Skip to content

https://github.com/BharathVishal/BatteryStats-for-Android :assembleRelease #57

https://github.com/BharathVishal/BatteryStats-for-Android :assembleRelease

https://github.com/BharathVishal/BatteryStats-for-Android :assembleRelease #57

Workflow file for this run

name: Build Android APK
run-name: ${{ github.event.inputs.repository }} ${{ github.event.inputs.branchName && format('{0}', github.event.inputs.branchName) }} ${{ github.event.inputs.subdir && format('[/{0}]', github.event.inputs.subdir) }} :${{ github.event.inputs.taskName }}
on:
workflow_dispatch:
inputs:
repository:
description: "Git repository URL"
required: true
default: "https://github.com/android/sunflower"
branchName:
description: "Git branch name [Optional]"
required: false
default: ""
subdir:
description: "Relative subdirectory path when the project is nested [Optional]"
required: false
default: ""
jdkVersion:
description: "OpenJDK version: 8, 17, 21, 25, …"
required: false
default: "17"
taskName:
description: "build.gradle task name: assembleDebug, assembleRelease, etc."
required: false
default: "assembleRelease"
jobs:
build:
runs-on: ubuntu-latest # Android SDK is built into this image
steps:
- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: ${{ github.event.inputs.jdkVersion }}
- name: Clone project
run: |
if [[ -z "${{ github.event.inputs.branchName }}" ]]; then
git clone --recurse-submodules --depth=1 ${{ github.event.inputs.repository }} workspace
else
git clone --recurse-submodules --depth=1 --branch ${{ github.event.inputs.branchName }} ${{ github.event.inputs.repository }} workspace
fi
- name: Build APK
working-directory: ./workspace/${{ github.event.inputs.subdir }}
run: |
if [ ! -f "gradlew" ]; then gradle wrapper; fi
chmod +x gradlew
if [[ "${{ github.event.inputs.taskName }}" == *Release* ]]; then
echo "Task contains 'Release', attempting to sign a release build with a debug key."
if [ ! -f "$HOME/.android/debug.keystore" ]; then
echo "Debug keystore not found. Creating one..."
keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
mkdir -p $HOME/.android
mv debug.keystore $HOME/.android/debug.keystore
fi
./gradlew ${{ github.event.inputs.taskName }} \
-Pandroid.injected.signing.store.file="$HOME/.android/debug.keystore" \
-Pandroid.injected.signing.store.password=android \
-Pandroid.injected.signing.key.alias=androiddebugkey \
-Pandroid.injected.signing.key.password=android \
--stacktrace
else
./gradlew ${{ github.event.inputs.taskName }} --stacktrace
fi
- name: Upload the APK artifact with 1 day retention
uses: actions/upload-artifact@v6
with:
path: workspace/**/*.apk
name: apk-archive
retention-days: 1