build-android.yml 4.5 KB

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