build-android.yml 3.8 KB

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