build-android.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 ("nightly"/"beta"/"non-release")'
  9. type: string
  10. required: true
  11. default: "beta"
  12. git-ref:
  13. description: "Build from Git Ref(master)"
  14. required: true
  15. default: "master"
  16. workflow_call:
  17. inputs:
  18. build-target:
  19. type: string
  20. required: true
  21. secrets:
  22. ANDROID_KEYSTORE:
  23. required: true
  24. ANDROID_KEYSTORE_PASSWORD:
  25. required: true
  26. SENTRY_AUTH_TOKEN:
  27. required: true
  28. env:
  29. CLOJURE_VERSION: '1.10.1.763'
  30. NODE_VERSION: '16'
  31. jobs:
  32. build-apk:
  33. runs-on: ubuntu-latest
  34. steps:
  35. - name: Check out Git repository
  36. uses: actions/checkout@v2
  37. with:
  38. ref: ${{ github.event.inputs.git-ref }}
  39. - name: Install Node.js, NPM and Yarn
  40. uses: actions/setup-node@v2
  41. with:
  42. node-version: ${{ env.NODE_VERSION }}
  43. - name: Get yarn cache directory path
  44. id: yarn-cache-dir-path
  45. run: echo "::set-output name=dir::$(yarn cache dir)"
  46. - name: Cache yarn cache directory
  47. uses: actions/cache@v2
  48. id: yarn-cache
  49. with:
  50. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  51. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  52. restore-keys: |
  53. ${{ runner.os }}-yarn-
  54. - name: Setup Java JDK
  55. uses: actions/[email protected]
  56. with:
  57. java-version: 1.8
  58. - name: Cache clojure deps
  59. uses: actions/cache@v2
  60. with:
  61. path: |
  62. ~/.m2/repository
  63. ~/.gitlibs
  64. key: ${{ runner.os }}-clojure-lib-${{ hashFiles('**/deps.edn') }}
  65. - name: Setup clojure
  66. uses: DeLaGuardo/[email protected]
  67. with:
  68. cli: ${{ env.CLOJURE_VERSION }}
  69. - name: Retrieve tag version
  70. id: ref
  71. run: |
  72. pkgver=$(node ./scripts/get-pkg-version.js "${{ inputs.build-target || github.event.inputs.build-target }}")
  73. echo ::set-output name=version::$pkgver
  74. - name: Update Nightly APP Version
  75. if: ${{ inputs.build-target == 'nightly' || github.event.inputs.build-target == 'nightly' }}
  76. run: |
  77. sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs
  78. sed -i 's/versionName ".*"/versionName "${{ steps.ref.outputs.version }}"/g' android/app/build.gradle
  79. - name: Compile CLJS - android variant, use es6 instead of es-next
  80. run: yarn install && yarn release-android-app
  81. - name: Upload Sentry Sourcemaps (beta only)
  82. if: ${{ inputs.build-target == 'beta' || github.event.inputs.build-target == 'beta' }}
  83. run: |
  84. curl -sL https://sentry.io/get-cli/ | bash
  85. release_name="logseq-android@${{ steps.ref.outputs.version }}"
  86. sentry-cli releases new "${release_name}"
  87. sentry-cli releases files "${release_name}" upload-sourcemaps --ext map --ext js ./static/js --url-prefix '~/static/js'
  88. sentry-cli releases finalize "${release_name}"
  89. env:
  90. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  91. SENTRY_ORG: logseq
  92. SENTRY_PROJECT: logseq
  93. - name: Prepare public Directory
  94. run: |
  95. cp -r static public/
  96. rm -rvf public/static/js/publishing
  97. rm -rvf public/workspaces
  98. rm -rvf public/static/js/*.js.map || true
  99. rm -rvf public/static/*.*
  100. rm -rvf public/static/ios
  101. rm -rvf android/app/src/main/assets/public || true
  102. - name: Sync public to Android Project
  103. run: npx cap sync
  104. - name: Setup Android SDK
  105. uses: android-actions/setup-android@v2
  106. - name: Build Android
  107. run: |
  108. ./gradlew clean
  109. ./gradlew zipApksForRelease
  110. working-directory: android
  111. - name: Sign Android APK
  112. run: |
  113. echo ${{ secrets.ANDROID_KEYSTORE }} | base64 -d > keystore.jks
  114. /usr/local/lib/android/sdk/build-tools/30.0.3/apksigner sign \
  115. --ks keystore.jks --ks-pass "pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" \
  116. --in app/build/outputs/apk/release/app-release-unsigned.apk \
  117. --out app-signed.apk
  118. working-directory: android
  119. - name: Rename Apk
  120. run: |
  121. mkdir builds
  122. mv android/app-signed.apk ./builds/Logseq-android-${{ steps.ref.outputs.version }}.apk
  123. - name: Upload Artifact
  124. uses: actions/upload-artifact@v2
  125. with:
  126. name: logseq-android-builds
  127. path: builds