Skip to content

debug

debug #53

Workflow file for this run

name: Android Build
on:
release:
types: [created]
push:
branches:
- test
env:
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true
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
run: |
if [[ ${{ github.ref }} == 'refs/heads/test' || ${{ github.ref }} == 'refs/heads/main' || ${{ github.event_name }} == 'release' ]]; then
cp .env.production.example .env
else
cp .env.development.example .env
fi
source .env
echo "VITE_APP_NAME=$VITE_APP_NAME" >> $GITHUB_ENV
echo "VITE_ANDROID_APPLICATION_ID=$VITE_ANDROID_APPLICATION_ID" >> $GITHUB_ENV
echo "VITE_APP_URL=$VITE_APP_URL" >> $GITHUB_ENV
- name: Debug environment
run: |
echo "Environment variables:"
echo "VITE_APP_NAME: ${{ env.VITE_APP_NAME }}"
echo "VITE_ANDROID_APPLICATION_ID: ${{ env.VITE_ANDROID_APPLICATION_ID }}"
echo "VITE_APP_URL: ${{ env.VITE_APP_URL }}"
- name: Set VERSION and VERSION_CODE
run: |
if [[ ${{ github.event_name }} == 'release' ]]; then
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "VERSION_CODE=$(git rev-list --count HEAD)" >> $GITHUB_ENV
else
echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "VERSION_CODE=$(git rev-list --count HEAD)" >> $GITHUB_ENV
fi
- name: Run pre-build script
run: |
if [ -f .env ]; then
source .env
VERSION=${{ env.VERSION }} VERSION_CODE=${{ env.VERSION_CODE }} npm run prebuild
else
echo ".env file not found. Current directory contents:"
ls -la
echo "Current working directory: $(pwd)"
exit 1
fi
- name: Check AndroidManifest.xml after prebuild
run: |
echo "AndroidManifest.xml contents after prebuild:"
cat android/app/src/main/AndroidManifest.xml
- name: Build Android app
run: |
source .env
ionic cap sync android
ionic cap build android --no-interactive --prod
- 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 --info \
-PversionCode=${{ env.VERSION_CODE }} \
-PversionName=${{ env.VERSION }} \
-PappName="${{ env.VITE_APP_NAME }}" \
-PapplicationId="${{ env.VITE_ANDROID_APPLICATION_ID }}" \
-PappUrl="${{ env.VITE_APP_URL }}"
- name: Check AndroidManifest.xml after Gradle build
run: |
echo "AndroidManifest.xml contents after Gradle build:"
cat android/app/src/main/AndroidManifest.xml
- 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 }}-prod-${{ 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 }}-prod-${{ env.VERSION }}.apk
shell: bash
- name: Set VERSION for release
if: github.event_name == 'release'
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Set VERSION for test branch
if: github.event_name == 'push'
run: echo "VERSION=test" >> $GITHUB_ENV
- name: Sign APK
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.VITE_APP_NAME }}-${{ env.VERSION }}.apk android/app/build/outputs/apk/release/app-release-unsigned.apk
shell: bash
- name: Verify APK
run: |
$ANDROID_SDK_ROOT/build-tools/33.0.0/apksigner verify android/app/build/outputs/apk/release/${{ env.VITE_APP_NAME }}-${{ env.VERSION }}.apk
shell: bash
- name: Upload APK to GitHub Release
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: android/app/build/outputs/apk/release/${{ env.VITE_APP_NAME }}-${{ env.VERSION }}.apk
asset_name: ${{ env.VITE_APP_NAME }}-${{ env.VERSION }}.apk
asset_content_type: application/vnd.android.package-archive
- name: Upload APK as artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v3
with:
name: app-release-${{ env.BUILD_TYPE }}
path: android/app/build/outputs/apk/release/${{ env.VITE_APP_NAME }}-${{ env.VERSION }}.apk
- name: Check AndroidManifest.xml
run: |
cat android/app/src/main/AndroidManifest.xml
- name: Debug Build Environment
run: |
echo "VITE_ANDROID_APPLICATION_ID: ${{ env.VITE_ANDROID_APPLICATION_ID }}"
echo "Gradle Properties:"
cat android/gradle.properties
echo "Build Gradle Contents:"
cat android/app/build.gradle
- name: Check APK contents
run: |
APK_DIR="android/app/build/outputs/apk/release"
APK_FILE=$(find $APK_DIR -name "*.apk" | head -n 1)
if [ -f "$APK_FILE" ]; then
echo "APK file found: $APK_FILE"
echo "APK contents:"
unzip -l "$APK_FILE"
echo "AndroidManifest.xml contents:"
if unzip -p "$APK_FILE" AndroidManifest.xml > manifest.xml; then
if [ -s manifest.xml ]; then
$ANDROID_SDK_ROOT/build-tools/33.0.0/aapt dump xmltree manifest.xml || echo "aapt command failed"
else
echo "Extracted AndroidManifest.xml is empty"
fi
else
echo "Failed to extract AndroidManifest.xml from APK"
fi
else
echo "No APK file found in $APK_DIR"
ls -R $APK_DIR
fi
- name: Check aapt version
run: |
$ANDROID_SDK_ROOT/build-tools/33.0.0/aapt version || echo "aapt not found or failed to run"