-
-
Notifications
You must be signed in to change notification settings - Fork 10
429 lines (370 loc) · 12.8 KB
/
release.yaml
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
name: Release
on:
push:
tags:
- v*
workflow_dispatch: {}
permissions:
contents: write
id-token: write
jobs:
make-draft-release:
name: make draft release
permissions: write-all
runs-on: ubuntu-22.04
timeout-minutes: 360
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check if package version matches
run: test "${GITHUB_REF_NAME}" = "v$(jq -r .version freelens/package.json)"
- name: Create draft release
run: |
gh release create ${GITHUB_REF_NAME} \
--draft \
--title ${GITHUB_REF_NAME}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-app:
name: build app
needs:
- make-draft-release
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
arch: arm64
concurrency: linux-arm64
- os: ubuntu-22.04
arch: x64
concurrency: linux-amd64
- os: macos-14
arch: arm64
concurrency: macos
- os: macos-14
arch: x64
concurrency: macos
- os: windows-2022
arch: x64
concurrency: windows
runs-on: ${{ matrix.os }}
environment: signing
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ matrix.concurrency }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Get NPM cache directory
shell: bash
run: echo "npm_cache_dir=$(npm config get cache)" >> ${GITHUB_ENV}
- name: Use npm cache
uses: actions/cache@v4
with:
path: ${{ env.npm_cache_dir }}
key: ${{ matrix.os }}-${{ matrix.arch }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.arch }}-node-
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
retry_on: any
command: |
sudo apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
retry_on: any
command: brew install bash python-setuptools
- name: Install NPM dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
retry_on: any
command: npm ci
- name: Rebuild for arch (Linux arm64)
if: runner.os == 'Linux' && matrix.arch == 'arm64'
run: npm run rebuild -- -- -a arm64
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
- name: Monkey patch FPM arguments for RPM (Linux arm64)
if: runner.os == 'Linux' && matrix.arch == 'arm64'
run: |
sed -i 's/\? "aarch64" : "arm64"/|| targetName === "rpm" &/' node_modules/builder-util/out/arch.js
- name: Rebuild for arch (macOS x64)
if: runner.os == 'macOS' && matrix.arch == 'x64'
run: npm run rebuild -- -- -a x64
- name: Build NPM packages (macOS x64, Linux arm64)
if: runner.os == 'macOS' && matrix.arch == 'x64' || runner.os == 'Linux' && matrix.arch == 'arm64'
run: npm run build
env:
DOWNLOAD_ALL_ARCHITECTURES: "true"
- name: Build NPM packages (macOS arm64, Linux x64, Windows)
if: runner.os == 'macOS' && matrix.arch == 'arm64' || runner.os == 'Linux' && matrix.arch == 'x64' || runner.os == 'Windows'
run: npm run build
- name: Build Electron app (macOS)
if: runner.os == 'macOS'
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
retry_on: any
retry_wait_seconds: 600
command: |
for var in APPLEID APPLEIDPASS APPLETEAMID CSC_LINK CSC_KEY_PASSWORD CSC_INSTALLER_LINK CSC_INSTALLER_KEY_PASSWORD; do
test -n "${!var}" || unset $var
done
npm run build:app -- -- -- \
dmg pkg \
--publish never \
--${{ matrix.arch }}
env:
APPLEID: ${{ secrets.APPLEID }}
APPLEIDPASS: ${{ secrets.APPLEIDPASS }}
APPLETEAMID: ${{ secrets.APPLETEAMID }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_INSTALLER_LINK: ${{ secrets.CSC_INSTALLER_LINK }}
CSC_INSTALLER_KEY_PASSWORD: ${{ secrets.CSC_INSTALLER_KEY_PASSWORD }}
- name: Notarize PKG (macOS)
if: runner.os == 'macOS'
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
retry_on: any
retry_wait_seconds: 600
command: |
if [[ -n $APPLEID && -n $APPLEIDPASS && -n $APPLETEAMID ]]; then
pkgname=$(ls -1 freelens/dist/Freelens*.pkg | head -n1)
auth="--apple-id $APPLEID --password $APPLEIDPASS --team-id $APPLETEAMID"
xcrun notarytool submit $pkgname $auth --wait 2>&1 | tee freelens/dist/notarytool.log
uuid=$(awk '/id: / { print $2; exit; }' freelens/dist/notarytool.log)
sleep 60
if [[ -n $uuid ]]; then
xcrun notarytool log $uuid $auth
xcrun stapler staple $pkgname
fi
fi
env:
APPLEID: ${{ secrets.APPLEID }}
APPLEIDPASS: ${{ secrets.APPLEIDPASS }}
APPLETEAMID: ${{ secrets.APPLETEAMID }}
- name: Build Electron app (Linux)
if: runner.os == 'Linux'
run: |
npm run build:app -- -- -- \
AppImage deb rpm \
--publish never \
--${{ matrix.arch }}
- name: Build Electron app (Windows x64)
if: runner.os == 'Windows' && matrix.arch == 'x64'
shell: bash
run: |
for var in CSC_LINK CSC_KEY_PASSWORD; do
test -n "${!var}" || unset $var
done
npm run build:app -- -- -- \
msi nsis \
--publish never \
--${{ matrix.arch }}
env:
CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
- name: Azure Trusted Signing (Windows x64)
if: runner.os == 'Windows' && matrix.arch == 'x64' && github.ref_name == 'main' && github.event_name != 'pull_request'
uses: azure/[email protected]
with:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
endpoint: ${{ vars.AZURE_ENDPOINT }}
trusted-signing-account-name: ${{ vars.AZURE_CODE_SIGNING_NAME }}
certificate-profile-name: ${{ vars.AZURE_CERT_PROFILE_NAME }}
files-folder: ${{ github.workspace }}\freelens\dist
files-folder-filter: exe,msi
- name: Tweak binaries
shell: bash
run: |
find . -name '*pty.node' -print0 | xargs -0 file
rm -f freelens/dist/*.blockmap
- name: Normalize filenames before upload
shell: bash
run: |
perl << 'END'
chdir "freelens/dist" or die $!;
my %arch = (x64 => "amd64", arm64 => "arm64");
my $arch = $arch{$ENV{ARCH}};
while (<Freelens*>) {
my $src = $_;
s/ Setup /-/;
s/[ _]/-/g;
if (/\.(dmg|exe|msi|pkg)$/ && !/-(amd64|arm64)\./) {
s/\.(dmg|exe|msi|pkg)$/-$arch.$1/;
}
s/[.-](aarch64|arm64)/-arm64/;
s/[.-](amd64|x86-64)/-amd64/;
s/-(amd64|arm64).(dmg|pkg)$/-macos-$1.$2/;
s/-(amd64|arm64).(AppImage|deb|flatpak|rpm|snap)$/-linux-$1.$2/;
s/-(amd64|arm64).(exe|msi|)$/-windows-$1.$2/;
my $dst = $_;
if ($src ne $dst) {
print "rename $src to $dst\n";
rename $src, $dst or die $!;
}
}
END
env:
ARCH: ${{ matrix.arch }}
- name: Make checksums for binaries (Linux, Windows)
if: runner.os == 'Linux' || runner.os == 'Windows'
shell: bash
run: |
for f in freelens/dist/Freelens*.*; do
sha256sum "$f" | tee "$f.sha256"
done
- name: Make checksums for binaries (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
for f in freelens/dist/Freelens*.*; do
shasum -a 256 "$f" | tee "$f.sha256"
done
- name: List files before upload
shell: bash
run: |
for f in freelens/dist/Freelens*.*; do
echo "$(ls -l "$f")" "|" "$(file -b "$f")"
done
- name: Upload files
shell: bash
run: |
gh release upload ${GITHUB_REF_NAME} freelens/dist/Freelens*.*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-github-release:
name: publish GitHub release
needs:
- make-draft-release
- build-app
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Publish GitHub release
run: gh release edit ${GITHUB_REF_NAME} --draft=false
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm-release:
name: publish NPM release
needs:
- make-draft-release
- build-app
- publish-github-release
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
arch: x64
runs-on: ${{ matrix.os }}
environment: publish
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
- name: Get NPM cache directory
shell: bash
run: echo "npm_cache_dir=$(npm config get cache)" >> ${GITHUB_ENV}
- name: Use NPM cache
uses: actions/cache@v4
with:
path: ${{ env.npm_cache_dir }}
key: ${{ matrix.os }}-${{ matrix.arch }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.arch }}-node-
- name: Install NPM dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
retry_on: any
command: npm ci
- name: Build
run: npm run build
- name: Reset Git working directory
run: git reset --hard
- name: Publish NPM packages
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
retry_on: any
command: |
case "${GITHUB_REF_NAME}" in
*-*) dist_tag=next;;
*) dist_tag=latest;;
esac
npx -y lerna lerna \
publish from-package \
--no-push \
--no-git-tag-version \
--yes \
--dist-tag ${dist_tag}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
release-apt-repository:
name: Release APT repository
needs:
- make-draft-release
- publish-github-release
runs-on: ubuntu-24.04
environment: apt-signing
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: GPG configuration
run: |
mkdir -p -m 0700 $HOME/.gnupg
echo "use-agent" > $HOME/.gnupg/gpg.conf
echo "pinentry-program $GITHUB_WORKSPACE/.github/scripts/pinentry.sh" > $HOME/.gnupg/gpg-agent.conf
echo "$GPG_PASSPHRASE" > $HOME/.gnupg/passphrase
gpgconf --launch gpg-agent
echo "$GPG_PRIVATE_KEY" | gpg --import
echo "$GPG_KEY_ID:6:" | gpg --import-ownertrust
env:
GPG_KEY_ID: ${{ vars.GPG_KEY_ID }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Release APT repository
run: |
set -x
gh release download ${GITHUB_REF_NAME} -p "*.deb" -D tmp
pushd tmp
apt-ftparchive packages . | tee Packages | xz > Packages.xz
apt-ftparchive release . > Release
gpg --clearsign -o InRelease Release
gpg --armor --detach-sign --sign -o Release.gpg Release
gh release upload ${GITHUB_REF_NAME} InRelease Packages Packages.xz Release Release.gpg --clobber
popd
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}