-
Notifications
You must be signed in to change notification settings - Fork 4
113 lines (97 loc) · 3.96 KB
/
build.yml
File metadata and controls
113 lines (97 loc) · 3.96 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
name: Android CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
SIGNING_KEYSTORE: ${{ secrets.SIGNING_KEYSTORE }}
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
RELEASED_REPO_TOKEN: ${{ secrets.RELEASED_REPO_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Decode Keystore (if provided)
run: |
if [ -n "${SIGNING_KEYSTORE}" ]; then
echo "Decoding provided keystore..."
echo "${SIGNING_KEYSTORE}" | base64 --decode > app/release.keystore
else
echo "No keystore provided — skipping signing setup."
fi
- name: Setup Gradle Signing Config (if keystore provided)
run: |
if [ -n "${SIGNING_KEYSTORE}" ]; then
echo "Adding signing config to gradle.properties..."
echo -e "\nSTORE_FILE=release.keystore" >> gradle.properties
echo "STORE_PASSWORD=${STORE_PASSWORD}" >> gradle.properties
echo "KEY_ALIAS=${KEY_ALIAS}" >> gradle.properties
echo "KEY_PASSWORD=${KEY_PASSWORD}" >> gradle.properties
else
echo "Skipping signing config (no keystore)."
fi
- name: Build APK (Release or Debug)
run: |
if [ -n "${SIGNING_KEYSTORE}" ]; then
echo "Building signed release APK..."
./gradlew assembleRelease --stacktrace
else
echo "Building debug APK..."
./gradlew assembleDebug --stacktrace
fi
- name: Build App Bundle (only if keystore provided)
run: |
if [ -n "${SIGNING_KEYSTORE}" ]; then
echo "Building release App Bundle (.aab)..."
./gradlew bundleRelease --stacktrace
else
echo "Skipping bundle build (no signing info)."
fi
- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: app-apk
path: |
app/build/outputs/apk/release/app-release.apk
app/build/outputs/apk/debug/app-debug.apk
if-no-files-found: warn
compression-level: 0
- name: Upload Release App Bundle
if: env.SIGNING_KEYSTORE != ''
uses: actions/upload-artifact@v4
with:
name: app-release.aab
path: app/build/outputs/bundle/release/app-release.aab
if-no-files-found: ignore
compression-level: 0
- name: Push APK to released repo (if token provided)
run: |
if [ -n "${RELEASED_REPO_TOKEN}" ]; then
echo "Pushing release APK to external repo..."
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git clone https://x-access-token:${RELEASED_REPO_TOKEN}@github.com/mrepol742/released.git
cd released
mkdir -p android
cp ../app/build/outputs/apk/release/output-metadata.json android/melvinjones-app-metadata.json || echo "No metadata found — skipping copy."
cp ../app/build/outputs/apk/release/app-release.apk android/melvinjones-app.apk || echo "No release APK found — skipping copy."
git add android/melvinjones-app-metadata.json || true
git add android/melvinjones-app.apk || true
git commit -m "chore: update melvinjones-app.apk ($(date +'%Y-%m-%d %H:%M:%S'))" || echo "Nothing to commit."
git push origin master || echo "No changes to push."
else
echo "No RELEASED_REPO_TOKEN found — skipping repo upload."
fi