forked from AlexandreRouma/SDRPlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (125 loc) · 6.51 KB
/
build_android.yml
File metadata and controls
137 lines (125 loc) · 6.51 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Build Android
on:
workflow_call:
inputs:
version_full:
required: true
type: string
secrets:
ANDROID_KEYSTORE_BASE64:
required: false
ANDROID_KEYSTORE_PASSWORD:
required: false
ANDROID_KEY_ALIAS:
required: false
ANDROID_KEY_PASSWORD:
required: false
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
# Don't abort sibling matrix jobs if one fails — the failure is
# usually specific to one (flavor, build_type) combination and
# we want to surface diagnostics for the working ones too.
fail-fast: false
matrix:
# Per-(flavor, build_type) matrix split. Each cell runs in its
# own parallel job, dropping the wall-clock from sum(per-cell)
# to max(per-cell). flavor maps to the productFlavors{} block
# in android/app/build.gradle ('arm' = armeabi-v7a + arm64-v8a,
# 'x86' = x86 + x86_64). flavor_caps / build_type_caps are
# CamelCase variants for the assemble<Flavor><BuildType>
# gradle task name — flavor / build_type stay lowercase
# because they appear in apk output paths and artifact names.
include:
- flavor: arm
flavor_caps: Arm
build_type: debug
build_type_caps: Debug
- flavor: x86
flavor_caps: X86
build_type: debug
build_type_caps: Debug
- flavor: arm
flavor_caps: Arm
build_type: release
build_type_caps: Release
- flavor: x86
flavor_caps: X86
build_type: release
build_type_caps: Release
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: |
sudo apt update -y
sudo apt install -y wget git p7zip-full openjdk-17-jdk build-essential cmake patchelf python3-mako
# Provision Gradle 9.4.1 (pinned to match android/build.gradle's AGP
# 9.2.1) ahead of install_android_devenv.sh so the script's gradle
# detect-and-skip block short-circuits, and so subsequent steps that
# invoke `gradle` find it on PATH. The action also caches Gradle's
# user home (~/.gradle/caches, daemon JVMs) across runs.
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
with:
gradle-version: 9.4.1
# Shared across every workflow in the repo — tarballs are byte-identical
# regardless of target platform, URL_HASH validates correctness at
# extraction. The same key in every workflow means Android, Linux,
# macOS, and Windows all hit the same cache entry: a curl tarball
# downloaded by one workflow is reused by the next instead of being
# re-fetched. Restore-keys keep tarballs accumulating across recipe
# edits — additions to .pkg_cache never conflict, URL_HASH guards
# against stale content.
- name: Cache deps download tarballs
uses: actions/cache@v4
with:
path: deps/.pkg_cache
key: deps-pkgcache-${{ hashFiles('deps/+**/*.cmake', 'deps/cmake/**/*.cmake', 'deps/CMakeLists.txt', 'deps/CMakePresets.json') }}
restore-keys: |
deps-pkgcache-
# Per-(flavor, build_type) install-prefix cache. Glob covers both
# ABIs in this flavor (arm* matches armeabi-v7a + arm64-v8a; x86*
# matches x86 + x86_64) for the specific build type. Exact-key only
# — autobuild.cmake's recipe-hash marker is the safety net against
# stale state slipping through.
- name: Cache deps install prefix (${{ matrix.flavor }} / ${{ matrix.build_type_caps }})
uses: actions/cache@v4
with:
path: deps/build-android-${{ matrix.flavor }}*-${{ matrix.build_type_caps }}/destdir
key: deps-destdir-android-${{ matrix.flavor }}-${{ matrix.build_type_caps }}-${{ hashFiles('deps/+**', 'deps/cmake/**', 'deps/CMakeLists.txt', 'deps/CMakePresets.json', 'cmake/sdrpp_collect_required_deps.cmake', 'android/app/build.gradle') }}
- name: Install Android development environment
run: bash ./install_android_devenv.sh
# Release-only: decode the signing keystore if the secret is present.
# has_keystore controls whether the Release build / upload steps run
# — repos without the secret (forks, PRs) skip the release path
# cleanly while still producing the matching Debug APK.
- name: Decode keystore
id: check_signing
if: matrix.build_type == 'release'
run: |
if [ -n "$ANDROID_KEYSTORE_BASE64" ]; then
echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > ${{ runner.workspace }}/release.keystore
echo "has_keystore=true" >> $GITHUB_OUTPUT
else
echo "has_keystore=false" >> $GITHUB_OUTPUT
fi
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
- name: Build ${{ matrix.flavor_caps }} ${{ matrix.build_type_caps }} APK
if: matrix.build_type == 'debug' || steps.check_signing.outputs.has_keystore == 'true'
working-directory: ${{ github.workspace }}/android
env:
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
ANDROID_KEYSTORE_FILE: ${{ runner.workspace }}/release.keystore
run: gradle --info -PoptBuildDeps=ON assemble${{ matrix.flavor_caps }}${{ matrix.build_type_caps }}
- name: Save ${{ matrix.flavor_caps }} ${{ matrix.build_type_caps }} APK
if: matrix.build_type == 'debug' || steps.check_signing.outputs.has_keystore == 'true'
uses: actions/upload-artifact@v4
with:
name: sdrpp-iak-${{ inputs.version_full }}-android-${{ matrix.flavor }}-${{ matrix.build_type }}
path: ${{ github.workspace }}/android/app/build/outputs/apk/${{ matrix.flavor }}/${{ matrix.build_type }}/sdrpp-iak-${{ matrix.flavor }}-${{ matrix.build_type }}.apk