-
Notifications
You must be signed in to change notification settings - Fork 3
67 lines (57 loc) · 2.28 KB
/
Copy pathrelease.yml
File metadata and controls
67 lines (57 loc) · 2.28 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
name: Release
# Builds a signed release APK and attaches it to a GitHub Release whenever a version
# tag (e.g. v0.1.0) is pushed. Obtainium watches this repo's Releases and picks up the APK.
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Full history so the versionCode (git commit count) is correct — a shallow
# clone would report a commit count of 1 for every release.
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Decode release keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: echo "$KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/release.jks"
- name: Derive version from tag
id: version
run: |
# The pushed tag (e.g. v0.2.0) is the source of truth. versionName is the tag without its
# leading "v" so the APK's embedded version equals the release tag — this is what stops
# Obtainium from showing a permanent phantom update. versionCode is the commit count:
# strictly increasing, so Android always accepts the update as newer.
echo "name=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
echo "code=$(git rev-list --count HEAD)" >> "$GITHUB_OUTPUT"
- name: Build signed release APK
env:
KEYSTORE_FILE: ${{ runner.temp }}/release.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: >-
./gradlew :app:assembleRelease
-PappVersionName=${{ steps.version.outputs.name }}
-PappVersionCode=${{ steps.version.outputs.code }}
- name: Stage APK
run: |
mkdir -p dist
cp app/build/outputs/apk/release/app-release.apk "dist/light-keyboard-${GITHUB_REF_NAME}.apk"
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: dist/light-keyboard-*.apk
generate_release_notes: true