Repository navigation
238 lines (222 loc) · 11.6 KB
/
Copy pathdev.yml
File metadata and controls
238 lines (222 loc) · 11.6 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Publishes every change to the app on master as a development build:
# - on Google Play's internal testing track, a private channel for up to 100 testers, its
# closed testing track, for the testers on its list, and its open testing track, the beta
# anyone can join from the store page. Releases go to production (release.yml).
# - as a GitHub pre-release, dev-<version code>: the APK, with the same package and
# signature as releases, so it updates to and from them, and both builds' R8 mappings
# Changes that don't reach the app (tests, docs, CI, store listings) don't make one.
#
# The keys live in Cloud KMS and cannot be exported: the builds are made unsigned and signed by
# clementine-player/kms-signer, which only sends digests to KMS. GitHub Actions authenticates to
# Google Cloud through Workload Identity Federation (the pool Clementine's macOS signing uses,
# with its own provider and service account), for both signing and the Play upload, so the
# repository holds no keys or credentials at all. See RELEASING.md and scripts/gcp_*_setup.sh
# for the one-time setup; until each signing certificate is committed, its part is skipped with
# a notice.
name: dev
on:
push:
branches: [master]
# What goes into the app; later patterns override earlier ones.
paths:
- "app/**"
- "!app/src/test/**"
- "!app/src/androidTest/**"
- "!app/lint-baseline.xml"
- "gradle/**"
- "*.gradle.kts"
- "gradle.properties"
- ".github/workflows/dev.yml"
workflow_dispatch:
# Uploads must land in order, as each needs a higher version code than the last; release.yml
# shares the group.
concurrency:
group: play
cancel-in-progress: false
permissions:
contents: write # for the dev pre-release
id-token: write # for the OIDC token Workload Identity Federation exchanges
# Created by scripts/gcp_play_setup.sh and scripts/gcp_release_setup.sh.
env:
WORKLOAD_IDENTITY_PROVIDER: projects/611551928920/locations/global/workloadIdentityPools/github-actions/providers/android-remote-play
SERVICE_ACCOUNT: android-play-release@clementine-data.iam.gserviceaccount.com
UPLOAD_KMS_KEY: projects/clementine-data/locations/global/keyRings/android-signing/cryptoKeys/play-upload/cryptoKeyVersions/1
UPLOAD_CERT: app/upload_cert.pem
RELEASE_KMS_KEY: projects/clementine-data/locations/global/keyRings/android-signing/cryptoKeys/github-release/cryptoKeyVersions/1
RELEASE_CERT: app/release_cert.pem
# The signer release to use, pinned with its checksum since it signs releases. To update, take
# both from https://github.com/clementine-player/kms-signer/releases (and in release.yml).
KMS_SIGNER_VERSION: 2026.09.25-a3c0e5e
KMS_SIGNER_SHA256: 843d553610ebca4a4beee8fc9a66c0c9c7575bc614bc69ea3646eb656974798a
jobs:
dev:
# Workload Identity Federation admits master alone.
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@v7.0.1
with:
# The version code comes from the number of commits on the branch.
fetch-depth: 0
- uses: actions/setup-java@v6.2.0
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v6.4.1
- name: Version
id: version
run: |
# Twice the commit count: releases (release.yml) take the odd code after it, so
# the two never collide and every upload's code is higher than the last.
code=$(( 2 * $(git rev-list --count HEAD) ))
name="$(sed -n 's/^ *versionName = "\(.*\)"/\1/p' app/build.gradle.kts)+$(git rev-parse --short HEAD)"
min_sdk=$(sed -n 's/^ *minSdk = \([0-9]*\)/\1/p' app/build.gradle.kts)
{
echo "code=$code"
echo "name=$name"
echo "min_sdk=$min_sdk"
} >> "$GITHUB_OUTPUT"
echo "Building $name ($code)"
- name: Build the unsigned bundle and APK
run: >
./gradlew bundlePlayRelease assembleFdroidRelease
-PtestingFeatures=true
-PversionCodeOverride=${{ steps.version.outputs.code }}
-PversionNameOverride=${{ steps.version.outputs.name }}
- name: Check the signing setup
id: setup
run: |
play=false; github=false
if [ -f "$UPLOAD_CERT" ]; then
play=true
else
echo "::notice::Built the Play bundle but did not sign or upload it: $UPLOAD_CERT is not committed yet (see RELEASING.md)."
fi
if [ -f "$RELEASE_CERT" ]; then
github=true
else
echo "::notice::Built the APK but did not sign or publish it: $RELEASE_CERT is not committed yet (see RELEASING.md)."
fi
{
echo "play=$play"
echo "github=$github"
echo "cloud=$([ $play = true ] || [ $github = true ] && echo true || echo false)"
} >> "$GITHUB_OUTPUT"
- name: Get kms-signer
if: steps.setup.outputs.cloud == 'true'
run: |
zip="kms-signer-$KMS_SIGNER_VERSION.zip"
curl -sSfL -o "$RUNNER_TEMP/$zip" \
"https://github.com/clementine-player/kms-signer/releases/download/v$KMS_SIGNER_VERSION/$zip"
echo "$KMS_SIGNER_SHA256 $RUNNER_TEMP/$zip" | sha256sum --check
unzip -q "$RUNNER_TEMP/$zip" -d "$RUNNER_TEMP"
echo "KMS_SIGNER=$RUNNER_TEMP/kms-signer-$KMS_SIGNER_VERSION/bin/kms-signer" >> "$GITHUB_ENV"
- uses: google-github-actions/auth@v3.0.0
id: auth
if: steps.setup.outputs.cloud == 'true'
with:
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.SERVICE_ACCOUNT }}
- name: Sign the bundle with Cloud KMS
if: steps.setup.outputs.play == 'true'
run: |
"$KMS_SIGNER" sign --key "$UPLOAD_KMS_KEY" --cert "$UPLOAD_CERT" \
--in app/build/outputs/bundle/playRelease/ClementineRemote-play-release.aab \
--out "$RUNNER_TEMP/ClementineRemote-play-release.aab" \
--min-sdk ${{ steps.version.outputs.min_sdk }}
"$KMS_SIGNER" verify --in "$RUNNER_TEMP/ClementineRemote-play-release.aab"
- name: Sign the APK with Cloud KMS
if: steps.setup.outputs.github == 'true'
run: |
"$KMS_SIGNER" sign --key "$RELEASE_KMS_KEY" --cert "$RELEASE_CERT" \
--in app/build/outputs/apk/fdroid/release/ClementineRemote-fdroid-release-unsigned.apk \
--out "$RUNNER_TEMP/ClementineRemote-dev.apk"
"$KMS_SIGNER" verify --in "$RUNNER_TEMP/ClementineRemote-dev.apk"
# With R8's mappings, which turn a crash's stack trace from this build back into the
# code's names (retrace, in the SDK's command-line tools). Google Play gets the Play
# build's own, but a trace from logcat or the F-Droid APK needs these.
- uses: actions/upload-artifact@v7.0.2
with:
name: dev-builds
path: |
${{ runner.temp }}/ClementineRemote-play-release.aab
${{ runner.temp }}/ClementineRemote-dev.apk
app/build/outputs/bundle/playRelease/*.aab
app/build/outputs/apk/fdroid/release/*.apk
app/build/outputs/mapping/
- name: Release notes
run: |
mkdir -p whatsnew
git log -1 --format=%s | cut -c1-500 > whatsnew/whatsnew-en-US
# The GitHub pre-release: the build, then what changed since the last release.
last=$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n 1)
{
echo "Development build ${{ steps.version.outputs.name }} (${{ steps.version.outputs.code }}), from $GITHUB_SHA."
echo "It updates to the next release, and the next development build updates it."
echo
echo "Changes since ${last:-the start}:"
echo
git log --format='- %s' --no-merges ${last:+"$last.."}HEAD | head -n 50
} > "$RUNNER_TEMP/dev-notes.md"
- name: Upload to the testing tracks
id: upload
# Play may refuse to send changes for review itself (below).
continue-on-error: true
if: steps.setup.outputs.play == 'true'
uses: r0adkll/upload-google-play@v1.1.5
with:
# The federated credentials from the auth step, not a service account key.
serviceAccountJson: ${{ steps.auth.outputs.credentials_file_path }}
packageName: org.clementine_player.remote
releaseFiles: ${{ runner.temp }}/ClementineRemote-play-release.aab
releaseName: ${{ steps.version.outputs.name }}
# R8's map of the names it shortened, so Play shows readable stack traces.
mappingFile: app/build/outputs/mapping/playRelease/mapping.txt
tracks: internal,alpha,beta
# "draft" until the app's first release has been rolled out in Play Console.
status: ${{ vars.PLAY_RELEASE_STATUS || 'completed' }}
whatsNewDirectory: whatsnew
# When Play wants changes sent for review from Play Console (after a rejection, say), it
# refuses to send them itself: commit them unsent, for someone to send there.
- name: Upload to the testing tracks, without sending it for review
if: steps.setup.outputs.play == 'true' && steps.upload.outcome == 'failure'
uses: r0adkll/upload-google-play@v1.1.5
with:
# The federated credentials from the auth step, not a service account key.
serviceAccountJson: ${{ steps.auth.outputs.credentials_file_path }}
packageName: org.clementine_player.remote
releaseFiles: ${{ runner.temp }}/ClementineRemote-play-release.aab
releaseName: ${{ steps.version.outputs.name }}
# R8's map of the names it shortened, so Play shows readable stack traces.
mappingFile: app/build/outputs/mapping/playRelease/mapping.txt
tracks: internal,alpha,beta
# "draft" until the app's first release has been rolled out in Play Console.
status: ${{ vars.PLAY_RELEASE_STATUS || 'completed' }}
whatsNewDirectory: whatsnew
changesNotSentForReview: true
- name: Say it needs sending for review
if: steps.setup.outputs.play == 'true' && steps.upload.outcome == 'failure'
run: |
echo "::warning::Google Play wouldn't send this development build for review itself, so it waits in Play Console: send it for review from Publishing overview."
- name: Publish the dev pre-release
if: steps.setup.outputs.github == 'true'
env:
GH_TOKEN: ${{ github.token }}
TAG: dev-${{ steps.version.outputs.code }}
run: |
# Releases are immutable once published, so each build is a pre-release of its own,
# with R8's mappings from the start, as releases have: scripts/play_crashes.py puts
# the names back into crashes Play reports with R8's names, and a trace from logcat
# or the APK needs the F-Droid build's. They're all kept, so an older build's crashes
# can still be retraced. Already there when this is run again.
for flavor in play fdroid; do
cp "app/build/outputs/mapping/${flavor}Release/mapping.txt" \
"$RUNNER_TEMP/ClementineRemote-${{ steps.version.outputs.name }}-$flavor-mapping.txt"
done
if ! gh release view "$TAG" > /dev/null 2>&1; then
gh release create "$TAG" --prerelease --latest=false --target "$GITHUB_SHA" \
--title "Development build ${{ steps.version.outputs.name }}" \
--notes-file "$RUNNER_TEMP/dev-notes.md" \
"$RUNNER_TEMP/ClementineRemote-dev.apk" \
"$RUNNER_TEMP"/ClementineRemote-"${{ steps.version.outputs.name }}"-*-mapping.txt
fi