-
Notifications
You must be signed in to change notification settings - Fork 117
79 lines (69 loc) · 3.07 KB
/
build-apk.yaml
File metadata and controls
79 lines (69 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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