build test #21
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-latest | |
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 for test | |
if: github.ref == 'refs/heads/test' | |
run: cp .env.development.example .env | |
- name: Set up environment for main | |
if: github.ref == 'refs/heads/main' | |
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: 'temurin' | |
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 for test | |
if: github.ref == 'refs/heads/test' | |
run: | | |
$ANDROID_SDK_ROOT/build-tools/33.0.0/apksigner sign --ks my-release-key.keystore --ks-pass pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }} --key-pass pass:${{ secrets.ANDROID_KEY_PASSWORD }} --out android/app/build/outputs/apk/release/${{ env.APP_NAME }}-test-${{ env.VERSION }}.apk android/app/build/outputs/apk/release/app-release-unsigned.apk | |
shell: bash | |
- name: Sign APK for main | |
if: github.ref == 'refs/heads/main' | |
run: | | |
$ANDROID_SDK_ROOT/build-tools/33.0.0/apksigner sign --ks my-release-key.keystore --ks-pass pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }} --key-pass pass:${{ secrets.ANDROID_KEY_PASSWORD }} --out android/app/build/outputs/apk/release/${{ env.APP_NAME }}-${{ env.VERSION }}.apk android/app/build/outputs/apk/release/app-release-unsigned.apk | |
shell: bash | |
- name: Verify APK for test | |
if: github.ref == 'refs/heads/test' | |
run: | | |
$ANDROID_SDK_ROOT/build-tools/33.0.0/apksigner verify android/app/build/outputs/apk/release/${{ env.APP_NAME }}-test-${{ env.VERSION }}.apk | |
shell: bash | |
- name: Verify APK for main | |
if: github.ref == 'refs/heads/main' | |
run: | | |
$ANDROID_SDK_ROOT/build-tools/33.0.0/apksigner verify android/app/build/outputs/apk/release/${{ env.APP_NAME }}-${{ env.VERSION }}.apk | |
shell: bash | |
- name: Upload APK for test | |
if: github.ref == 'refs/heads/test' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-release-test | |
path: android/app/build/outputs/apk/release/${{ env.APP_NAME }}-test-${{ env.VERSION }}.apk | |
- name: Upload APK for main | |
if: github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-release-prod | |
path: android/app/build/outputs/apk/release/${{ env.APP_NAME }}-${{ env.VERSION }}.apk |