android ci #13
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: | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- test | |
env: | |
ACTIONS_RUNNER_DEBUG: true | |
ACTIONS_STEP_DEBUG: true | |
APP_NAME: "shockwallet" | |
VERSION: ${{ github.ref_name }} | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install deps | |
run: | | |
npm ci | |
npm install -g @ionic/cli native-run cordova-res | |
- name: Set up environment | |
run: cp .env.production.example .env | |
- name: Run pre-build script | |
run: npm run prebuild | |
- name: Build Android app | |
run: ionic cap build android --no-interactive | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Cache Gradle packages | |
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: Make gradlew executable | |
run: chmod +x ./android/gradlew | |
- name: Build with Gradle | |
run: | | |
cd android | |
./gradlew assembleRelease | |
- name: Set up Android SDK | |
uses: android-actions/setup-android@v3 | |
- name: Decode Keystore | |
run: | | |
echo ${{ secrets.ANDROID_KEYSTORE }} | base64 --decode > my-release-key.keystore | |
shell: bash | |
- name: Verify Keystore | |
run: | | |
keytool -list -v -keystore my-release-key.keystore -storepass ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
shell: bash | |
- name: Sign APK | |
run: | | |
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore -storepass ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} -keypass ${{ secrets.ANDROID_KEY_PASSWORD }} android/app/build/outputs/apk/release/app-release-unsigned.apk ${{ secrets.ANDROID_KEY_ALIAS }} | |
zipalign -v 4 android/app/build/outputs/apk/release/app-release-unsigned.apk android/app/build/outputs/apk/release/${{ env.APP_NAME }}-${{ env.VERSION }}.apk | |
shell: bash | |
- name: Verify APK | |
run: | | |
apksigner verify android/app/build/outputs/apk/release/${{ env.APP_NAME }}-${{ env.VERSION }}.apk | |
shell: bash | |
- name: Upload APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-release | |
path: android/app/build/outputs/apk/release/${{ env.APP_NAME }}-${{ env.VERSION }}.apk |