Skip to content

Commit 8906955

Browse files
committed
ci: add GitHub Actions build workflow
2 parents 1df5bca + c2d6b0c commit 8906955

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Android CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
env:
15+
SIGNING_KEYSTORE: ${{ secrets.SIGNING_KEYSTORE }}
16+
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
17+
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
18+
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
19+
RELEASED_REPO_TOKEN: ${{ secrets.RELEASED_REPO_TOKEN }}
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup JDK 17
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: zulu
29+
java-version: 17
30+
31+
- name: Setup Gradle
32+
uses: gradle/actions/setup-gradle@v4
33+
34+
- name: Decode Keystore (if provided)
35+
run: |
36+
if [ -n "${SIGNING_KEYSTORE}" ]; then
37+
echo "Decoding provided keystore..."
38+
echo "${SIGNING_KEYSTORE}" | base64 --decode > app/release.keystore
39+
else
40+
echo "No keystore provided — skipping signing setup."
41+
fi
42+
43+
- name: Setup Gradle Signing Config (if keystore provided)
44+
run: |
45+
if [ -n "${SIGNING_KEYSTORE}" ]; then
46+
echo "Adding signing config to gradle.properties..."
47+
echo -e "\nSTORE_FILE=release.keystore" >> gradle.properties
48+
echo "STORE_PASSWORD=${STORE_PASSWORD}" >> gradle.properties
49+
echo "KEY_ALIAS=${KEY_ALIAS}" >> gradle.properties
50+
echo "KEY_PASSWORD=${KEY_PASSWORD}" >> gradle.properties
51+
else
52+
echo "Skipping signing config (no keystore)."
53+
fi
54+
55+
- name: Build APK (Release or Debug)
56+
run: |
57+
if [ -n "${SIGNING_KEYSTORE}" ]; then
58+
echo "Building signed release APK..."
59+
./gradlew assembleRelease --stacktrace
60+
else
61+
echo "Building debug APK..."
62+
./gradlew assembleDebug --stacktrace
63+
fi
64+
65+
- name: Build App Bundle (only if keystore provided)
66+
run: |
67+
if [ -n "${SIGNING_KEYSTORE}" ]; then
68+
echo "Building release App Bundle (.aab)..."
69+
./gradlew bundleRelease --stacktrace
70+
else
71+
echo "Skipping bundle build (no signing info)."
72+
fi
73+
74+
- name: Upload APK
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: app-apk
78+
path: |
79+
app/build/outputs/apk/release/app-release.apk
80+
app/build/outputs/apk/debug/app-debug.apk
81+
if-no-files-found: warn
82+
compression-level: 0
83+
84+
- name: Upload Release App Bundle
85+
if: env.SIGNING_KEYSTORE != ''
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: app-release.aab
89+
path: app/build/outputs/bundle/release/app-release.aab
90+
if-no-files-found: ignore
91+
compression-level: 0
92+
93+
- name: Push APK to released repo (if token provided)
94+
run: |
95+
if [ -n "${RELEASED_REPO_TOKEN}" ]; then
96+
echo "Pushing release APK to external repo..."
97+
git config --global user.name "github-actions[bot]"
98+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
99+
100+
git clone https://x-access-token:${RELEASED_REPO_TOKEN}@github.com/mrepol742/released.git
101+
cd released
102+
mkdir -p android
103+
104+
cp ../app/build/outputs/apk/release/output-metadata.json android/webvium-launcher-metadata.json || echo "No metadata found — skipping copy."
105+
cp ../app/build/outputs/apk/release/app-release.apk android/webvium-launcher.apk || echo "No release APK found — skipping copy."
106+
107+
git add android/webvium-launcher-metadata.json || true
108+
git add android/webvium-launcher.apk || true
109+
git commit -m "chore: update webvium-launcher.apk ($(date +'%Y-%m-%d %H:%M:%S'))" || echo "Nothing to commit."
110+
git push origin master || echo "No changes to push."
111+
else
112+
echo "No RELEASED_REPO_TOKEN found — skipping repo upload."
113+
fi

0 commit comments

Comments
 (0)