-
Notifications
You must be signed in to change notification settings - Fork 6
383 lines (324 loc) · 12.8 KB
/
Copy pathrelease.yml
File metadata and controls
383 lines (324 loc) · 12.8 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
verify:
uses: ./.github/workflows/ci.yml
validate-release-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Verify release tag matches checked-in app versions
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"
workspace_version="$(sed -nE 's/^version = "([^"]+)"/\1/p' Cargo.toml | head -1)"
tauri_version="$(python3 -c 'import json; print(json.load(open("crates/diffcore-tauri/tauri.conf.json"))["version"])')"
if [ "$tag_version" != "$workspace_version" ]; then
echo "::error::Release tag $tag_version does not match workspace version $workspace_version"
exit 1
fi
if [ "$tag_version" != "$tauri_version" ]; then
echo "::error::Release tag $tag_version does not match Tauri app version $tauri_version"
exit 1
fi
build-macos:
needs: [verify, validate-release-version]
runs-on: macos-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
cache-dependency-path: crates/diffcore-tauri/ui/package-lock.json
- name: Install UI dependencies
working-directory: crates/diffcore-tauri/ui
run: npm ci
- name: Install Tauri CLI
run: cargo install tauri-cli --version "^2" --locked
- name: Import Apple certificate
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
CERTIFICATE_PATH="$RUNNER_TEMP/certificate.p12"
KEYCHAIN_PATH="$RUNNER_TEMP/app-signing.keychain-db"
echo -n "$APPLE_CERTIFICATE" | base64 --decode -o "$CERTIFICATE_PATH"
security create-keychain -p "" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "" "$KEYCHAIN_PATH"
security import "$CERTIFICATE_PATH" -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
security set-key-partition-list -S apple-tool:,apple: -k "" "$KEYCHAIN_PATH"
security list-keychain -d user -s "$KEYCHAIN_PATH"
- name: Write Apple API key
env:
APPLE_API_KEY_CONTENT: ${{ secrets.APPLE_API_KEY_CONTENT }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
run: |
API_KEY_PATH="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY}.p8"
echo -n "$APPLE_API_KEY_CONTENT" > "$API_KEY_PATH"
chmod 600 "$API_KEY_PATH"
- name: Build Tauri app (Apple Silicon)
env:
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
APPLE_API_KEY_PATH: ${{ runner.temp }}/AuthKey_${{ secrets.APPLE_API_KEY }}.p8
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
run: cargo tauri build --target aarch64-apple-darwin
- name: Verify code signing and notarization
env:
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
APPLE_API_KEY_PATH: ${{ runner.temp }}/AuthKey_${{ secrets.APPLE_API_KEY }}.p8
run: |
set -euo pipefail
MOUNT_DIR=""
cleanup() {
if [ -n "${MOUNT_DIR}" ] && mount | grep -q "${MOUNT_DIR}"; then
hdiutil detach "${MOUNT_DIR}" -quiet || true
fi
}
trap cleanup EXIT
echo "::group::Locate .app bundle"
DMG_PATH=$(find target/aarch64-apple-darwin/release/bundle/dmg -name "*.dmg" -type f | head -1)
if [ -z "$DMG_PATH" ]; then
echo "::error::No DMG found in bundle output"
exit 1
fi
APP_PATH=$(find target/aarch64-apple-darwin/release/bundle -name "*.app" -type d | head -1)
if [ -z "$APP_PATH" ]; then
echo "No .app found in bundle dir, mounting DMG to verify..."
MOUNT_DIR="$(mktemp -d)"
hdiutil attach "$DMG_PATH" -mountpoint "$MOUNT_DIR" -nobrowse -quiet
APP_PATH=$(find "$MOUNT_DIR" -maxdepth 1 -name "*.app" -type d | head -1)
fi
if [ -z "$APP_PATH" ]; then
echo "::error::No .app found in bundle output or mounted DMG"
exit 1
fi
echo "Found app at: $APP_PATH"
echo "Found DMG at: $DMG_PATH"
echo "::endgroup::"
echo "::group::Verify app signature"
codesign -dvvv "$APP_PATH"
echo "::endgroup::"
echo "::group::Verify signature validity"
codesign --verify --deep --strict "$APP_PATH"
echo "::endgroup::"
echo "::group::Check signing identity"
IDENTITY=$(codesign -dvvv "$APP_PATH" 2>&1 | grep "Authority=Developer ID Application" || true)
if [ -z "$IDENTITY" ]; then
echo "::error::App is NOT signed with Developer ID Application certificate!"
exit 1
fi
echo "Signed by: $IDENTITY"
echo "::endgroup::"
echo "::group::Gatekeeper assessment (.app)"
spctl --assess --type execute --verbose "$APP_PATH"
echo "::endgroup::"
echo "::group::Notarize and staple DMG"
xcrun notarytool submit \
"$DMG_PATH" \
--issuer "$APPLE_API_ISSUER" \
--key-id "$APPLE_API_KEY" \
--key "$APPLE_API_KEY_PATH" \
--wait
xcrun stapler staple "$DMG_PATH"
echo "::endgroup::"
echo "::group::Validate notarized DMG ticket"
xcrun stapler validate "$DMG_PATH"
echo "::endgroup::"
echo "::group::Gatekeeper assessment (.dmg)"
spctl --assess --type open --context context:primary-signature --verbose "$DMG_PATH"
echo "::endgroup::"
- name: List macOS bundle outputs
run: |
echo "::group::All bundle files"
find target/aarch64-apple-darwin/release/bundle -type f | sort
echo "::endgroup::"
- name: Upload macOS artifacts
uses: actions/upload-artifact@v6
with:
name: diffcore-aarch64-apple-darwin
path: |
target/aarch64-apple-darwin/release/bundle/dmg/*.dmg
target/aarch64-apple-darwin/release/bundle/macos/*.tar.gz
target/aarch64-apple-darwin/release/bundle/macos/*.tar.gz.sig
if-no-files-found: warn
build-linux:
needs: [verify, validate-release-version]
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
cache-dependency-path: crates/diffcore-tauri/ui/package-lock.json
- name: Install UI dependencies
working-directory: crates/diffcore-tauri/ui
run: npm ci
- name: Install Tauri CLI
run: cargo install tauri-cli --version "^2" --locked
- name: Build Tauri app
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
run: cargo tauri build
- name: Upload Linux artifacts
uses: actions/upload-artifact@v6
with:
name: diffcore-linux
path: |
target/release/bundle/deb/*.deb
target/release/bundle/appimage/*.AppImage
target/release/bundle/appimage/*.AppImage.sig
build-windows:
needs: [verify, validate-release-version]
runs-on: windows-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
cache-dependency-path: crates/diffcore-tauri/ui/package-lock.json
- name: Install UI dependencies
working-directory: crates/diffcore-tauri/ui
run: npm ci
- name: Install Tauri CLI
run: cargo install tauri-cli --version "^2" --locked
- name: Build Tauri app
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
run: cargo tauri build
- name: Upload Windows artifacts
uses: actions/upload-artifact@v6
with:
name: diffcore-windows
path: |
target/release/bundle/msi/*.msi
target/release/bundle/msi/*.msi.sig
target/release/bundle/nsis/*.exe
target/release/bundle/nsis/*.exe.sig
create-release:
needs: [build-macos, build-linux, build-windows]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: List downloaded artifacts
run: find artifacts -type f | sort
- name: Create or update GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${GITHUB_REF_NAME}"
files=()
while IFS= read -r -d '' file; do
files+=("$file")
done < <(
find artifacts -type f \( \
-name '*.dmg' -o \
-name '*.tar.gz' -o \
-name '*.deb' -o \
-name '*.AppImage' -o \
-name '*.AppImage.sig' -o \
-name '*.msi' -o \
-name '*.msi.sig' -o \
-name '*.exe' -o \
-name '*.exe.sig' \
\) ! -name '*.tar.gz.sig' -print0
)
if [ ${#files[@]} -eq 0 ]; then
echo "No release assets found under artifacts/"
exit 1
fi
if gh release view "$tag" > /dev/null 2>&1; then
gh release upload "$tag" "${files[@]}" --clobber
else
gh release create "$tag" "${files[@]}" --generate-notes --verify-tag
fi
- name: Generate updater manifest (latest.json)
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
base_url="https://github.com/jamesaphoenix/diff-core/releases/download/${tag}"
notes="$(gh release view "$tag" --json body -q .body | head -c 2000)"
pub_date="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
# Read signatures
mac_sig=""
linux_sig=""
win_nsis_sig=""
for f in $(find artifacts -name "*.sig" -type f); do
content="$(cat "$f")"
case "$f" in
*.tar.gz.sig) mac_sig="$content" ;;
*.AppImage.sig) linux_sig="$content" ;;
*.exe.sig) win_nsis_sig="$content" ;;
esac
done
# Find artifact filenames
mac_tar="$(find artifacts -name '*.tar.gz' ! -name '*.sig' -type f | head -1 | xargs basename 2>/dev/null || echo '')"
linux_appimage="$(find artifacts -name '*.AppImage' -type f | head -1 | xargs basename 2>/dev/null || echo '')"
win_exe="$(find artifacts -name '*.exe' -type f | head -1 | xargs basename 2>/dev/null || echo '')"
cat > latest.json <<JSONEOF
{
"version": "${version}",
"notes": $(echo "$notes" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))'),
"pub_date": "${pub_date}",
"platforms": {
"darwin-aarch64": {
"signature": "${mac_sig}",
"url": "${base_url}/${mac_tar}"
},
"linux-x86_64": {
"signature": "${linux_sig}",
"url": "${base_url}/${linux_appimage}"
},
"windows-x86_64": {
"signature": "${win_nsis_sig}",
"url": "${base_url}/${win_exe}"
}
}
}
JSONEOF
gh release upload "$tag" latest.json --clobber