Skip to content

Commit 77b538b

Browse files
committed
feat: add GitHub Actions workflow for building and releasing APKs
1 parent 92e0f84 commit 77b538b

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build Release APKs
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-release:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/[email protected]
13+
14+
- name: Extract version from libs.versions.toml
15+
id: version
16+
run: |
17+
VERSION=$(grep 'versionName = ' gradle/libs.versions.toml | sed 's/versionName = "\(.*\)"/\1/')
18+
VERSION_CODE=$(grep 'versionCode = ' gradle/libs.versions.toml | sed 's/versionCode = "\(.*\)"/\1/')
19+
echo "name=$VERSION" >> $GITHUB_OUTPUT
20+
echo "code=$VERSION_CODE" >> $GITHUB_OUTPUT
21+
echo "Building version: $VERSION (code: $VERSION_CODE)"
22+
23+
- name: Set up JDK 17
24+
uses: actions/[email protected]
25+
with:
26+
distribution: 'adopt'
27+
java-version: '17'
28+
29+
- name: Grant execute permissions for gradlew
30+
run: chmod +x ./gradlew
31+
32+
- name: Decode Keystore
33+
env:
34+
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
35+
if: ${{ env.KEYSTORE_BASE64 != '' }}
36+
run: |
37+
mkdir -p app/keystore
38+
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/keystore/release.keystore
39+
echo "keystore=keystore/release.keystore" > app/keystore/signing.properties
40+
echo "keystore.alias=${{ secrets.KEYSTORE_ALIAS }}" >> app/keystore/signing.properties
41+
echo "keystore.password=${{ secrets.KEYSTORE_PASSWORD }}" >> app/keystore/signing.properties
42+
43+
- name: Build Full Release APK
44+
run: ./gradlew :app:assembleFullRelease
45+
46+
- name: Build FOSS Release APK
47+
run: ./gradlew :app:assembleFossRelease
48+
49+
- name: Rename APKs
50+
run: |
51+
VERSION="${{ steps.version.outputs.name }}"
52+
mkdir -p release-apks
53+
54+
# Full Release
55+
if [ -f app/build/outputs/apk/full/release/app-full-release.apk ]; then
56+
cp app/build/outputs/apk/full/release/app-full-release.apk release-apks/pdai-full-release-${VERSION}.apk
57+
fi
58+
59+
# FOSS Release
60+
if [ -f app/build/outputs/apk/foss/release/app-foss-release.apk ]; then
61+
cp app/build/outputs/apk/foss/release/app-foss-release.apk release-apks/pdai-foss-release-${VERSION}.apk
62+
fi
63+
64+
- name: Upload Release APKs
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: pdai-release-${{ steps.version.outputs.name }}
68+
path: release-apks/*.apk
69+
retention-days: 90

0 commit comments

Comments
 (0)