-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 3.33 KB
/
Copy pathrelease.yml
File metadata and controls
105 lines (89 loc) · 3.33 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: >
Release version (e.g., v1.2.3). Leave empty to auto-increment
the patch version from the latest git tag.
required: false
default: ""
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
INPUT_VERSION="${{ github.event.inputs.version }}"
if [ -n "$INPUT_VERSION" ]; then
if [[ "$INPUT_VERSION" != v* ]]; then
INPUT_VERSION="v${INPUT_VERSION}"
fi
VERSION="$INPUT_VERSION"
else
LATEST_TAG=$(git tag -l 'v*' | sort -V | tail -n 1)
if [ -z "$LATEST_TAG" ]; then
VERSION="v0.0.1"
else
VERSION_BODY="${LATEST_TAG#v}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_BODY"
PATCH=$((PATCH + 1))
VERSION="v${MAJOR}.${MINOR}.${PATCH}"
fi
fi
echo "Resolved version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v4
- name: Inject weather API key
run: echo "meteoblue_key=${{ secrets.METEOBLUE_KEY }}" >> gradle.properties
- name: Build release APK
run: ./gradlew assembleRelease
- name: Set up signing keystore
run: |
echo "${{ secrets.SIGNING_KEYSTORE_BASE64 }}" | base64 -d > "${{ runner.temp }}/release.keystore"
- name: Align and sign APK
id: sign
env:
SIGNING_KEYSTORE_PATH: ${{ runner.temp }}/release.keystore
SIGNING_KEYSTORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
VERSION: ${{ steps.version.outputs.version }}
run: |
BUILD_TOOLS_DIR=$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -n 1)
"$BUILD_TOOLS_DIR/zipalign" -v -p 4 \
app/build/outputs/apk/release/app-release-unsigned.apk \
app-release-aligned.apk
"$BUILD_TOOLS_DIR/apksigner" sign \
--ks "$SIGNING_KEYSTORE_PATH" \
--ks-pass "pass:$SIGNING_KEYSTORE_PASSWORD" \
--ks-key-alias "$SIGNING_KEY_ALIAS" \
--key-pass "pass:$SIGNING_KEY_PASSWORD" \
--out "aR2Launcher-${VERSION}.apk" \
app-release-aligned.apk
echo "apk_path=aR2Launcher-${VERSION}.apk" >> "$GITHUB_OUTPUT"
- name: Create and push tag
run: |
VERSION="${{ steps.version.outputs.version }}"
git config user.name "c0dev0id"
git config user.email "sh+git@codevoid.de"
git tag "$VERSION"
git push origin "$VERSION"
- name: Create GitHub release draft
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
draft: true
generate_release_notes: true
files: ${{ steps.sign.outputs.apk_path }}