build-desktop-release.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. # This is the main desktop application release workflow for both nightly and beta/stable releases.
  2. name: Build-Desktop-Release
  3. on:
  4. workflow_dispatch:
  5. inputs:
  6. build-target:
  7. description: 'Build Target (Release Type)'
  8. type: choice
  9. required: true
  10. options:
  11. - beta
  12. - nightly
  13. - non-release
  14. default: "non-release"
  15. git-ref:
  16. description: "Release Git Ref (Which branch or tag to build?)"
  17. required: true
  18. default: "master"
  19. is-draft:
  20. description: 'Draft Release? (Beta only, Nightly will always be a non-draft)'
  21. type: boolean
  22. required: true
  23. default: true
  24. is-pre-release:
  25. description: 'Pre Release? (labeled as "PreRelease")'
  26. type: boolean
  27. required: true
  28. default: true
  29. enable-file-sync-production:
  30. description: 'File sync production mode'
  31. type: boolean
  32. required: true
  33. default: true
  34. enable-plugins:
  35. description: 'Build with plugin system support'
  36. type: boolean
  37. required: true
  38. default: true
  39. build-android:
  40. description: 'Build Android App'
  41. type: boolean
  42. required: true
  43. default: true
  44. schedule: # Every workday at the 2 P.M. (UTC) we run a scheduled nightly build
  45. - cron: '0 14 * * MON-FRI'
  46. env:
  47. CLOJURE_VERSION: '1.10.1.763'
  48. NODE_VERSION: '16'
  49. jobs:
  50. compile-cljs:
  51. runs-on: ubuntu-18.04
  52. steps:
  53. - name: Check build options
  54. if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.build-target == 'nightly' || github.event.inputs.build-target == 'beta') && github.event.inputs.git-ref != 'master' }}
  55. run: |
  56. echo "::error title=CheckFail::Nightly and Beta Release MUST be built from master"
  57. exit 1
  58. - name: Check out Git repository
  59. uses: actions/checkout@v2
  60. with:
  61. ref: ${{ github.event.inputs.git-ref }}
  62. - name: Install Node.js, NPM and Yarn
  63. uses: actions/setup-node@v2
  64. with:
  65. node-version: ${{ env.NODE_VERSION }}
  66. - name: Get yarn cache directory path
  67. id: yarn-cache-dir-path
  68. run: echo "::set-output name=dir::$(yarn cache dir)"
  69. - name: Cache yarn cache directory
  70. uses: actions/cache@v2
  71. id: yarn-cache
  72. with:
  73. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  74. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  75. restore-keys: |
  76. ${{ runner.os }}-yarn-
  77. - name: Setup Java JDK
  78. uses: actions/[email protected]
  79. with:
  80. java-version: 1.8
  81. - name: Cache clojure deps
  82. uses: actions/cache@v2
  83. with:
  84. path: |
  85. ~/.m2/repository
  86. ~/.gitlibs
  87. key: ${{ runner.os }}-clojure-lib-${{ hashFiles('**/deps.edn') }}
  88. - name: Setup clojure
  89. uses: DeLaGuardo/[email protected]
  90. with:
  91. cli: ${{ env.CLOJURE_VERSION }}
  92. - name: Retrieve tag version
  93. id: ref
  94. run: |
  95. pkgver=$(node ./scripts/get-pkg-version.js "${{ github.event.inputs.build-target }}")
  96. echo ::set-output name=version::$pkgver
  97. - name: Do Not Overwrite Existing Release
  98. if: ${{ github.event.inputs.build-target == 'beta' }}
  99. run: |
  100. if curl -f "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.ref.outputs.version }}" &>/dev/null; then
  101. echo "::error title=CheckFail::Release already exists"
  102. exit 1
  103. fi
  104. - name: Update Nightly APP Version
  105. if: ${{ github.event.inputs.build-target == 'nightly' || github.event_name == 'schedule' }}
  106. run: |
  107. sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs
  108. - name: Set Build Environment Variables (only when workflow_dispath)
  109. if: ${{ github.event_name == 'workflow_dispatch' }}
  110. # if scheduled, use default settings
  111. run: |
  112. echo "ENABLE_PLUGINS=${{ github.event_name == 'schedule' || github.event.inputs.enable-plugins == 'true' }}" >> $GITHUB_ENV
  113. echo "ENABLE_FILE_SYNC_PRODUCTION=${{ github.event_name == 'schedule' || github.event.inputs.enable-file-sync-production == 'true' }}" >> $GITHUB_ENV
  114. - name: Compile CLJS
  115. run: yarn install && gulp build && yarn cljs:release-electron
  116. env:
  117. LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
  118. LOGSEQ_POSTHOG_TOKEN: ${{ secrets.LOGSEQ_POSTHOG_TOKEN }}
  119. - name: Update APP Version
  120. run: |
  121. sed -i 's/"version": "0.0.1"/"version": "${{ steps.ref.outputs.version }}"/g' ./package.json
  122. working-directory: ./static
  123. - name: Display Package.json
  124. run: cat ./package.json
  125. working-directory: ./static
  126. - name: Save VERSION file
  127. run: echo "${{ steps.ref.outputs.version }}" > ./VERSION
  128. working-directory: ./static
  129. - name: List Files
  130. run: ls -al
  131. working-directory: ./static
  132. - name: Upload Sentry Sourcemaps (beta only)
  133. if: ${{ github.repository == 'logseq/logseq' && github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }}
  134. run: |
  135. curl -sL https://sentry.io/get-cli/ | bash
  136. release_name="logseq@${{ steps.ref.outputs.version }}"
  137. sentry-cli releases new "${release_name}"
  138. sentry-cli releases files "${release_name}" upload-sourcemaps --ext map --ext js ./static/js --url-prefix '~/static/js'
  139. sentry-cli releases finalize "${release_name}"
  140. env:
  141. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  142. SENTRY_ORG: logseq
  143. SENTRY_PROJECT: logseq
  144. - name: Cache Static File
  145. uses: actions/upload-artifact@v2
  146. with:
  147. name: static
  148. path: static
  149. build-linux:
  150. runs-on: ubuntu-18.04
  151. needs: [ compile-cljs ]
  152. steps:
  153. - name: Download The Static Asset
  154. uses: actions/download-artifact@v2
  155. with:
  156. name: static
  157. path: static
  158. - name: Retrieve tag version
  159. id: ref
  160. run: |
  161. pkgver=$(cat ./static/VERSION)
  162. echo ::set-output name=version::$pkgver
  163. - name: Install Node.js, NPM and Yarn
  164. uses: actions/setup-node@v2
  165. with:
  166. node-version: ${{ env.NODE_VERSION }}
  167. # - name: Cache Node Modules
  168. # uses: actions/cache@v2
  169. # with:
  170. # path: |
  171. # **/node_modules
  172. # key: ${{ runner.os }}-node-modules
  173. - name: Build/Release Electron App
  174. run: yarn install && yarn electron:make
  175. working-directory: ./static
  176. - name: Save artifacts
  177. run: |
  178. mkdir -p builds
  179. # NOTE: save VERSION file to builds directory
  180. cp static/VERSION ./builds/VERSION
  181. mv static/out/make/*-*.AppImage ./builds/Logseq-linux-x64-${{ steps.ref.outputs.version }}.AppImage
  182. mv static/out/make/zip/linux/x64/*-linux-x64-*.zip ./builds/Logseq-linux-x64-${{ steps.ref.outputs.version }}.zip
  183. - name: Upload Artifact
  184. uses: actions/upload-artifact@v2
  185. with:
  186. name: logseq-linux-builds
  187. path: builds
  188. build-windows:
  189. runs-on: windows-latest
  190. needs: [ compile-cljs ]
  191. steps:
  192. - name: Download The Static Asset
  193. uses: actions/download-artifact@v2
  194. with:
  195. name: static
  196. path: static
  197. - name: Retrieve tag version
  198. id: ref
  199. run: |
  200. $env:PkgVer=$(cat ./static/VERSION)
  201. echo "::set-output name=version::$env:PkgVer"
  202. - name: Install Node.js, NPM and Yarn
  203. uses: actions/setup-node@v2
  204. with:
  205. node-version: ${{ env.NODE_VERSION }}
  206. # - name: Cache Node Modules
  207. # uses: actions/cache@v2
  208. # with:
  209. # path: |
  210. # **/node_modules
  211. # key: ${{ runner.os }}-node-modules
  212. - name: Deps Electron app
  213. run: yarn install
  214. working-directory: ./static
  215. - name: Fix Deps Electron app
  216. run: yarn run postinstall
  217. working-directory: ./static/node_modules/dugite/
  218. - name: Prepare Code Sign
  219. if: ${{ github.repository == 'logseq/logseq' }}
  220. run: |
  221. [IO.File]::WriteAllBytes($(Get-Location).Path + "\codesign.pfx", [Convert]::FromBase64String($env:CERTIFICATE))
  222. env:
  223. CERTIFICATE: ${{ secrets.CODE_SIGN_CERTIFICATE }}
  224. - name: Build/Release Electron app
  225. run: yarn electron:make
  226. working-directory: ./static
  227. env:
  228. CODE_SIGN_CERTIFICATE_FILE: ../codesign.pfx
  229. CODE_SIGN_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_CERTIFICATE_PASSWORD }}
  230. - name: Save Artifact
  231. run: |
  232. mkdir builds
  233. mv static\out\make\squirrel.windows\x64\*.exe builds\Logseq-win-x64-${{ steps.ref.outputs.version }}.exe
  234. mv static\out\make\squirrel.windows\x64\*.nupkg builds\Logseq-win-x64-${{ steps.ref.outputs.version }}-full.nupkg
  235. mv static\out\make\squirrel.windows\x64\RELEASES builds\RELEASES
  236. - name: Upload Artifact
  237. uses: actions/upload-artifact@v2
  238. with:
  239. name: logseq-win64-builds
  240. path: builds
  241. build-macos-x64:
  242. needs: [ compile-cljs ]
  243. runs-on: macos-11
  244. steps:
  245. - name: Download The Static Asset
  246. uses: actions/download-artifact@v2
  247. with:
  248. name: static
  249. path: static
  250. - name: Retrieve tag version
  251. id: ref
  252. run: |
  253. pkgver=$(cat ./static/VERSION)
  254. echo ::set-output name=version::$pkgver
  255. - name: List Static Files
  256. run: ls -al ./static
  257. - name: Install Node.js, NPM and Yarn
  258. uses: actions/setup-node@v2
  259. with:
  260. node-version: ${{ env.NODE_VERSION }}
  261. - name: Get yarn cache directory path
  262. id: yarn-cache-dir-path
  263. run: echo "::set-output name=dir::$(yarn cache dir)"
  264. - name: Cache yarn cache directory
  265. uses: actions/cache@v2
  266. id: yarn-cache
  267. with:
  268. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  269. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  270. restore-keys: |
  271. ${{ runner.os }}-yarn-
  272. - name: Signing By Apple Developer ID
  273. if: ${{ github.repository == 'logseq/logseq' }}
  274. uses: apple-actions/import-codesign-certs@v1
  275. with:
  276. p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
  277. p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}
  278. # - name: Cache Node Modules
  279. # uses: actions/cache@v2
  280. # with:
  281. # path: |
  282. # **/node_modules
  283. # key: ${{ runner.os }}-node-modules
  284. - name: Build/Release Electron App for x64
  285. run: yarn install && yarn electron:make
  286. working-directory: ./static
  287. env:
  288. APPLE_ID: ${{ secrets.APPLE_ID_EMAIL }}
  289. APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
  290. APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
  291. - name: Save x64 artifacts
  292. run: |
  293. mkdir -p builds
  294. mv static/out/make/Logseq.dmg ./builds/Logseq-darwin-x64-${{ steps.ref.outputs.version }}.dmg
  295. mv static/out/make/zip/darwin/x64/*.zip ./builds/Logseq-darwin-x64-${{ steps.ref.outputs.version }}.zip
  296. - name: Upload Artifact
  297. uses: actions/upload-artifact@v2
  298. with:
  299. name: logseq-darwin-x64-builds
  300. path: builds
  301. build-macos-arm64:
  302. needs: [ compile-cljs ]
  303. runs-on: macos-11
  304. steps:
  305. - name: Download The Static Asset
  306. uses: actions/download-artifact@v2
  307. with:
  308. name: static
  309. path: static
  310. - name: Retrieve tag version
  311. id: ref
  312. run: |
  313. pkgver=$(cat ./static/VERSION)
  314. echo ::set-output name=version::$pkgver
  315. - name: Install Node.js, NPM and Yarn
  316. uses: actions/setup-node@v2
  317. with:
  318. node-version: ${{ env.NODE_VERSION }}
  319. - name: Get yarn cache directory path
  320. id: yarn-cache-dir-path
  321. run: echo "::set-output name=dir::$(yarn cache dir)"
  322. - name: Cache yarn cache directory
  323. uses: actions/cache@v2
  324. id: yarn-cache
  325. with:
  326. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  327. key: ${{ runner.os }}-arm64-yarn-${{ hashFiles('**/yarn.lock') }}
  328. restore-keys: |
  329. ${{ runner.os }}-arm64-yarn-
  330. - name: Signing By Apple Developer ID
  331. if: ${{ github.repository == 'logseq/logseq' }}
  332. uses: apple-actions/import-codesign-certs@v1
  333. with:
  334. p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
  335. p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}
  336. # - name: Cache Node Modules
  337. # uses: actions/cache@v2
  338. # with:
  339. # path: |
  340. # **/node_modules
  341. # key: ${{ runner.os }}-node-modules
  342. - name: Fetch deps and fix dugit arch for arm64
  343. run: yarn install --ignore-platform && cd node_modules/dugite && npm_config_arch=arm64 node script/download-git.js
  344. working-directory: ./static
  345. - name: Build/Release Electron App for arm64
  346. run: yarn electron:make-macos-arm64
  347. working-directory: ./static
  348. env:
  349. APPLE_ID: ${{ secrets.APPLE_ID_EMAIL }}
  350. APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
  351. APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
  352. - name: Save arm64 artifacts
  353. run: |
  354. mkdir -p builds
  355. mv static/out/make/Logseq.dmg ./builds/Logseq-darwin-arm64-${{ steps.ref.outputs.version }}.dmg
  356. mv static/out/make/zip/darwin/arm64/*.zip ./builds/Logseq-darwin-arm64-${{ steps.ref.outputs.version }}.zip
  357. - name: Upload Artifact
  358. uses: actions/upload-artifact@v2
  359. with:
  360. name: logseq-darwin-arm64-builds
  361. path: builds
  362. # reuse workflow via workflow_call
  363. build-android:
  364. uses: ./.github/workflows/build-android.yml
  365. if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }}
  366. with:
  367. build-target: "${{ github.event.inputs.build-target }}"
  368. # if scheduled, use production mode
  369. enable-file-sync-production: "${{ github.event_name == 'schedule' || github.event.inputs.enable-file-sync-production == 'true' }}"
  370. secrets:
  371. ANDROID_KEYSTORE: "${{ secrets.ANDROID_KEYSTORE }}"
  372. ANDROID_KEYSTORE_PASSWORD: "${{ secrets.ANDROID_KEYSTORE_PASSWORD }}"
  373. SENTRY_AUTH_TOKEN: "${{ secrets.SENTRY_AUTH_TOKEN }}"
  374. nightly-release:
  375. if: ${{ github.event_name == 'schedule' || github.event.inputs.build-target == 'nightly' }}
  376. needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows, build-android ]
  377. runs-on: ubuntu-18.04
  378. steps:
  379. - name: Download MacOS x64 Artifacts
  380. uses: actions/download-artifact@v2
  381. with:
  382. name: logseq-darwin-x64-builds
  383. path: ./
  384. - name: Download MacOS arm64 Artifacts
  385. uses: actions/download-artifact@v2
  386. with:
  387. name: logseq-darwin-arm64-builds
  388. path: ./
  389. - name: Download The Linux Artifacts
  390. uses: actions/download-artifact@v2
  391. with:
  392. name: logseq-linux-builds
  393. path: ./
  394. - name: Download The Windows Artifact
  395. uses: actions/download-artifact@v2
  396. with:
  397. name: logseq-win64-builds
  398. path: ./
  399. - name: Download Android Artifacts
  400. uses: actions/download-artifact@v2
  401. with:
  402. name: logseq-android-builds
  403. path: ./
  404. - name: Generate SHA256 checksums
  405. run: |
  406. sha256sum *-darwin-* > SHA256SUMS.txt
  407. sha256sum *-win-* >> SHA256SUMS.txt
  408. sha256sum *-linux-* >> SHA256SUMS.txt
  409. sha256sum *.apk >> SHA256SUMS.txt
  410. cat SHA256SUMS.txt
  411. - name: List files
  412. run: ls -rl
  413. - name: Update Nightly Release
  414. uses: andelf/nightly-release@main
  415. env:
  416. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  417. with:
  418. tag_name: nightly
  419. name: 'Desktop/Android APP Nightly Release $$'
  420. draft: false
  421. prerelease: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.is-pre-release) || (github.event_name == 'schedule')}}
  422. body: |
  423. This is a nightly release of the Logseq desktop app.
  424. It's unstable compared to the official releases, **use it with caution**!
  425. files: |
  426. ./SHA256SUMS.txt
  427. ./*.zip
  428. ./*.dmg
  429. ./*.exe
  430. ./*.AppImage
  431. ./*.apk
  432. release:
  433. # NOTE: For now, we only have beta channel to be released on Github
  434. if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }}
  435. needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows ]
  436. runs-on: ubuntu-latest
  437. steps:
  438. - name: Download MacOS x64 Artifacts
  439. uses: actions/download-artifact@v2
  440. with:
  441. name: logseq-darwin-x64-builds
  442. path: ./
  443. - name: Download MacOS arm64 Artifacts
  444. uses: actions/download-artifact@v2
  445. with:
  446. name: logseq-darwin-arm64-builds
  447. path: ./
  448. - name: Download The Linux Artifacts
  449. uses: actions/download-artifact@v2
  450. with:
  451. name: logseq-linux-builds
  452. path: ./
  453. - name: Download The Windows Artifact
  454. uses: actions/download-artifact@v2
  455. with:
  456. name: logseq-win64-builds
  457. path: ./
  458. - name: Download Android Artifacts
  459. uses: actions/download-artifact@v2
  460. if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }}
  461. with:
  462. name: logseq-android-builds
  463. path: ./
  464. - name: List files
  465. run: ls -rl
  466. - name: Retrieve tag version
  467. id: ref
  468. run: |
  469. pkgver=$(cat VERSION)
  470. echo ::set-output name=version::$pkgver
  471. - name: Fix .nupkg name in RELEASES file
  472. run: |
  473. sed -i "s/Logseq-.*.nupkg/Logseq-win-x64-${{ steps.ref.outputs.version }}-full.nupkg/g" RELEASES
  474. - name: Generate SHA256 checksums
  475. run: |
  476. sha256sum *-darwin-* > SHA256SUMS.txt
  477. sha256sum *-win-* >> SHA256SUMS.txt
  478. sha256sum *-linux-* >> SHA256SUMS.txt
  479. sha256sum *.apk >> SHA256SUMS.txt
  480. sha256sum RELEASES >> SHA256SUMS.txt
  481. cat SHA256SUMS.txt
  482. - name: Create Release Draft
  483. uses: softprops/action-gh-release@v1
  484. env:
  485. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  486. with:
  487. tag_name: ${{ steps.ref.outputs.version }}
  488. name: Desktop/Android APP ${{ steps.ref.outputs.version }} (Beta Testing)
  489. body: "TODO: Fill this changelog. Sorry for the inconvenience!"
  490. draft: ${{ github.event.inputs.is-draft }}
  491. prerelease: ${{ github.event.inputs.is-pre-release }}
  492. files: |
  493. ./VERSION
  494. ./SHA256SUMS.txt
  495. ./*.zip
  496. ./*.dmg
  497. ./*.exe
  498. ./*.nupkg
  499. ./RELEASES
  500. ./*.AppImage
  501. ./*.apk