-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (84 loc) · 3.7 KB
/
build.yml
File metadata and controls
99 lines (84 loc) · 3.7 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
name: Build APK
on:
push:
branches: [main, master]
tags: ['v*']
pull_request:
branches: [main, master]
workflow_dispatch:
inputs:
build_type:
description: 'Build type'
required: true
default: 'debug'
type: choice
options:
- debug
- release
- both
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ensure JDK 17 is available
run: |
set -euxo pipefail
if java -version 2>&1 | grep -q 'version "17\.'; then
java -version
exit 0
fi
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" >> "$GITHUB_ENV"
echo "/usr/lib/jvm/java-17-openjdk-amd64/bin" >> "$GITHUB_PATH"
java -version
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
# ── Debug build ──────────────────────────────────────────────────
- name: Build debug APK
if: github.event_name != 'workflow_dispatch' || github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == 'both'
run: ./gradlew assembleDebug --no-daemon
- name: Upload debug APK
if: github.event_name != 'workflow_dispatch' || github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == 'both'
uses: actions/upload-artifact@v4
with:
name: app-debug
path: app/build/outputs/apk/debug/app-debug.apk
# ── Release build (tags or manual trigger, signed if secrets configured) ────
- name: Decode keystore
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both') && env.KEYSTORE_BASE64 != ''
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: echo "$KEYSTORE_BASE64" | base64 -d > release.keystore
- name: Create keystore.properties
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both') && env.KEYSTORE_BASE64 != ''
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
cat > keystore.properties <<EOF
storeFile=release.keystore
storePassword=$KEYSTORE_PASSWORD
keyAlias=$KEY_ALIAS
keyPassword=$KEY_PASSWORD
EOF
- name: Build release APK
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both'
run: ./gradlew assembleRelease --no-daemon
- name: Upload release APK
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both'
uses: actions/upload-artifact@v4
with:
name: app-release-unsigned
path: app/build/outputs/apk/release/app-release-unsigned.apk
- name: Upload signed release APK
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both') && env.KEYSTORE_BASE64 != ''
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
uses: actions/upload-artifact@v4
with:
name: app-release-signed
path: app/build/outputs/apk/release/app-release.apk