94 lines
No EOL
2.9 KiB
YAML
94 lines
No EOL
2.9 KiB
YAML
name: Build APK
|
|
|
|
on:
|
|
push:
|
|
branches: [ "master" ]
|
|
tags: [ "v*", "V*" ]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and push
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: "temurin"
|
|
java-version: "17"
|
|
|
|
- name: Make Gradle executable
|
|
run: chmod +x ./gradlew
|
|
|
|
- name: Build APKs
|
|
run: |
|
|
# Retry the Gradle build up to 3 times to mitigate transient cache/service errors
|
|
ATTEMPT=0
|
|
until [ $ATTEMPT -ge 3 ]
|
|
do
|
|
./gradlew build --no-daemon --stacktrace && break
|
|
ATTEMPT=$((ATTEMPT+1))
|
|
echo "Gradle build failed, retrying ($ATTEMPT/3)..."
|
|
sleep 5
|
|
done
|
|
if [ $ATTEMPT -ge 3 ]; then
|
|
echo "Gradle build failed after 3 attempts"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Setup directories
|
|
run:
|
|
mkdir -p /tmp/ShiggyXposedbuild/apks
|
|
mkdir -p /tmp/ShiggyXposedbuild/tools
|
|
|
|
- name: Move debug APK
|
|
run: mv ./app/build/outputs/apk/debug/app-debug.apk /tmp/ShiggyXposedbuild/apks
|
|
|
|
- name: Download uber-apk-signer
|
|
run: wget -nv "https://github.com/patrickfav/uber-apk-signer/releases/download/v1.2.1/uber-apk-signer-1.2.1.jar" -O /tmp/ShiggyXposedbuild/tools/uber-apk-signer.jar
|
|
|
|
- name: Sign release APK
|
|
run: java -jar /tmp/ShiggyXposedbuild/tools/uber-apk-signer.jar --apks ./app/build/outputs/apk/release/app-release-unsigned.apk --out /tmp/ShiggyXposedbuild/apks/
|
|
|
|
- name: Rename release APK
|
|
run: mv /tmp/ShiggyXposedbuild/apks/app-release-aligned-debugSigned.apk /tmp/ShiggyXposedbuild/apks/app-release.apk
|
|
|
|
- name: Upload debug APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: app-debug
|
|
path: /tmp/ShiggyXposedbuild/apks/app-debug.apk
|
|
|
|
- name: Upload All APKs
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: app-release
|
|
path: /tmp/ShiggyXposedbuild/apks/app-release.apk
|
|
|
|
- name: Publish APKs to GitHub Release
|
|
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
TAG_NAME="${GITHUB_REF#refs/tags/}"
|
|
else
|
|
TAG_NAME=$(gh release view --json tagName -q .tagName 2>/dev/null || echo "")
|
|
fi
|
|
if [ -n "$TAG_NAME" ]; then
|
|
echo "Uploading APKs to release $TAG_NAME..."
|
|
gh release upload "$TAG_NAME" \
|
|
/tmp/ShiggyXposedbuild/apks/app-release.apk \
|
|
/tmp/ShiggyXposedbuild/apks/app-debug.apk \
|
|
--clobber
|
|
else
|
|
echo "No release tag found to upload assets to."
|
|
fi |