-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (171 loc) · 6.95 KB
/
release.yml
File metadata and controls
202 lines (171 loc) · 6.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Build and Release
on:
push:
tags:
- 'v*'
permissions:
contents: write # needed to create releases and upload assets
jobs:
build:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Show Xcode version
run: |
xcode-select -p
xcodebuild -version
swift --version
- name: List schemes (debug)
run: |
xcodebuild -project NetworkMonitor.xcodeproj -list
- name: Build Release
run: |
xcodebuild \
-project NetworkMonitor.xcodeproj \
-scheme NetworkMonitor \
-configuration Release \
-derivedDataPath "$GITHUB_WORKSPACE/.build" \
CODE_SIGN_IDENTITY="-" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
ONLY_ACTIVE_ARCH=NO \
build
- name: Verify binary
run: |
APP="$GITHUB_WORKSPACE/.build/Build/Products/Release/NetworkMonitor.app"
ls -la "$APP/Contents/MacOS/"
echo "App size: $(du -sh "$APP" | cut -f1)"
- name: Sign ad-hoc
run: |
APP="$GITHUB_WORKSPACE/.build/Build/Products/Release/NetworkMonitor.app"
codesign --force --deep --sign "-" "$APP"
- name: Package
run: |
APP="$GITHUB_WORKSPACE/.build/Build/Products/Release/NetworkMonitor.app"
mkdir -p dist/daemon
cp -R "$APP" dist/
cp install.sh dist/
cp README.md dist/
chmod +x dist/install.sh
zip -r NetworkMonitor-release.zip dist/ -x "*.DS_Store" -x "__MACOSX/*"
echo "Zip size: $(du -sh NetworkMonitor-release.zip | cut -f1)"
unzip -l NetworkMonitor-release.zip
- name: Compute sha256
id: sha
run: |
SHA=$(shasum -a 256 NetworkMonitor-release.zip | awk '{print $1}')
echo "sha256=$SHA" >> "$GITHUB_OUTPUT"
echo "SHA-256: $SHA"
- name: Upload release asset
uses: softprops/action-gh-release@v2
with:
name: "Network Monitor ${{ github.ref_name }}"
body: |
## 🌐 Network Monitor ${{ github.ref_name }}
### How to install
**Option 1 — Homebrew (recommended)**
```
brew tap RandomUserUsingGitHub/tap
brew install --cask network-monitor
```
**Option 2 — Manual**
1. Download **NetworkMonitor-release.zip** below ↓
2. Unzip it
3. Drag `NetworkMonitor.app` → `/Applications`
4. Open Terminal and run:
```
bash install.sh
```
> If macOS says "unidentified developer": right-click → **Open** → **Open Anyway** (once only)
### Requirements
macOS 13 or later
### SHA-256
`${{ steps.sha.outputs.sha256 }}`
files: NetworkMonitor-release.zip
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-homebrew:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout tap repo
uses: actions/checkout@v4
with:
repository: RandomUserUsingGitHub/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Download release zip for sha256
run: |
VERSION="${GITHUB_REF_NAME#v}"
curl -sL -o release.zip "https://github.com/RandomUserUsingGitHub/NetworkMonitoring/releases/download/${GITHUB_REF_NAME}/NetworkMonitor-release.zip"
SHA=$(sha256sum release.zip | awk '{print $1}')
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "SHA256=$SHA" >> "$GITHUB_ENV"
echo "Version: $VERSION, SHA-256: $SHA"
- name: Update Cask formula
run: |
CASK="homebrew-tap/Casks/network-monitor.rb"
if [ ! -f "$CASK" ]; then
CASK="homebrew-tap/network-monitor.rb"
fi
cat <<EOF > "$CASK"
cask "network-monitor" do
version "${VERSION}"
sha256 "${SHA256}"
url "https://github.com/RandomUserUsingGitHub/NetworkMonitoring/releases/download/v${VERSION}/NetworkMonitor-release.zip"
name "Network Monitor"
desc "Lightweight macOS network monitoring app with live ping graph and IP tracking"
homepage "https://github.com/RandomUserUsingGitHub/NetworkMonitoring"
depends_on macos: ">= :ventura"
app "dist/NetworkMonitor.app"
postflight do
# Write default config if none exists
cfg_dir = File.expand_path("~/.config/network-monitor")
FileUtils.mkdir_p(cfg_dir)
cfg_file = "#{cfg_dir}/settings.json"
unless File.exist?(cfg_file)
File.write(cfg_file, <<~JSON)
{
"ping": { "host": "8.8.8.8", "interval_seconds": 2, "fail_threshold": 3,
"timeout_seconds": 2, "packet_size": 56, "history_size": 60 },
"ip_check": { "interval_seconds": 10 },
"notifications": { "sound": "Basso", "enabled": true, "censor_on_change": false },
"ui": { "theme": "green", "ping_graph_width": 60 },
"log": { "tail_lines": 7 }
}
JSON
end
# Clean up old daemon-style LaunchAgent if present
old_plist = File.expand_path("~/Library/LaunchAgents/com.user.network-monitor.plist")
if File.exist?(old_plist)
system_command "/bin/launchctl", args: ["unload", old_plist]
File.delete(old_plist)
end
end
uninstall delete: [
File.expand_path("~/Library/LaunchAgents/com.armin.network-monitor.login.plist"),
File.expand_path("~/Library/LaunchAgents/com.user.network-monitor.plist"),
]
zap trash: [
"~/.config/network-monitor",
"~/.network_monitor.log",
"/tmp/.netmon_*",
]
end
EOF
echo "Updated Cask:"
head -5 "$CASK"
- name: Commit and push
env:
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
cd homebrew-tap
git remote set-url origin "https://x-access-token:${TAP_TOKEN}@github.com/RandomUserUsingGitHub/homebrew-tap.git"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/network-monitor.rb
git diff --cached --quiet && echo "No changes" && exit 0
git commit -m "Update network-monitor to ${VERSION}"
git push