Files
Bible-Daily/.github/workflows/android-build.yml
T

71 lines
1.8 KiB
YAML

name: Build Android APK
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Make Gradle wrapper executable
run: chmod +x gradlew
- name: Build update-compatible APK
run: ./gradlew assembleDebug -PciVersionCode=${{ github.run_number }} -PciVersionName=1.0.${{ github.run_number }}
- name: Prepare release assets
shell: bash
run: |
VERSION_CODE="${{ github.run_number }}"
VERSION_NAME="1.0.${{ github.run_number }}"
APK_URL="https://github.com/jahruz67/Bible-Daily/releases/download/latest/app-debug.apk"
APK_PATH="$(find app/build/outputs/apk/debug -maxdepth 1 -name '*.apk' -print -quit)"
if [ -z "$APK_PATH" ]; then
echo "No APK found in app/build/outputs/apk/debug"
exit 1
fi
cp "$APK_PATH" app-debug.apk
cat > latest.json <<EOF
{
"versionCode": $VERSION_CODE,
"versionName": "$VERSION_NAME",
"apkUrl": "$APK_URL",
"commit": "${GITHUB_SHA}",
"builtAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
- name: Upload APK to latest release
uses: softprops/action-gh-release@v2
with:
tag_name: latest
name: Latest APK
files: |
app-debug.apk
latest.json
make_latest: true
overwrite_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}