Repository navigation
324 lines (279 loc) · 9.85 KB
/
Copy pathrelease.yml
File metadata and controls
324 lines (279 loc) · 9.85 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
verify:
name: Verify release
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up pnpm
uses: pnpm/action-setup@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
- name: Build
run: pnpm build
build-macos:
name: Build macOS (${{ matrix.arch }})
needs: verify
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- runner: macos-15
arch: arm64
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up pnpm
uses: pnpm/action-setup@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Validate Apple signing secrets
shell: bash
env:
MACOS_CERTIFICATE_P12_BASE64: ${{ secrets.MACOS_CERTIFICATE_P12_BASE64 }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY_P8_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
run: |
required_secrets=(
MACOS_CERTIFICATE_P12_BASE64
MACOS_CERTIFICATE_PASSWORD
APPLE_API_KEY_P8_BASE64
APPLE_API_KEY_ID
APPLE_API_ISSUER
)
missing_secrets=()
for secret_name in "${required_secrets[@]}"; do
if [[ -z "${!secret_name}" ]]; then
missing_secrets+=("$secret_name")
fi
done
if (( ${#missing_secrets[@]} > 0 )); then
printf 'Missing required GitHub Actions secrets: %s\n' "${missing_secrets[*]}"
exit 1
fi
- name: Import Developer ID certificate
shell: bash
env:
MACOS_CERTIFICATE_P12_BASE64: ${{ secrets.MACOS_CERTIFICATE_P12_BASE64 }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
run: |
certificate_path="$RUNNER_TEMP/developer-id-application.p12"
keychain_path="$RUNNER_TEMP/git-gud-signing.keychain-db"
keychain_password="$(openssl rand -hex 24)"
printf '%s' "$MACOS_CERTIFICATE_P12_BASE64" | base64 --decode > "$certificate_path"
security create-keychain -p "$keychain_password" "$keychain_path"
security set-keychain-settings -lut 21600 "$keychain_path"
security unlock-keychain -p "$keychain_password" "$keychain_path"
security import "$certificate_path" \
-P "$MACOS_CERTIFICATE_PASSWORD" \
-A \
-t cert \
-f pkcs12 \
-k "$keychain_path"
security set-key-partition-list \
-S apple-tool:,apple:,codesign: \
-s \
-k "$keychain_password" \
"$keychain_path"
security list-keychains -d user -s "$keychain_path"
signing_identity="$(
security find-identity -v -p codesigning "$keychain_path" \
| awk -F '"' '/Developer ID Application:/ { print $2; exit }'
)"
if [[ -z "$signing_identity" ]]; then
echo 'The certificate does not contain a valid Developer ID Application identity.'
exit 1
fi
echo "MACOS_SIGNING_IDENTITY=$signing_identity" >> "$GITHUB_ENV"
echo "MACOS_SIGNING_KEYCHAIN=$keychain_path" >> "$GITHUB_ENV"
echo "MACOS_CERTIFICATE_PATH=$certificate_path" >> "$GITHUB_ENV"
- name: Prepare App Store Connect API key
shell: bash
env:
APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY_P8_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
run: |
api_key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
printf '%s' "$APPLE_API_KEY_P8_BASE64" | base64 --decode > "$api_key_path"
chmod 600 "$api_key_path"
echo "APPLE_API_KEY_PATH=$api_key_path" >> "$GITHUB_ENV"
- name: Build macOS application
env:
GIT_GUD_VERSION: ${{ github.ref_name }}
run: pnpm dist
- name: Notarize and staple macOS application
env:
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
run: node scripts/notarize-macos-app.mjs
- name: Verify signed and notarized application
shell: bash
run: |
codesign --verify --deep --strict --verbose=2 "dist/mac/Git Gud.app"
team_identifier="$(
codesign -d --verbose=4 "dist/mac/Git Gud.app" 2>&1 \
| awk -F= '/^TeamIdentifier=/ { print $2; exit }'
)"
if [[ "$team_identifier" != "G6L7T68JBX" ]]; then
echo "Unexpected updater signing team: ${team_identifier:-missing}"
exit 1
fi
bundle_identifier="$(
/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' \
"dist/mac/Git Gud.app/Contents/Info.plist"
)"
if [[ "$bundle_identifier" != "dev.kaldy.git-gud" ]]; then
echo "Unexpected updater bundle identifier: ${bundle_identifier:-missing}"
exit 1
fi
# Both checks ask Apple's ticket service online, which sometimes drops runner
# connections (stapler "Error 68", NSURLErrorDomain -1005); retry before failing.
retry() {
for attempt in 1 2 3 4; do
"$@" && return 0
echo "Attempt ${attempt} failed: $*"
sleep $((attempt * 20))
done
return 1
}
retry xcrun stapler validate "dist/mac/Git Gud.app"
retry syspolicy_check distribution "dist/mac/Git Gud.app"
- name: Package release artifact
shell: bash
run: |
archive_name="Git-Gud-${GITHUB_REF_NAME}-macOS-${{ matrix.arch }}.zip"
mkdir -p artifacts
ditto -c -k --sequesterRsrc --keepParent "dist/mac/Git Gud.app" "artifacts/$archive_name"
node scripts/write-release-checksum.mjs "artifacts/$archive_name"
- name: Upload workflow artifact
uses: actions/upload-artifact@v7
with:
name: release-${{ matrix.arch }}
path: artifacts/*
if-no-files-found: error
compression-level: 0
retention-days: 14
- name: Remove temporary Apple credentials
if: ${{ always() }}
shell: bash
run: |
if [[ -n "${MACOS_SIGNING_KEYCHAIN:-}" ]]; then
security delete-keychain "$MACOS_SIGNING_KEYCHAIN" || true
fi
rm -f \
"${MACOS_CERTIFICATE_PATH:-}" \
"${APPLE_API_KEY_PATH:-}"
build-windows:
name: Build Windows (x64)
needs: verify
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up pnpm
uses: pnpm/action-setup@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test Windows integration seams
run: >-
pnpm exec vitest run
src/main/git/exec.test.ts
src/main/externalApplications.test.ts
src/main/system.test.ts
src/main/profiles.test.ts
src/main/piHarness.test.ts
src/main/machines.test.ts
src/main/updater.test.ts
src/renderer/src/components/statusbar/StatusBar.test.tsx
- name: Build portable Windows application
env:
CSC_IDENTITY_AUTO_DISCOVERY: "false"
GIT_GUD_VERSION: ${{ github.ref_name }}
run: pnpm dist:windows
- name: Create checksum
shell: pwsh
run: |
$artifacts = @(Get-ChildItem "dist/windows/*.exe")
if ($artifacts.Count -ne 1) {
throw "Expected one Windows executable, found $($artifacts.Count)."
}
$artifact = $artifacts[0]
node scripts/write-release-checksum.mjs "$($artifact.FullName)"
- name: Upload workflow artifact
uses: actions/upload-artifact@v7
with:
name: release-windows-x64
path: |
dist/windows/*.exe
dist/windows/*.exe.sha256
if-no-files-found: error
compression-level: 0
retention-days: 14
publish:
name: Publish GitHub Release
needs:
- build-macos
- build-windows
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Download release artifacts
uses: actions/download-artifact@v8
with:
pattern: release-*
path: release-artifacts
merge-multiple: true
- name: Verify checksums
shell: bash
run: |
cd release-artifacts
for checksum in *.sha256; do
shasum -a 256 -c "$checksum"
done
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: >-
gh release create "$GITHUB_REF_NAME"
release-artifacts/*
--verify-tag
--generate-notes
--title "Git Gud $GITHUB_REF_NAME"