109 lines
3.1 KiB
YAML
109 lines
3.1 KiB
YAML
name: Android Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
name: Build Release APK
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '17'
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v3
|
|
|
|
- name: Grant execute permission for gradlew
|
|
run: chmod +x droid/gradlew
|
|
|
|
- name: Create keystore directory
|
|
run: mkdir -p ~/.android
|
|
|
|
- name: Decode Keystore
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
|
run: |
|
|
if [ -z "$KEYSTORE_BASE64" ]; then
|
|
echo "KEYSTORE_BASE64 secret not set"
|
|
exit 1
|
|
fi
|
|
echo "$KEYSTORE_BASE64" | base64 -d > ~/.android/inbe-release.keystore
|
|
echo "Keystore decoded successfully"
|
|
|
|
- name: Build Release APK
|
|
working-directory: ./droid
|
|
env:
|
|
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
run: |
|
|
./gradlew assembleRelease \
|
|
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
|
-Pkeystore.path="/home/runner/.android/inbe-release.keystore" \
|
|
--stacktrace
|
|
|
|
- name: Rename APKs
|
|
run: |
|
|
find droid/app/build/outputs/apk/release -name "*-universal-release.apk" -exec cp {} inbe-universal.apk \; 2>/dev/null || true
|
|
find droid/app/build/outputs/apk/release -name "*.apk" -exec cp {} inbe.apk \; 2>/dev/null || true
|
|
|
|
- name: Upload APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-apk
|
|
path: |
|
|
inbe-universal.apk
|
|
inbe.apk
|
|
if-no-files-found: warn
|
|
|
|
- name: Create and Push Tag (if new version)
|
|
id: tag_version
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
run: |
|
|
VERSION=$(grep "versionName" droid/app/build.gradle | awk '{print $2}' | tr -d '"')
|
|
TAG="v$VERSION"
|
|
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
|
echo "Tag $TAG exists, skipping"
|
|
echo "tag_pushed=false" >> $GITHUB_OUTPUT
|
|
else
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git tag -a "$TAG" -m "Release $VERSION"
|
|
git push origin "$TAG"
|
|
echo "tag_pushed=true" >> $GITHUB_OUTPUT
|
|
echo "tag_name=$TAG" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Create GitHub Release
|
|
if: steps.tag_version.outputs.tag_pushed == 'true'
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: ${{ steps.tag_version.outputs.tag_name }}
|
|
files: |
|
|
inbe-universal.apk
|
|
inbe.apk
|
|
generate_release_notes: true
|
|
draft: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|