forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
583 lines (502 loc) · 19.2 KB
/
build-desktop-release.yml
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
576
577
578
579
580
581
582
583
# This is the main desktop application release workflow for both nightly and beta/stable releases.
name: Build-Desktop-Release
on:
workflow_dispatch:
inputs:
build-target:
description: 'Build Target (Release Type)'
type: choice
required: true
options:
- beta
- nightly
- non-release
default: "non-release"
git-ref:
description: "Release Git Ref (Which branch or tag to build?)"
required: true
default: "master"
is-draft:
description: 'Draft Release? (Beta only, Nightly will always be a non-draft)'
type: boolean
required: true
default: true
is-pre-release:
description: 'Pre Release? (labeled as "PreRelease")'
type: boolean
required: true
default: true
enable-file-sync-production:
description: 'File sync production mode'
type: boolean
required: true
default: true
enable-plugins:
description: 'Build with plugin system support'
type: boolean
required: true
default: true
build-android:
description: 'Build Android App'
type: boolean
required: true
default: true
schedule: # Every workday at the 2 P.M. (UTC) we run a scheduled nightly build
- cron: '0 14 * * MON-FRI'
env:
CLOJURE_VERSION: '1.10.1.763'
NODE_VERSION: '16'
jobs:
compile-cljs:
runs-on: ubuntu-18.04
steps:
- name: Check build options
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.build-target == 'nightly' || github.event.inputs.build-target == 'beta') && github.event.inputs.git-ref != 'master' }}
run: |
echo "::error title=CheckFail::Nightly and Beta Release MUST be built from master"
exit 1
- name: Check out Git repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn cache directory
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: 1.8
- name: Cache clojure deps
uses: actions/cache@v2
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-clojure-lib-${{ hashFiles('**/deps.edn') }}
- name: Setup clojure
uses: DeLaGuardo/[email protected]
with:
cli: ${{ env.CLOJURE_VERSION }}
- name: Retrieve tag version
id: ref
run: |
pkgver=$(node ./scripts/get-pkg-version.js "${{ github.event.inputs.build-target }}")
echo ::set-output name=version::$pkgver
- name: Do Not Overwrite Existing Release
if: ${{ github.event.inputs.build-target == 'beta' }}
run: |
if curl -f "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.ref.outputs.version }}" &>/dev/null; then
echo "::error title=CheckFail::Release already exists"
exit 1
fi
- name: Update Nightly APP Version
if: ${{ github.event.inputs.build-target == 'nightly' || github.event_name == 'schedule' }}
run: |
sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs
- name: Set Build Environment Variables (only when workflow_dispath)
if: ${{ github.event_name == 'workflow_dispatch' }}
# if scheduled, use default settings
run: |
echo "ENABLE_PLUGINS=${{ github.event_name == 'schedule' || github.event.inputs.enable-plugins == 'true' }}" >> $GITHUB_ENV
echo "ENABLE_FILE_SYNC_PRODUCTION=${{ github.event_name == 'schedule' || github.event.inputs.enable-file-sync-production == 'true' }}" >> $GITHUB_ENV
- name: Compile CLJS
run: yarn install && gulp build && yarn cljs:release-electron
env:
LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
LOGSEQ_POSTHOG_TOKEN: ${{ secrets.LOGSEQ_POSTHOG_TOKEN }}
- name: Update APP Version
run: |
sed -i 's/"version": "0.0.1"/"version": "${{ steps.ref.outputs.version }}"/g' ./package.json
working-directory: ./static
- name: Display Package.json
run: cat ./package.json
working-directory: ./static
- name: Save VERSION file
run: echo "${{ steps.ref.outputs.version }}" > ./VERSION
working-directory: ./static
- name: List Files
run: ls -al
working-directory: ./static
- name: Upload Sentry Sourcemaps (beta only)
if: ${{ github.repository == 'logseq/logseq' && github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }}
run: |
curl -sL https://sentry.io/get-cli/ | bash
release_name="logseq@${{ steps.ref.outputs.version }}"
sentry-cli releases new "${release_name}"
sentry-cli releases files "${release_name}" upload-sourcemaps --ext map --ext js ./static/js --url-prefix '~/static/js'
sentry-cli releases finalize "${release_name}"
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: logseq
SENTRY_PROJECT: logseq
- name: Cache Static File
uses: actions/upload-artifact@v2
with:
name: static
path: static
build-linux:
runs-on: ubuntu-18.04
needs: [ compile-cljs ]
steps:
- name: Download The Static Asset
uses: actions/download-artifact@v2
with:
name: static
path: static
- name: Retrieve tag version
id: ref
run: |
pkgver=$(cat ./static/VERSION)
echo ::set-output name=version::$pkgver
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules
- name: Build/Release Electron App
run: yarn install && yarn electron:make
working-directory: ./static
- name: Save artifacts
run: |
mkdir -p builds
# NOTE: save VERSION file to builds directory
cp static/VERSION ./builds/VERSION
mv static/out/make/*-*.AppImage ./builds/Logseq-linux-x64-${{ steps.ref.outputs.version }}.AppImage
mv static/out/make/zip/linux/x64/*-linux-x64-*.zip ./builds/Logseq-linux-x64-${{ steps.ref.outputs.version }}.zip
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: logseq-linux-builds
path: builds
build-windows:
runs-on: windows-latest
needs: [ compile-cljs ]
steps:
- name: Download The Static Asset
uses: actions/download-artifact@v2
with:
name: static
path: static
- name: Retrieve tag version
id: ref
run: |
$env:PkgVer=$(cat ./static/VERSION)
echo "::set-output name=version::$env:PkgVer"
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules
- name: Deps Electron app
run: yarn install
working-directory: ./static
- name: Fix Deps Electron app
run: yarn run postinstall
working-directory: ./static/node_modules/dugite/
- name: Prepare Code Sign
if: ${{ github.repository == 'logseq/logseq' }}
run: |
[IO.File]::WriteAllBytes($(Get-Location).Path + "\codesign.pfx", [Convert]::FromBase64String($env:CERTIFICATE))
env:
CERTIFICATE: ${{ secrets.CODE_SIGN_CERTIFICATE }}
- name: Build/Release Electron app
run: yarn electron:make
working-directory: ./static
env:
CODE_SIGN_CERTIFICATE_FILE: ../codesign.pfx
CODE_SIGN_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_CERTIFICATE_PASSWORD }}
- name: Save Artifact
run: |
mkdir builds
mv static\out\make\squirrel.windows\x64\*.exe builds\Logseq-win-x64-${{ steps.ref.outputs.version }}.exe
mv static\out\make\squirrel.windows\x64\*.nupkg builds\Logseq-win-x64-${{ steps.ref.outputs.version }}-full.nupkg
mv static\out\make\squirrel.windows\x64\RELEASES builds\RELEASES
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: logseq-win64-builds
path: builds
build-macos-x64:
needs: [ compile-cljs ]
runs-on: macos-11
steps:
- name: Download The Static Asset
uses: actions/download-artifact@v2
with:
name: static
path: static
- name: Retrieve tag version
id: ref
run: |
pkgver=$(cat ./static/VERSION)
echo ::set-output name=version::$pkgver
- name: List Static Files
run: ls -al ./static
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn cache directory
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Signing By Apple Developer ID
if: ${{ github.repository == 'logseq/logseq' }}
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules
- name: Build/Release Electron App for x64
run: yarn install && yarn electron:make
working-directory: ./static
env:
APPLE_ID: ${{ secrets.APPLE_ID_EMAIL }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
- name: Save x64 artifacts
run: |
mkdir -p builds
mv static/out/make/Logseq.dmg ./builds/Logseq-darwin-x64-${{ steps.ref.outputs.version }}.dmg
mv static/out/make/zip/darwin/x64/*.zip ./builds/Logseq-darwin-x64-${{ steps.ref.outputs.version }}.zip
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: logseq-darwin-x64-builds
path: builds
build-macos-arm64:
needs: [ compile-cljs ]
runs-on: macos-11
steps:
- name: Download The Static Asset
uses: actions/download-artifact@v2
with:
name: static
path: static
- name: Retrieve tag version
id: ref
run: |
pkgver=$(cat ./static/VERSION)
echo ::set-output name=version::$pkgver
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn cache directory
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-arm64-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-arm64-yarn-
- name: Signing By Apple Developer ID
if: ${{ github.repository == 'logseq/logseq' }}
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules
- name: Fetch deps and fix dugit arch for arm64
run: yarn install --ignore-platform && cd node_modules/dugite && npm_config_arch=arm64 node script/download-git.js
working-directory: ./static
- name: Build/Release Electron App for arm64
run: yarn electron:make-macos-arm64
working-directory: ./static
env:
APPLE_ID: ${{ secrets.APPLE_ID_EMAIL }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
- name: Save arm64 artifacts
run: |
mkdir -p builds
mv static/out/make/Logseq.dmg ./builds/Logseq-darwin-arm64-${{ steps.ref.outputs.version }}.dmg
mv static/out/make/zip/darwin/arm64/*.zip ./builds/Logseq-darwin-arm64-${{ steps.ref.outputs.version }}.zip
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: logseq-darwin-arm64-builds
path: builds
# reuse workflow via workflow_call
build-android:
uses: ./.github/workflows/build-android.yml
if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }}
with:
build-target: "${{ github.event.inputs.build-target }}"
# if scheduled, use production mode
enable-file-sync-production: "${{ github.event_name == 'schedule' || github.event.inputs.enable-file-sync-production == 'true' }}"
secrets:
ANDROID_KEYSTORE: "${{ secrets.ANDROID_KEYSTORE }}"
ANDROID_KEYSTORE_PASSWORD: "${{ secrets.ANDROID_KEYSTORE_PASSWORD }}"
SENTRY_AUTH_TOKEN: "${{ secrets.SENTRY_AUTH_TOKEN }}"
nightly-release:
if: ${{ github.event_name == 'schedule' || github.event.inputs.build-target == 'nightly' }}
needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows, build-android ]
runs-on: ubuntu-18.04
steps:
- name: Download MacOS x64 Artifacts
uses: actions/download-artifact@v2
with:
name: logseq-darwin-x64-builds
path: ./
- name: Download MacOS arm64 Artifacts
uses: actions/download-artifact@v2
with:
name: logseq-darwin-arm64-builds
path: ./
- name: Download The Linux Artifacts
uses: actions/download-artifact@v2
with:
name: logseq-linux-builds
path: ./
- name: Download The Windows Artifact
uses: actions/download-artifact@v2
with:
name: logseq-win64-builds
path: ./
- name: Download Android Artifacts
uses: actions/download-artifact@v2
with:
name: logseq-android-builds
path: ./
- name: Generate SHA256 checksums
run: |
sha256sum *-darwin-* > SHA256SUMS.txt
sha256sum *-win-* >> SHA256SUMS.txt
sha256sum *-linux-* >> SHA256SUMS.txt
sha256sum *.apk >> SHA256SUMS.txt
cat SHA256SUMS.txt
- name: List files
run: ls -rl
- name: Update Nightly Release
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
name: 'Desktop/Android APP Nightly Release $$'
draft: false
prerelease: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.is-pre-release) || (github.event_name == 'schedule')}}
body: |
This is a nightly release of the Logseq desktop app.
It's unstable compared to the official releases, **use it with caution**!
Known Issue: macOS build is not signed, so you need to allow it to run in System Preferences -> Security & Privacy -> General.
files: |
./SHA256SUMS.txt
./*.zip
./*.dmg
./*.exe
./*.AppImage
./*.apk
release:
# NOTE: For now, we only have beta channel to be released on Github
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }}
needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows ]
runs-on: ubuntu-latest
steps:
- name: Download MacOS x64 Artifacts
uses: actions/download-artifact@v2
with:
name: logseq-darwin-x64-builds
path: ./
- name: Download MacOS arm64 Artifacts
uses: actions/download-artifact@v2
with:
name: logseq-darwin-arm64-builds
path: ./
- name: Download The Linux Artifacts
uses: actions/download-artifact@v2
with:
name: logseq-linux-builds
path: ./
- name: Download The Windows Artifact
uses: actions/download-artifact@v2
with:
name: logseq-win64-builds
path: ./
- name: Download Android Artifacts
uses: actions/download-artifact@v2
if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }}
with:
name: logseq-android-builds
path: ./
- name: List files
run: ls -rl
- name: Retrieve tag version
id: ref
run: |
pkgver=$(cat VERSION)
echo ::set-output name=version::$pkgver
- name: Fix .nupkg name in RELEASES file
run: |
sed -i "s/Logseq-.*.nupkg/Logseq-win-x64-${{ steps.ref.outputs.version }}-full.nupkg/g" RELEASES
- name: Generate SHA256 checksums
run: |
sha256sum *-darwin-* > SHA256SUMS.txt
sha256sum *-win-* >> SHA256SUMS.txt
sha256sum *-linux-* >> SHA256SUMS.txt
sha256sum *.apk >> SHA256SUMS.txt
sha256sum RELEASES >> SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create Release Draft
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.ref.outputs.version }}
name: Desktop/Android APP ${{ steps.ref.outputs.version }} (Beta Testing)
body: "TODO: Fill this changelog. Sorry for the inconvenience!"
draft: ${{ github.event.inputs.is-draft }}
prerelease: ${{ github.event.inputs.is-pre-release }}
files: |
./VERSION
./SHA256SUMS.txt
./*.zip
./*.dmg
./*.exe
./*.nupkg
./RELEASES
./*.AppImage
./*.apk