forked from posit-dev/ggsql
-
Notifications
You must be signed in to change notification settings - Fork 0
575 lines (481 loc) · 18.9 KB
/
Copy pathrelease-packages.yml
File metadata and controls
575 lines (481 loc) · 18.9 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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
name: Release Cargo and Installer Packages
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build-windows:
name: Build Windows Installers
runs-on: windows-2022
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install tree-sitter-cli
run: npm install -g tree-sitter-cli
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
with:
targets: x86_64-pc-windows-msvc
- name: Install cargo-packager
run: cargo install cargo-packager --locked
- name: Build ggsql binary
run: cargo build --release --bin ggsql --bin ggsql-jupyter
- name: Sign files before making NSIS and MSI installer
id: sign-files
uses: ./.github/workflows/actions/sign-files
with:
paths: |
./target/release/ggsql.exe
./target/release/ggsql-jupyter.exe
env:
# environment variables required to sign with signtool
SM_HOST: ${{ secrets.SM_HOST }}
SM_API_KEY: ${{ secrets.SM_API_KEY }}
SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
SM_CLIENT_CERT_FINGERPRINT: ${{ secrets.SM_CLIENT_CERT_FINGERPRINT }}
- name: Build NSIS installer
run: cargo packager --release --formats nsis
- name: Build MSI installer
run: cargo packager --release --formats wix
- name: Sign installers
uses: ./.github/workflows/actions/sign-files
with:
paths: |
./ggsql-cli/target/release/packager/*.exe
./ggsql-cli/target/release/packager/*.msi
env:
# environment variables required to sign with signtool
SM_HOST: ${{ secrets.SM_HOST }}
SM_API_KEY: ${{ secrets.SM_API_KEY }}
SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
SM_CLIENT_CERT_FINGERPRINT: ${{ secrets.SM_CLIENT_CERT_FINGERPRINT }}
- name: Upload NSIS installer
uses: actions/upload-artifact@v4
with:
name: ggsql-windows-nsis
path: ggsql-cli/target/release/packager/*.exe
retention-days: 30
- name: Upload MSI installer
uses: actions/upload-artifact@v4
with:
name: ggsql-windows-msi
path: ggsql-cli/target/release/packager/*.msi
retention-days: 30
build-macos-x86_64:
name: Build macOS Installers (x86_64)
runs-on: macos-15-intel
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install tree-sitter-cli
run: npm install -g tree-sitter-cli
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
with:
targets: x86_64-apple-darwin
- name: Set up Apple notarization key
run: |
mkdir -p ~/.private_keys
echo -n "$APPLE_API_KEY_BASE64" | base64 --decode -o ~/.private_keys/AuthKey_${APPLE_API_KEY}.p8
chmod 600 ~/.private_keys/AuthKey_${APPLE_API_KEY}.p8
env:
APPLE_API_KEY_BASE64: ${{ secrets.GWS_APPLE_API_KEY_BASE64 }}
APPLE_API_KEY: ${{ secrets.GWS_APPLE_API_KEY }}
- name: Import signing certificates
env:
APPLICATION_P12: ${{ secrets.GWS_APPLE_SIGN_APPLICATION_P12 }}
INSTALLER_P12: ${{ secrets.GWS_APPLE_SIGN_INSTALLER_P12 }}
P12_PASSWORD: ${{ secrets.GWS_APPLE_SIGN_PW }}
run: |
KEYCHAIN_PATH="$RUNNER_TEMP/signing.keychain-db"
KEYCHAIN_PW="$(openssl rand -hex 32)"
security create-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_PATH"
security set-keychain-settings "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_PATH"
echo -n "$APPLICATION_P12" | base64 --decode -o "$RUNNER_TEMP/app.p12"
echo -n "$INSTALLER_P12" | base64 --decode -o "$RUNNER_TEMP/inst.p12"
security import "$RUNNER_TEMP/app.p12" -P "$P12_PASSWORD" -k "$KEYCHAIN_PATH" -T /usr/bin/codesign -T /usr/bin/pkgbuild
security import "$RUNNER_TEMP/inst.p12" -P "$P12_PASSWORD" -k "$KEYCHAIN_PATH" -T /usr/bin/codesign -T /usr/bin/pkgbuild
security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PW" "$KEYCHAIN_PATH"
security list-keychains -d user -s "$KEYCHAIN_PATH" $(security list-keychains -d user | tr -d '"')
- name: Compute version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Build ggsql binary (x86_64)
run: cargo build --release --bin ggsql --bin ggsql-jupyter
- name: Sign binaries (Developer ID Application)
env:
SIGN_ID: "Developer ID Application: ${{ secrets.GWS_APPLE_SIGN_IDENTITY }}"
run: |
codesign --force --options runtime --timestamp \
--entitlements entitlements.plist \
--sign "$SIGN_ID" target/release/ggsql
codesign --force --options runtime --timestamp \
--entitlements entitlements.plist \
--sign "$SIGN_ID" target/release/ggsql-jupyter
- name: Build and notarize PKG installer (x86_64)
# NOTE: --sign uses the Developer ID *Installer* cert (signs .pkg only),
# distinct from the Developer ID Application cert used to sign Mach-O above.
env:
SIGN_ID: "Developer ID Installer: ${{ secrets.GWS_APPLE_SIGN_IDENTITY }}"
APPLE_API_KEY: ${{ secrets.GWS_APPLE_API_KEY }}
APPLE_API_ISSUER: ${{ secrets.GWS_APPLE_API_ISSUER }}
run: |
PKG_NAME="ggsql_${VERSION}_x86_64.pkg"
mkdir -p pkg-payload/usr/local/bin
cp target/release/ggsql pkg-payload/usr/local/bin/
cp target/release/ggsql-jupyter pkg-payload/usr/local/bin/
mkdir -p pkg-scripts
cat > pkg-scripts/postinstall <<EOF
#!/bin/sh
mkdir -p /usr/local/bin
EOF
chmod 755 pkg-scripts/postinstall
pkgbuild \
--root ./pkg-payload \
--install-location / \
--identifier co.posit.ggsql \
--version "$VERSION" \
--scripts ./pkg-scripts \
--sign "$SIGN_ID" \
"$PKG_NAME"
xcrun notarytool submit "$PKG_NAME" \
--key ~/.private_keys/AuthKey_${APPLE_API_KEY}.p8 \
--key-id "$APPLE_API_KEY" \
--issuer "$APPLE_API_ISSUER" \
--wait
xcrun stapler staple "$PKG_NAME"
- name: Upload PKG installer (x86_64)
uses: actions/upload-artifact@v4
with:
name: ggsql-macos-pkg-x86_64
path: ggsql_*_x86_64.pkg
retention-days: 30
build-macos-aarch64:
name: Build macOS Installers (aarch64)
runs-on: macos-15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install tree-sitter-cli
run: npm install -g tree-sitter-cli
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
with:
targets: aarch64-apple-darwin
- name: Set up Apple notarization key
run: |
mkdir -p ~/.private_keys
echo -n "$APPLE_API_KEY_BASE64" | base64 --decode -o ~/.private_keys/AuthKey_${APPLE_API_KEY}.p8
chmod 600 ~/.private_keys/AuthKey_${APPLE_API_KEY}.p8
env:
APPLE_API_KEY_BASE64: ${{ secrets.GWS_APPLE_API_KEY_BASE64 }}
APPLE_API_KEY: ${{ secrets.GWS_APPLE_API_KEY }}
- name: Import signing certificates
env:
APPLICATION_P12: ${{ secrets.GWS_APPLE_SIGN_APPLICATION_P12 }}
INSTALLER_P12: ${{ secrets.GWS_APPLE_SIGN_INSTALLER_P12 }}
P12_PASSWORD: ${{ secrets.GWS_APPLE_SIGN_PW }}
run: |
KEYCHAIN_PATH="$RUNNER_TEMP/signing.keychain-db"
KEYCHAIN_PW="$(openssl rand -hex 32)"
security create-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_PATH"
security set-keychain-settings "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_PATH"
echo -n "$APPLICATION_P12" | base64 --decode -o "$RUNNER_TEMP/app.p12"
echo -n "$INSTALLER_P12" | base64 --decode -o "$RUNNER_TEMP/inst.p12"
security import "$RUNNER_TEMP/app.p12" -P "$P12_PASSWORD" -k "$KEYCHAIN_PATH" -T /usr/bin/codesign -T /usr/bin/pkgbuild
security import "$RUNNER_TEMP/inst.p12" -P "$P12_PASSWORD" -k "$KEYCHAIN_PATH" -T /usr/bin/codesign -T /usr/bin/pkgbuild
security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PW" "$KEYCHAIN_PATH"
security list-keychains -d user -s "$KEYCHAIN_PATH" $(security list-keychains -d user | tr -d '"')
- name: Compute version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Build ggsql binary (aarch64)
run: cargo build --release --bin ggsql --bin ggsql-jupyter
- name: Sign binaries (Developer ID Application)
env:
SIGN_ID: "Developer ID Application: ${{ secrets.GWS_APPLE_SIGN_IDENTITY }}"
run: |
codesign --force --options runtime --timestamp \
--entitlements entitlements.plist \
--sign "$SIGN_ID" target/release/ggsql
codesign --force --options runtime --timestamp \
--entitlements entitlements.plist \
--sign "$SIGN_ID" target/release/ggsql-jupyter
- name: Build and notarize PKG installer (aarch64)
# NOTE: --sign uses the Developer ID *Installer* cert (signs .pkg only),
# distinct from the Developer ID Application cert used to sign Mach-O above.
env:
SIGN_ID: "Developer ID Installer: ${{ secrets.GWS_APPLE_SIGN_IDENTITY }}"
APPLE_API_KEY: ${{ secrets.GWS_APPLE_API_KEY }}
APPLE_API_ISSUER: ${{ secrets.GWS_APPLE_API_ISSUER }}
run: |
PKG_NAME="ggsql_${VERSION}_aarch64.pkg"
mkdir -p pkg-payload/usr/local/bin
cp target/release/ggsql pkg-payload/usr/local/bin/
cp target/release/ggsql-jupyter pkg-payload/usr/local/bin/
mkdir -p pkg-scripts
cat > pkg-scripts/postinstall <<EOF
#!/bin/sh
mkdir -p /usr/local/bin
EOF
chmod 755 pkg-scripts/postinstall
pkgbuild \
--root ./pkg-payload \
--install-location / \
--identifier co.posit.ggsql \
--version "$VERSION" \
--scripts ./pkg-scripts \
--sign "$SIGN_ID" \
"$PKG_NAME"
xcrun notarytool submit "$PKG_NAME" \
--key ~/.private_keys/AuthKey_${APPLE_API_KEY}.p8 \
--key-id "$APPLE_API_KEY" \
--issuer "$APPLE_API_ISSUER" \
--wait
xcrun stapler staple "$PKG_NAME"
- name: Upload PKG installer (aarch64)
uses: actions/upload-artifact@v4
with:
name: ggsql-macos-pkg-aarch64
path: ggsql_*_aarch64.pkg
retention-days: 30
build-linux-x86_64:
name: Build Linux Installers (x86_64)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install tree-sitter-cli
run: npm install -g tree-sitter-cli
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
with:
targets: x86_64-unknown-linux-gnu
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Install cargo-packager
run: cargo install cargo-packager --locked
- name: Build ggsql binary (x86_64)
run: cargo build --release --bin ggsql --bin ggsql-jupyter
- name: Build Debian package (x86_64)
run: cargo packager --release --formats deb
- name: Upload Debian package (x86_64)
uses: actions/upload-artifact@v4
with:
name: ggsql-linux-deb-x86_64
path: ggsql-cli/target/release/packager/*.deb
retention-days: 30
build-linux-aarch64:
name: Build Linux Installers (aarch64)
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install tree-sitter-cli
run: npm install -g tree-sitter-cli
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
with:
targets: aarch64-unknown-linux-gnu
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Install cargo-packager
run: cargo install cargo-packager --locked
- name: Build ggsql binary (aarch64)
run: cargo build --release --bin ggsql --bin ggsql-jupyter
- name: Build Debian package (aarch64)
run: cargo packager --release --formats deb
- name: Upload Debian package (aarch64)
uses: actions/upload-artifact@v4
with:
name: ggsql-linux-deb-aarch64
path: ggsql-cli/target/release/packager/*.deb
retention-days: 30
build-cargo:
name: Publish to crates.io
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install tree-sitter-cli
run: npm install -g tree-sitter-cli
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
- name: Get crates.io publish token
uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Build tree-sitter-ggsql
run: cargo build --package tree-sitter-ggsql
- name: Publish tree-sitter-ggsql
run: cargo publish --package tree-sitter-ggsql --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Wait for crates.io index update
run: sleep 30
- name: Publish ggsql
run: cargo publish --package ggsql
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Wait for crates.io index update
run: sleep 30
- name: Publish ggsql-jupyter
run: cargo publish --package ggsql-jupyter
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Publish ggsql-cli
run: cargo publish --package ggsql-cli
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
build-wasm:
name: Build Wasm Package (wasm32)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Increase disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
sudo docker builder prune -a
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Install tree-sitter-cli
run: npm install -g tree-sitter-cli
- name: Install Rust toolchain
# This job only builds wasm, which is exempt from the 1.86 MSRV (R
# doesn't use wasm) and needs a newer rustc, so the whole job runs on
# stable. ggsql-wasm/rust-toolchain.toml also selects stable for the build.
uses: dtolnay/rust-toolchain@stable
- name: Install LLVM
run: sudo apt-get install -y llvm
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Install wasm-opt
run: cargo install wasm-opt
- name: Build WASM package
run: ./ggsql-wasm/build-wasm.sh
- name: Create npm tarball
working-directory: ggsql-wasm/pkg
run: npm pack
- name: Upload npm tarball
uses: actions/upload-artifact@v4
with:
name: ggsql-wasm-npm
path: ggsql-wasm/pkg/*.tgz
retention-days: 30
publish-npm:
name: Publish to npm
needs: [build-wasm]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
environment: npm
permissions:
id-token: write
contents: read
steps:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Download npm tarball
uses: actions/download-artifact@v4
with:
name: ggsql-wasm-npm
path: npm-tarball
- name: Update npm for OIDC support
# Install v10.9.8 first as workaround for nodejs/node#62425
run: |
npm install -g npm@10.9.8
npm install -g npm@latest
- name: Determine npm dist-tag
id: dist-tag
run: |
if [[ "$GITHUB_REF_NAME" == *"-dev"* || "$GITHUB_REF_NAME" == *"-rc"* ]]; then
echo "tag=next" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi
- name: Publish to npm
run: npm publish ./npm-tarball/*.tgz --access=public --provenance --tag ${{ steps.dist-tag.outputs.tag }}
create-release:
name: Create GitHub Release
needs: [build-windows, build-macos-x86_64, build-macos-aarch64, build-linux-x86_64, build-linux-aarch64, build-cargo, build-wasm]
runs-on: ubuntu-latest
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts
- name: Create release and upload installers
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/**/*.exe
artifacts/**/*.msi
artifacts/**/*.pkg
artifacts/**/*.deb
artifacts/**/*.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}