build-desktop-release.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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. - name: Update APP Version
  117. run: |
  118. sed -i 's/"version": "0.0.1"/"version": "${{ steps.ref.outputs.version }}"/g' ./package.json
  119. working-directory: ./static
  120. - name: Display Package.json
  121. run: cat ./package.json
  122. working-directory: ./static
  123. - name: Save VERSION file
  124. run: echo "${{ steps.ref.outputs.version }}" > ./VERSION
  125. working-directory: ./static
  126. - name: List Files
  127. run: ls -al
  128. working-directory: ./static
  129. - name: Upload Sentry Sourcemaps (beta only)
  130. if: ${{ github.repository == 'logseq/logseq' && github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }}
  131. run: |
  132. curl -sL https://sentry.io/get-cli/ | bash
  133. release_name="logseq@${{ steps.ref.outputs.version }}"
  134. sentry-cli releases new "${release_name}"
  135. sentry-cli releases files "${release_name}" upload-sourcemaps --ext map --ext js ./static/js --url-prefix '~/static/js'
  136. sentry-cli releases finalize "${release_name}"
  137. env:
  138. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  139. SENTRY_ORG: logseq
  140. SENTRY_PROJECT: logseq
  141. - name: Cache Static File
  142. uses: actions/upload-artifact@v2
  143. with:
  144. name: static
  145. path: static
  146. build-linux:
  147. runs-on: ubuntu-18.04
  148. needs: [ compile-cljs ]
  149. steps:
  150. - name: Download The Static Asset
  151. uses: actions/download-artifact@v2
  152. with:
  153. name: static
  154. path: static
  155. - name: Retrieve tag version
  156. id: ref
  157. run: |
  158. pkgver=$(cat ./static/VERSION)
  159. echo ::set-output name=version::$pkgver
  160. - name: Install Node.js, NPM and Yarn
  161. uses: actions/setup-node@v2
  162. with:
  163. node-version: ${{ env.NODE_VERSION }}
  164. # - name: Cache Node Modules
  165. # uses: actions/cache@v2
  166. # with:
  167. # path: |
  168. # **/node_modules
  169. # key: ${{ runner.os }}-node-modules
  170. - name: Build/Release Electron App
  171. run: yarn install && yarn electron:make
  172. working-directory: ./static
  173. - name: Save artifacts
  174. run: |
  175. mkdir -p builds
  176. # NOTE: save VERSION file to builds directory
  177. cp static/VERSION ./builds/VERSION
  178. mv static/out/make/*-*.AppImage ./builds/Logseq-linux-x64-${{ steps.ref.outputs.version }}.AppImage
  179. mv static/out/make/zip/linux/x64/*-linux-x64-*.zip ./builds/Logseq-linux-x64-${{ steps.ref.outputs.version }}.zip
  180. - name: Upload Artifact
  181. uses: actions/upload-artifact@v2
  182. with:
  183. name: logseq-linux-builds
  184. path: builds
  185. build-windows:
  186. runs-on: windows-latest
  187. needs: [ compile-cljs ]
  188. steps:
  189. - name: Download The Static Asset
  190. uses: actions/download-artifact@v2
  191. with:
  192. name: static
  193. path: static
  194. - name: Retrieve tag version
  195. id: ref
  196. run: |
  197. $env:PkgVer=$(cat ./static/VERSION)
  198. echo "::set-output name=version::$env:PkgVer"
  199. - name: Install Node.js, NPM and Yarn
  200. uses: actions/setup-node@v2
  201. with:
  202. node-version: ${{ env.NODE_VERSION }}
  203. # - name: Cache Node Modules
  204. # uses: actions/cache@v2
  205. # with:
  206. # path: |
  207. # **/node_modules
  208. # key: ${{ runner.os }}-node-modules
  209. - name: Deps Electron app
  210. run: yarn install
  211. working-directory: ./static
  212. - name: Fix Deps Electron app
  213. run: yarn run postinstall
  214. working-directory: ./static/node_modules/dugite/
  215. - name: Prepare Code Sign
  216. if: ${{ github.repository == 'logseq/logseq' }}
  217. run: |
  218. [IO.File]::WriteAllBytes($(Get-Location).Path + "\codesign.pfx", [Convert]::FromBase64String($env:CERTIFICATE))
  219. env:
  220. CERTIFICATE: ${{ secrets.CODE_SIGN_CERTIFICATE }}
  221. - name: Build/Release Electron app
  222. run: yarn electron:make
  223. working-directory: ./static
  224. env:
  225. CODE_SIGN_CERTIFICATE_FILE: ../codesign.pfx
  226. CODE_SIGN_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGN_CERTIFICATE_PASSWORD }}
  227. - name: Save Artifact
  228. run: |
  229. mkdir builds
  230. mv static\out\make\squirrel.windows\x64\*.exe builds\Logseq-win-x64-${{ steps.ref.outputs.version }}.exe
  231. mv static\out\make\squirrel.windows\x64\*.nupkg builds\Logseq-win-x64-${{ steps.ref.outputs.version }}-full.nupkg
  232. mv static\out\make\squirrel.windows\x64\RELEASES builds\RELEASES
  233. - name: Upload Artifact
  234. uses: actions/upload-artifact@v2
  235. with:
  236. name: logseq-win64-builds
  237. path: builds
  238. build-macos-x64:
  239. needs: [ compile-cljs ]
  240. runs-on: macos-11
  241. steps:
  242. - name: Download The Static Asset
  243. uses: actions/download-artifact@v2
  244. with:
  245. name: static
  246. path: static
  247. - name: Retrieve tag version
  248. id: ref
  249. run: |
  250. pkgver=$(cat ./static/VERSION)
  251. echo ::set-output name=version::$pkgver
  252. - name: List Static Files
  253. run: ls -al ./static
  254. - name: Install Node.js, NPM and Yarn
  255. uses: actions/setup-node@v2
  256. with:
  257. node-version: ${{ env.NODE_VERSION }}
  258. - name: Get yarn cache directory path
  259. id: yarn-cache-dir-path
  260. run: echo "::set-output name=dir::$(yarn cache dir)"
  261. - name: Cache yarn cache directory
  262. uses: actions/cache@v2
  263. id: yarn-cache
  264. with:
  265. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  266. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  267. restore-keys: |
  268. ${{ runner.os }}-yarn-
  269. - name: Signing By Apple Developer ID
  270. if: ${{ github.repository == 'logseq/logseq' }}
  271. uses: apple-actions/import-codesign-certs@v1
  272. with:
  273. p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
  274. p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}
  275. # - name: Cache Node Modules
  276. # uses: actions/cache@v2
  277. # with:
  278. # path: |
  279. # **/node_modules
  280. # key: ${{ runner.os }}-node-modules
  281. - name: Build/Release Electron App for x64
  282. run: yarn install && yarn electron:make
  283. working-directory: ./static
  284. env:
  285. APPLE_ID: ${{ secrets.APPLE_ID_EMAIL }}
  286. APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
  287. APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
  288. - name: Save x64 artifacts
  289. run: |
  290. mkdir -p builds
  291. mv static/out/make/Logseq.dmg ./builds/Logseq-darwin-x64-${{ steps.ref.outputs.version }}.dmg
  292. mv static/out/make/zip/darwin/x64/*.zip ./builds/Logseq-darwin-x64-${{ steps.ref.outputs.version }}.zip
  293. - name: Upload Artifact
  294. uses: actions/upload-artifact@v2
  295. with:
  296. name: logseq-darwin-x64-builds
  297. path: builds
  298. build-macos-arm64:
  299. needs: [ compile-cljs ]
  300. runs-on: macos-11
  301. steps:
  302. - name: Download The Static Asset
  303. uses: actions/download-artifact@v2
  304. with:
  305. name: static
  306. path: static
  307. - name: Retrieve tag version
  308. id: ref
  309. run: |
  310. pkgver=$(cat ./static/VERSION)
  311. echo ::set-output name=version::$pkgver
  312. - name: Install Node.js, NPM and Yarn
  313. uses: actions/setup-node@v2
  314. with:
  315. node-version: ${{ env.NODE_VERSION }}
  316. - name: Get yarn cache directory path
  317. id: yarn-cache-dir-path
  318. run: echo "::set-output name=dir::$(yarn cache dir)"
  319. - name: Cache yarn cache directory
  320. uses: actions/cache@v2
  321. id: yarn-cache
  322. with:
  323. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  324. key: ${{ runner.os }}-arm64-yarn-${{ hashFiles('**/yarn.lock') }}
  325. restore-keys: |
  326. ${{ runner.os }}-arm64-yarn-
  327. - name: Signing By Apple Developer ID
  328. if: ${{ github.repository == 'logseq/logseq' }}
  329. uses: apple-actions/import-codesign-certs@v1
  330. with:
  331. p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
  332. p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}
  333. # - name: Cache Node Modules
  334. # uses: actions/cache@v2
  335. # with:
  336. # path: |
  337. # **/node_modules
  338. # key: ${{ runner.os }}-node-modules
  339. - name: Fetch deps and fix dugit arch for arm64
  340. run: yarn install --ignore-platform && cd node_modules/dugite && npm_config_arch=arm64 node script/download-git.js
  341. working-directory: ./static
  342. - name: Build/Release Electron App for arm64
  343. run: yarn electron:make-macos-arm64
  344. working-directory: ./static
  345. env:
  346. APPLE_ID: ${{ secrets.APPLE_ID_EMAIL }}
  347. APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
  348. APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
  349. - name: Save arm64 artifacts
  350. run: |
  351. mkdir -p builds
  352. mv static/out/make/Logseq.dmg ./builds/Logseq-darwin-arm64-${{ steps.ref.outputs.version }}.dmg
  353. mv static/out/make/zip/darwin/arm64/*.zip ./builds/Logseq-darwin-arm64-${{ steps.ref.outputs.version }}.zip
  354. - name: Upload Artifact
  355. uses: actions/upload-artifact@v2
  356. with:
  357. name: logseq-darwin-arm64-builds
  358. path: builds
  359. # reuse workflow via workflow_call
  360. build-android:
  361. uses: ./.github/workflows/build-android.yml
  362. if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }}
  363. with:
  364. build-target: "${{ github.event.inputs.build-target }}"
  365. # if scheduled, use production mode
  366. enable-file-sync-production: "${{ github.event_name == 'schedule' || github.event.inputs.enable-file-sync-production == 'true' }}"
  367. secrets:
  368. ANDROID_KEYSTORE: "${{ secrets.ANDROID_KEYSTORE }}"
  369. ANDROID_KEYSTORE_PASSWORD: "${{ secrets.ANDROID_KEYSTORE_PASSWORD }}"
  370. SENTRY_AUTH_TOKEN: "${{ secrets.SENTRY_AUTH_TOKEN }}"
  371. nightly-release:
  372. if: ${{ github.event_name == 'schedule' || github.event.inputs.build-target == 'nightly' }}
  373. needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows, build-android ]
  374. runs-on: ubuntu-18.04
  375. steps:
  376. - name: Download MacOS x64 Artifacts
  377. uses: actions/download-artifact@v2
  378. with:
  379. name: logseq-darwin-x64-builds
  380. path: ./
  381. - name: Download MacOS arm64 Artifacts
  382. uses: actions/download-artifact@v2
  383. with:
  384. name: logseq-darwin-arm64-builds
  385. path: ./
  386. - name: Download The Linux Artifacts
  387. uses: actions/download-artifact@v2
  388. with:
  389. name: logseq-linux-builds
  390. path: ./
  391. - name: Download The Windows Artifact
  392. uses: actions/download-artifact@v2
  393. with:
  394. name: logseq-win64-builds
  395. path: ./
  396. - name: Download Android Artifacts
  397. uses: actions/download-artifact@v2
  398. with:
  399. name: logseq-android-builds
  400. path: ./
  401. - name: Generate SHA256 checksums
  402. run: |
  403. sha256sum *-darwin-* > SHA256SUMS.txt
  404. sha256sum *-win-* >> SHA256SUMS.txt
  405. sha256sum *-linux-* >> SHA256SUMS.txt
  406. sha256sum *.apk >> SHA256SUMS.txt
  407. cat SHA256SUMS.txt
  408. - name: List files
  409. run: ls -rl
  410. - name: Update Nightly Release
  411. uses: andelf/nightly-release@main
  412. env:
  413. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  414. with:
  415. tag_name: nightly
  416. name: 'Desktop/Android APP Nightly Release $$'
  417. draft: false
  418. prerelease: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.is-pre-release) || (github.event_name == 'schedule')}}
  419. body: |
  420. This is a nightly release of the Logseq desktop app.
  421. It's unstable compared to the official releases, **use it with caution**!
  422. files: |
  423. ./SHA256SUMS.txt
  424. ./*.zip
  425. ./*.dmg
  426. ./*.exe
  427. ./*.AppImage
  428. ./*.apk
  429. release:
  430. # NOTE: For now, we only have beta channel to be released on Github
  431. if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }}
  432. needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows ]
  433. runs-on: ubuntu-latest
  434. steps:
  435. - name: Download MacOS x64 Artifacts
  436. uses: actions/download-artifact@v2
  437. with:
  438. name: logseq-darwin-x64-builds
  439. path: ./
  440. - name: Download MacOS arm64 Artifacts
  441. uses: actions/download-artifact@v2
  442. with:
  443. name: logseq-darwin-arm64-builds
  444. path: ./
  445. - name: Download The Linux Artifacts
  446. uses: actions/download-artifact@v2
  447. with:
  448. name: logseq-linux-builds
  449. path: ./
  450. - name: Download The Windows Artifact
  451. uses: actions/download-artifact@v2
  452. with:
  453. name: logseq-win64-builds
  454. path: ./
  455. - name: Download Android Artifacts
  456. uses: actions/download-artifact@v2
  457. if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }}
  458. with:
  459. name: logseq-android-builds
  460. path: ./
  461. - name: List files
  462. run: ls -rl
  463. - name: Retrieve tag version
  464. id: ref
  465. run: |
  466. pkgver=$(cat VERSION)
  467. echo ::set-output name=version::$pkgver
  468. - name: Fix .nupkg name in RELEASES file
  469. run: |
  470. sed -i "s/Logseq-.*.nupkg/Logseq-win-x64-${{ steps.ref.outputs.version }}-full.nupkg/g" RELEASES
  471. - name: Generate SHA256 checksums
  472. run: |
  473. sha256sum *-darwin-* > SHA256SUMS.txt
  474. sha256sum *-win-* >> SHA256SUMS.txt
  475. sha256sum *-linux-* >> SHA256SUMS.txt
  476. sha256sum *.apk >> SHA256SUMS.txt
  477. sha256sum RELEASES >> SHA256SUMS.txt
  478. cat SHA256SUMS.txt
  479. - name: Create Release Draft
  480. uses: softprops/action-gh-release@v1
  481. env:
  482. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  483. with:
  484. tag_name: ${{ steps.ref.outputs.version }}
  485. name: Desktop/Android APP ${{ steps.ref.outputs.version }} (Beta Testing)
  486. body: "TODO: Fill this changelog. Sorry for the inconvenience!"
  487. draft: ${{ github.event.inputs.is-draft }}
  488. prerelease: ${{ github.event.inputs.is-pre-release }}
  489. files: |
  490. ./VERSION
  491. ./SHA256SUMS.txt
  492. ./*.zip
  493. ./*.dmg
  494. ./*.exe
  495. ./*.nupkg
  496. ./RELEASES
  497. ./*.AppImage
  498. ./*.apk