Android Build #69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android Build | |
on: | |
workflow_run: | |
workflows: ["Electron Build and Release"] | |
types: | |
- completed | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./capacitor | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-tags: true | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.4.0 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'pnpm' | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
check-latest: true | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Install node-pre-gyp | |
run: pnpm install -g node-pre-gyp | |
- name: Remove Cached Build | |
run: rm -rf ./build && mkdir ./build | |
- name: Forcefully Remove Developer Mode | |
run: | | |
sed -i "s@if (mode === 'development')@// if (mode === 'development')@g" ./capacitor.config.js | |
echo "Forcefully removed developer mode" | |
- name: Build Native + Web | |
run: pnpm run build:app | |
- name: Sync | |
run: pnpm exec cap sync android | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build App | |
run: cd android && chmod +x ./gradlew && ./gradlew assembleRelease | |
- name: Stop Gradle daemon | |
run: cd android && ./gradlew --stop | |
# - name: Setup build tool version variable | |
# shell: bash | |
# run: | | |
# BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | |
# echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | |
# echo Last build tool version is: $BUILD_TOOL_VERSION | |
- name: Get Tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
GIT_CURR_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName') | |
echo "GIT_CURR_TAG=$GIT_CURR_TAG" >> $GITHUB_ENV | |
echo Last Tag is: $GIT_CURR_TAG | |
- uses: Wandalen/wretry.action@master | |
name: Sign app APK | |
id: sign_app | |
with: | |
attempt_limit: 3 | |
action: NoCrypt/[email protected] | |
with: | | |
releaseDir: capacitor/android/app/build/outputs/apk/release | |
signingKey: ${{ secrets.SIGNING_KEY }} | |
keyAlias: ${{ secrets.ALIAS }} | |
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEY_PASSWORD }} | |
appName: Migu | |
appVersion: ${{ env.GIT_CURR_TAG }} | |
appPrefix: android | |
- uses: jungwinter/split@v2 | |
id: signed_files | |
with: | |
msg: ${{ fromJSON( steps.sign_app.outputs.outputs ).signedFiles }} | |
separator: ':' | |
- name: Upload APK to release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git fetch --tags | |
gh release upload --clobber ${{ env.GIT_CURR_TAG }} ../${{ steps.signed_files.outputs._0 }} | |
gh release upload --clobber ${{ env.GIT_CURR_TAG }} ../${{ steps.signed_files.outputs._1 }} | |
gh release upload --clobber ${{ env.GIT_CURR_TAG }} ../${{ steps.signed_files.outputs._2 }} | |
gh release upload --clobber ${{ env.GIT_CURR_TAG }} ../${{ steps.signed_files.outputs._3 }} |