build-desktop-release.yml 17 KB

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