| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- # This is the main Android apk build workflow for both nightly and beta releases.
- # This is also configured to run as a workflow_call.
- name: Build-Android
- on:
- workflow_dispatch:
- inputs:
- build-target:
- description: 'Build Target (Release Type)'
- type: choice
- required: true
- options:
- - beta
- - nightly
- - non-release
- default: "non-release"
- git-ref:
- description: "Build from Git Ref(master)"
- required: true
- default: "master"
- enable-file-sync-production:
- description: 'File sync production mode'
- type: boolean
- required: true
- default: true
- workflow_call:
- inputs:
- build-target:
- type: string
- required: true
- enable-file-sync-production:
- description: 'File sync production mode'
- type: boolean
- secrets:
- ANDROID_KEYSTORE:
- required: true
- ANDROID_KEYSTORE_PASSWORD:
- required: true
- SENTRY_AUTH_TOKEN:
- required: true
- env:
- CLOJURE_VERSION: '1.10.1.763'
- NODE_VERSION: '16'
- jobs:
- build-apk:
- runs-on: ubuntu-latest
- steps:
- - name: Check out Git repository
- uses: actions/checkout@v2
- with:
- ref: ${{ github.event.inputs.git-ref }}
- - name: Install Node.js, NPM and Yarn
- uses: actions/setup-node@v2
- with:
- node-version: ${{ env.NODE_VERSION }}
- - name: Get yarn cache directory path
- id: yarn-cache-dir-path
- run: echo "::set-output name=dir::$(yarn cache dir)"
- - name: Cache yarn cache directory
- uses: actions/cache@v2
- id: yarn-cache
- with:
- path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- restore-keys: |
- ${{ runner.os }}-yarn-
- - name: Setup Java JDK
- uses: actions/[email protected]
- with:
- java-version: 1.8
- - name: Cache clojure deps
- uses: actions/cache@v2
- with:
- path: |
- ~/.m2/repository
- ~/.gitlibs
- key: ${{ runner.os }}-clojure-lib-${{ hashFiles('**/deps.edn') }}
- - name: Setup clojure
- uses: DeLaGuardo/[email protected]
- with:
- cli: ${{ env.CLOJURE_VERSION }}
- - name: Retrieve tag version
- id: ref
- run: |
- pkgver=$(node ./scripts/get-pkg-version.js "${{ inputs.build-target || github.event.inputs.build-target }}")
- echo ::set-output name=version::$pkgver
- - name: Update Nightly APP Version
- if: ${{ inputs.build-target == 'nightly' || github.event.inputs.build-target == 'nightly' }}
- run: |
- sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs
- sed -i 's/versionName ".*"/versionName "${{ steps.ref.outputs.version }}"/g' android/app/build.gradle
- - name: Set Build Environment Variables
- run: |
- echo "ENABLE_FILE_SYNC_PRODUCTION=${{ inputs.enable-file-sync-production == 'true' || github.event.inputs.enable-file-sync-production == 'true' }}" >> $GITHUB_ENV
- - name: Compile CLJS - android variant, use es6 instead of es-next
- run: yarn install && yarn release-android-app
- - name: Upload Sentry Sourcemaps (beta only)
- if: ${{ github.repository == 'logseq/logseq' && (inputs.build-target == 'beta' || github.event.inputs.build-target == 'beta') }}
- run: |
- curl -sL https://sentry.io/get-cli/ | bash
- release_name="logseq-android@${{ steps.ref.outputs.version }}"
- sentry-cli releases new "${release_name}"
- sentry-cli releases files "${release_name}" upload-sourcemaps --ext map --ext js ./static/js --url-prefix '~/static/js'
- sentry-cli releases finalize "${release_name}"
- env:
- SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- SENTRY_ORG: logseq
- SENTRY_PROJECT: logseq
- - name: Prepare public Directory
- run: |
- cp -r static public/
- rm -rvf public/static/js/publishing
- rm -rvf public/static/js/*.js.map || true
- rm -rvf public/static/*.*
- rm -rvf public/static/ios
- rm -rvf android/app/src/main/assets/public || true
- - name: Sync public to Android Project
- run: npx cap sync
- - name: Setup Android SDK
- uses: android-actions/setup-android@v2
- - name: Build Android
- run: |
- ./gradlew clean
- ./gradlew zipApksForRelease
- working-directory: android
- - name: Sign Android APK
- run: |
- echo ${{ secrets.ANDROID_KEYSTORE }} | base64 -d > keystore.jks
- /usr/local/lib/android/sdk/build-tools/30.0.3/apksigner sign \
- --ks keystore.jks --ks-pass "pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" \
- --in app/build/outputs/apk/release/app-release-unsigned.apk \
- --out app-signed.apk
- working-directory: android
- - name: Rename Apk
- run: |
- mkdir builds
- mv android/app-signed.apk ./builds/Logseq-android-${{ steps.ref.outputs.version }}.apk
- - name: Upload Artifact
- uses: actions/upload-artifact@v2
- with:
- name: logseq-android-builds
- path: builds
|