Repository navigation
94 lines (82 loc) · 3.2 KB
/
Copy pathandroid.yml
File metadata and controls
94 lines (82 loc) · 3.2 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
name: Android
# Builds the Android app (android/) and, on version tags, attaches the APK to the GitHub
# release. Signing: set the ANDROID_KEYSTORE_B64 / ANDROID_KEYSTORE_PASSWORD /
# ANDROID_KEY_ALIAS / ANDROID_KEY_PASSWORD secrets (see docs/android.md). Without them the
# APK is signed with a throwaway debug key, which installs but cannot update a signed build.
on:
push:
branches: [main]
tags: ["v*"]
paths:
- "android/**"
- ".github/workflows/android.yml"
pull_request:
paths:
- "android/**"
- ".github/workflows/android.yml"
workflow_dispatch:
permissions:
contents: write
jobs:
apk:
name: build APK
runs-on: ubuntu-latest
defaults:
run:
working-directory: android
env:
# the secrets context cannot be read in a step's `if`; an env value can
KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v5
- name: Release keystore
if: env.KEYSTORE_B64 != ''
run: |
echo "$KEYSTORE_B64" | base64 -d > "$RUNNER_TEMP/release.jks"
{
echo "storeFile=$RUNNER_TEMP/release.jks"
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}"
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}"
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}"
} > keystore.properties
- name: Build
run: ./gradlew --no-daemon assembleRelease lint
- name: Name the APK
id: apk
run: |
version="$(sed -n 's/^ *versionName = "\(.*\)"/\1/p' app/build.gradle.kts)"
out="openmuse-${version}.apk"
cp app/build/outputs/apk/release/app-release.apk "$out"
# a second copy under a fixed name, so /releases/latest/download/openmuse.apk always works
cp "$out" openmuse.apk
echo "path=android/$out" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v7
with:
name: openmuse-apk
path: ${{ steps.apk.outputs.path }}
if-no-files-found: error
- name: Tag matches the app version
if: startsWith(github.ref, 'refs/tags/v')
run: |
tag="${GITHUB_REF_NAME#v}"
if [ "$tag" != "${{ steps.apk.outputs.version }}" ]; then
echo "tag v$tag does not match android versionName ${{ steps.apk.outputs.version }}"; exit 1
fi
# Only an APK signed with the release key goes on a release: a debug-signed one would
# install, but could never be updated by (or update) a properly signed build. Without
# the secrets the APK is a workflow artifact and the maintainer attaches the one built
# with the key kept outside the repository (docs/android.md).
- name: Attach to the release
if: startsWith(github.ref, 'refs/tags/v') && env.KEYSTORE_B64 != ''
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.apk.outputs.path }}
android/openmuse.apk
generate_release_notes: false