95 lines
2.6 KiB
YAML
95 lines
2.6 KiB
YAML
name: Build Android APK
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '21'
|
|
|
|
- name: Setup Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Sync Capacitor
|
|
run: npx cap sync android
|
|
|
|
- name: Check if keystore exists
|
|
id: keystore-check
|
|
run: |
|
|
if [ -n "$KEYSTORE_BASE64" ]; then
|
|
echo "exists=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "exists=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
|
|
|
- name: Decode keystore
|
|
if: steps.keystore-check.outputs.exists == 'true'
|
|
run: |
|
|
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > android/impostor.keystore
|
|
|
|
- name: Create keystore.properties
|
|
if: steps.keystore-check.outputs.exists == 'true'
|
|
run: |
|
|
cat > android/keystore.properties << EOF
|
|
storeFile=../impostor.keystore
|
|
storePassword=${{ secrets.KEYSTORE_PASSWORD }}
|
|
keyAlias=${{ secrets.KEY_ALIAS }}
|
|
keyPassword=${{ secrets.KEY_PASSWORD }}
|
|
EOF
|
|
|
|
- name: Build Release APK
|
|
if: steps.keystore-check.outputs.exists == 'true'
|
|
working-directory: android
|
|
run: ./gradlew assembleRelease --no-daemon
|
|
|
|
- name: Build Debug APK (fallback)
|
|
if: steps.keystore-check.outputs.exists == 'false'
|
|
working-directory: android
|
|
run: ./gradlew assembleDebug --no-daemon
|
|
|
|
- name: Rename APK
|
|
run: |
|
|
if [ "${{ steps.keystore-check.outputs.exists }}" == "true" ]; then
|
|
cp android/app/build/outputs/apk/release/app-release.apk impostor-game.apk
|
|
else
|
|
cp android/app/build/outputs/apk/debug/app-debug.apk impostor-game.apk
|
|
fi
|
|
|
|
- name: Update latest release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: latest
|
|
name: Latest Build
|
|
body: |
|
|
Última versión del APK generada automáticamente.
|
|
|
|
Commit: ${{ github.sha }}
|
|
files: impostor-game.apk
|
|
prerelease: false
|
|
make_latest: true |