-
Notifications
You must be signed in to change notification settings - Fork 247
379 lines (317 loc) · 11.2 KB
/
build.yml
File metadata and controls
379 lines (317 loc) · 11.2 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
name: "build"
on:
push:
pull_request:
workflow_dispatch:
env:
SKIP_TESTS: 1
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install dependencies
run: |
npm ci
- name: Type check
run: |
npm run ts-check
- name: Build and package
run: |
node release/package-all.js --os linux --arch amd64
- name: Create tarball to preserve permissions
if: github.event_name == 'workflow_dispatch'
run: |
cd artifacts/linux-amd64
tar -cf ../linux-amd64.tar .
- name: Upload artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v6
with:
name: ${{ github.ref_type == 'tag' && !endsWith(github.ref_name, '-canary') && 'itch' || 'kitch' }}-${{ github.ref_name }}-linux-amd64
path: artifacts/linux-amd64.tar
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install dependencies
run: |
npm ci
- name: Type check
run: |
npm run ts-check
- name: Build and package
run: |
node release/package-all.js --os windows --arch amd64
- name: Upload unsigned artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v6
with:
name: windows-amd64-unsigned
path: artifacts/windows-amd64/
sign-windows:
needs: [build-windows]
if: github.event_name == 'workflow_dispatch'
runs-on: windows-latest
environment: signing-windows
steps:
- name: Download unsigned artifact
uses: actions/download-artifact@v7
with:
name: windows-amd64-unsigned
path: artifacts/windows-amd64/
- name: Sign with Azure Code Signing
uses: azure/artifact-signing-action@v1
with:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
endpoint: https://wus2.codesigning.azure.net
signing-account-name: itchio
certificate-profile-name: itchio
files: ${{ github.workspace }}/artifacts/windows-amd64/*.exe
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
- name: Verify signature
shell: pwsh
run: |
$exeFiles = Get-ChildItem -Path "artifacts/windows-amd64/*.exe"
foreach ($file in $exeFiles) {
$sig = Get-AuthenticodeSignature -FilePath $file.FullName
if ($sig.Status -ne "Valid") {
Write-Error "Signature verification failed for $($file.Name): $($sig.Status)"
exit 1
}
Write-Host "Signature verified for $($file.Name)"
}
- name: Upload signed artifact
uses: actions/upload-artifact@v6
with:
name: ${{ github.ref_type == 'tag' && !endsWith(github.ref_name, '-canary') && 'itch' || 'kitch' }}-${{ github.ref_name }}-windows-amd64
path: artifacts/windows-amd64/
build-macos-x64:
runs-on: macos-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v6
with:
node-version: '22'
- uses: actions/setup-go@v6
with:
go-version: '^1.22.1'
- name: Install dependencies
run: |
npm ci
- name: Type check
run: |
npm run ts-check
- name: Build and package (x64)
run: |
node release/package-all.js --os darwin --arch amd64
- name: Create tarball to preserve symlinks
if: github.event_name == 'workflow_dispatch'
run: |
cd artifacts/darwin-amd64
tar -cf ../darwin-amd64.tar .
- name: Upload unsigned artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v6
with:
name: darwin-amd64-unsigned
path: artifacts/darwin-amd64.tar
build-macos-arm64:
runs-on: macos-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v6
with:
node-version: '22'
- uses: actions/setup-go@v6
with:
go-version: '^1.22.1'
- name: Install dependencies
run: |
npm ci
- name: Type check
run: |
npm run ts-check
- name: Build and package (arm64)
run: |
node release/package-all.js --os darwin --arch arm64
- name: Create tarball to preserve symlinks
if: github.event_name == 'workflow_dispatch'
run: |
cd artifacts/darwin-arm64
tar -cf ../darwin-arm64.tar .
- name: Upload unsigned artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v6
with:
name: darwin-arm64-unsigned
path: artifacts/darwin-arm64.tar
sign-macos:
needs: [build-macos-x64, build-macos-arm64]
if: github.event_name == 'workflow_dispatch'
runs-on: macos-latest
environment: signing-macos
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Download unsigned x64 artifact
uses: actions/download-artifact@v7
with:
name: darwin-amd64-unsigned
path: artifacts/
- name: Download unsigned arm64 artifact
uses: actions/download-artifact@v7
with:
name: darwin-arm64-unsigned
path: artifacts/
- name: Extract tarballs (preserves symlinks)
run: |
mkdir -p artifacts/darwin-amd64 artifacts/darwin-arm64
tar -xf artifacts/darwin-amd64.tar -C artifacts/darwin-amd64
tar -xf artifacts/darwin-arm64.tar -C artifacts/darwin-arm64
- name: Install dependencies
run: npm ci
- name: Import signing certificate
env:
APPLE_CERTIFICATE_P12_BASE64: ${{ secrets.APPLE_CERTIFICATE_P12_BASE64 }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
# Create temporary keychain
KEYCHAIN_PATH=$RUNNER_TEMP/signing.keychain-db
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
# Import certificate
CERT_PATH=$RUNNER_TEMP/certificate.p12
echo "$APPLE_CERTIFICATE_P12_BASE64" | base64 --decode > "$CERT_PATH"
security import "$CERT_PATH" -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
rm "$CERT_PATH"
# Set keychain search list
security list-keychain -d user -s "$KEYCHAIN_PATH"
# Allow codesign to access the keychain
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
- name: Sign and notarize apps
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
node release/sign-macos.js --arch amd64
node release/sign-macos.js --arch arm64
- name: Create signed tarballs (preserves symlinks)
run: |
tar -cf artifacts/darwin-amd64-signed.tar -C artifacts/darwin-amd64 .
tar -cf artifacts/darwin-arm64-signed.tar -C artifacts/darwin-arm64 .
- name: Upload signed x64 artifact
uses: actions/upload-artifact@v6
with:
name: ${{ github.ref_type == 'tag' && !endsWith(github.ref_name, '-canary') && 'itch' || 'kitch' }}-${{ github.ref_name }}-darwin-amd64
path: artifacts/darwin-amd64-signed.tar
- name: Upload signed arm64 artifact
uses: actions/upload-artifact@v6
with:
name: ${{ github.ref_type == 'tag' && !endsWith(github.ref_name, '-canary') && 'itch' || 'kitch' }}-${{ github.ref_name }}-darwin-arm64
path: artifacts/darwin-arm64-signed.tar
create-github-release:
if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/')
needs: [build-linux, sign-windows, sign-macos]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
pattern: "{itch,kitch}-*"
- name: Create archives
run: |
set -e
cd artifacts
for dir in */; do
dirname=$(basename "$dir")
if ls "$dir"/*.tar 1> /dev/null 2>&1; then
# Compress existing tar (preserves permissions and symlinks)
gzip -c "$dir"/*.tar > "${dirname}.tar.gz"
else
# For platforms without a pre-built tar (e.g. Windows)
tar -czf "${dirname}.tar.gz" -C "$dir" .
fi
done
ls -lh *.tar.gz
- name: Create GitHub Release and upload artifacts
uses: softprops/action-gh-release@v2
with:
files: artifacts/*.tar.gz
draft: false
prerelease: ${{ contains(github.ref_name, 'canary') }}
publish-to-itchio:
if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/')
needs: [build-linux, sign-windows, sign-macos]
runs-on: ubuntu-latest
environment: butler-publish
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install dependencies
run: npm ci
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
pattern: "{itch,kitch}-*"
- name: Extract tarballs (preserves permissions and symlinks)
run: |
cd artifacts
for dir in */; do
if ls "$dir"/*.tar 1> /dev/null 2>&1; then
tar -xf "$dir"/*.tar -C "$dir"
rm "$dir"/*.tar
fi
done
- name: Verify macOS bundle structure
run: |
# The auto-updater expects Contents/ at the archive root, not app.app/Contents/
# Butler push on a .app directory achieves this, but let's verify the structure
for dir in artifacts/*darwin*; do
if [ -d "$dir" ]; then
app_bundle=$(find "$dir" -maxdepth 1 -name "*.app" -type d | head -1)
if [ -z "$app_bundle" ]; then
echo "ERROR: No .app bundle found in $dir"
exit 1
fi
# Verify expected structure exists
if [ ! -f "$app_bundle/Contents/Info.plist" ]; then
echo "ERROR: Missing Contents/Info.plist in $app_bundle"
exit 1
fi
if [ ! -d "$app_bundle/Contents/MacOS" ]; then
echo "ERROR: Missing Contents/MacOS in $app_bundle"
exit 1
fi
if [ ! -d "$app_bundle/Contents/Frameworks" ]; then
echo "ERROR: Missing Contents/Frameworks in $app_bundle"
exit 1
fi
echo "OK: $app_bundle has correct bundle structure"
fi
done
- name: Deploy to itch.io
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: node release/deploy.js