build-desktop-release.yml 18 KB

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