Skip to content

update build.yml

update build.yml #6

Workflow file for this run

name: Build Signed Android APK/AAB
on:
# Manual trigger (always available)
workflow_dispatch:
inputs:
build_type:
description: 'Build type'
required: true
default: 'debug'
type: choice
options:
- debug
- release
# Only on version tags
push:
tags:
- 'v*.*.*'
jobs:
build-android:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Install dependencies
run: npm install --legacy-peer-deps # Added --legacy-peer-deps for tailwind conflict
- name: Expo Prebuild
run: npx expo prebuild --platform android --clean
- name: Setup Gradle cache
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/release.keystore
- name: Create keystore.properties
run: |
echo "storeFile=release.keystore" > android/keystore.properties
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" >> android/keystore.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/keystore.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/keystore.properties
- name: Make gradlew executable
run: chmod +x android/gradlew
- name: Build Signed APK
run: cd android && ./gradlew assembleRelease --no-daemon
- name: Build Signed AAB
run: cd android && ./gradlew bundleRelease --no-daemon
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: app-release-apk
path: android/app/build/outputs/apk/release/*.apk
retention-days: 30
- name: Upload AAB artifact
uses: actions/upload-artifact@v4
with:
name: app-release-aab
path: android/app/build/outputs/bundle/release/*.aab
retention-days: 30
- name: Create Release
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ github.run_number }}
name: Release v${{ github.run_number }}
body: |
Automated build from commit ${{ github.sha }}
files: |
android/app/build/outputs/apk/release/*.apk
android/app/build/outputs/bundle/release/*.aab
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup keystore
if: always()
run: |
rm -f android/app/release.keystore
rm -f android/keystore.properties