build-android.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. # This is the main Android apk build workflow for both nightly and beta releases.
  2. # This is also configured to run as a workflow_call.
  3. name: Build-Android
  4. on:
  5. workflow_dispatch:
  6. inputs:
  7. build-target:
  8. description: 'Build Target (Release Type)'
  9. type: choice
  10. required: true
  11. options:
  12. - beta
  13. - nightly
  14. - non-release
  15. default: "non-release"
  16. git-ref:
  17. description: "Build from Git Ref(master)"
  18. required: true
  19. default: "master"
  20. enable-file-sync-production:
  21. description: 'File sync production mode'
  22. type: boolean
  23. required: true
  24. default: true
  25. workflow_call:
  26. inputs:
  27. build-target:
  28. type: string
  29. required: true
  30. enable-file-sync-production:
  31. description: 'File sync production mode'
  32. type: boolean
  33. secrets:
  34. ANDROID_KEYSTORE:
  35. required: true
  36. ANDROID_KEYSTORE_PASSWORD:
  37. required: true
  38. SENTRY_AUTH_TOKEN:
  39. required: true
  40. env:
  41. CLOJURE_VERSION: '1.11.1.1413'
  42. NODE_VERSION: '20'
  43. JAVA_VERSION: '17'
  44. jobs:
  45. build-apk:
  46. runs-on: ubuntu-latest
  47. steps:
  48. - name: Check out Git repository
  49. uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  50. with:
  51. ref: ${{ github.event.inputs.git-ref }}
  52. - name: Install Node.js, NPM and Yarn
  53. uses: actions/setup-node@v3
  54. with:
  55. node-version: ${{ env.NODE_VERSION }}
  56. - name: Get yarn cache directory path
  57. id: yarn-cache-dir-path
  58. run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
  59. - name: Cache yarn cache directory
  60. uses: actions/cache@v3
  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/setup-java@v3
  69. with:
  70. distribution: 'zulu'
  71. java-version: ${{ env.JAVA_VERSION }}
  72. - name: Cache clojure deps
  73. uses: actions/cache@v3
  74. with:
  75. path: |
  76. ~/.m2/repository
  77. ~/.gitlibs
  78. key: ${{ runner.os }}-clojure-lib-${{ hashFiles('**/deps.edn') }}
  79. - name: Setup clojure
  80. uses: DeLaGuardo/[email protected]
  81. with:
  82. cli: ${{ env.CLOJURE_VERSION }}
  83. - name: Retrieve tag version
  84. id: ref
  85. run: |
  86. pkgver=$(node ./scripts/get-pkg-version.js "${{ inputs.build-target || github.event.inputs.build-target }}")
  87. echo "version=$pkgver" >> $GITHUB_OUTPUT
  88. - name: Update Nightly APP Version
  89. if: ${{ inputs.build-target == '' || inputs.build-target == 'nightly' || github.event.inputs.build-target == 'nightly' }}
  90. run: |
  91. sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs
  92. sed -i 's/versionName ".*"/versionName "${{ steps.ref.outputs.version }}"/g' android/app/build.gradle
  93. - name: Set Build Environment Variables
  94. run: |
  95. echo "ENABLE_FILE_SYNC_PRODUCTION=${{ inputs.enable-file-sync-production || github.event.inputs.enable-file-sync-production || inputs.build-target == '' }}" >> $GITHUB_ENV
  96. - name: Compile CLJS - app variant, use es6 instead of es-next
  97. run: yarn install && yarn release-app
  98. env:
  99. LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
  100. LOGSEQ_POSTHOG_TOKEN: ${{ secrets.LOGSEQ_POSTHOG_TOKEN }}
  101. - name: Upload Sentry Sourcemaps (beta only)
  102. if: ${{ github.repository == 'logseq/logseq' && (inputs.build-target == 'beta' || github.event.inputs.build-target == 'beta') }}
  103. run: |
  104. curl -sL https://sentry.io/get-cli/ | bash
  105. release_name="logseq-android@${{ steps.ref.outputs.version }}"
  106. sentry-cli releases new "${release_name}"
  107. sentry-cli releases files "${release_name}" upload-sourcemaps --ext map --ext js ./static/js --url-prefix '~/static/js'
  108. sentry-cli releases finalize "${release_name}"
  109. env:
  110. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  111. SENTRY_ORG: logseq
  112. SENTRY_PROJECT: logseq
  113. - name: Prepare public Directory
  114. run: |
  115. cp -r static public/
  116. rm -rvf public/static/js/publishing
  117. rm -rvf public/static/js/*.js.map || true
  118. rm -rvf public/static/*.*
  119. rm -rvf public/static/ios
  120. rm -rvf android/app/src/main/assets/public || true
  121. - name: Sync public to Android Project
  122. run: npx cap sync android
  123. - name: Setup Android SDK
  124. uses: android-actions/setup-android@v2
  125. - name: Build Android
  126. run: |
  127. ./gradlew clean
  128. ./gradlew zipApksForRelease
  129. working-directory: android
  130. env:
  131. LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
  132. - name: Sign Android APK
  133. run: |
  134. echo ${{ secrets.ANDROID_KEYSTORE }} | base64 -d > keystore.jks
  135. /usr/local/lib/android/sdk/build-tools/33.0.0/apksigner sign \
  136. --ks keystore.jks --ks-pass "pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" \
  137. --in app/build/outputs/apk/release/app-release-unsigned.apk \
  138. --out app-signed.apk
  139. working-directory: android
  140. - name: Rename Apk
  141. run: |
  142. mkdir builds
  143. mv android/app-signed.apk ./builds/Logseq-android-${{ steps.ref.outputs.version }}.apk
  144. - name: Upload Artifact
  145. uses: actions/upload-artifact@v4
  146. with:
  147. name: logseq-android-builds
  148. path: builds