mirror of
https://github.com/logseq/logseq.git
synced 2026-04-26 23:25:05 +00:00
ci: add android apk build to nightly and beta release
This commit is contained in:
127
.github/workflows/build-android.yml
vendored
Normal file
127
.github/workflows/build-android.yml
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
# 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 ("nightly"/"beta")'
|
||||
type: string
|
||||
required: true
|
||||
default: "beta"
|
||||
workflow_call:
|
||||
inputs:
|
||||
build-target:
|
||||
type: string
|
||||
required: true
|
||||
secrets:
|
||||
ANDROID_KEYSTORE:
|
||||
required: true
|
||||
ANDROID_KEYSTORE_PASSWORD:
|
||||
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
|
||||
|
||||
- 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/setup-java@v1.4.3
|
||||
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/setup-clojure@3.5
|
||||
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: Compile CLJS
|
||||
run: yarn install && yarn release
|
||||
|
||||
- name: Prepare public Directory
|
||||
run: |
|
||||
cp -r static public/
|
||||
rm -rvf public/static/js/publishing
|
||||
rm -rvf public/workspaces
|
||||
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
|
||||
Reference in New Issue
Block a user