Skip to content

Commit ea4dd38

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

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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/checkout@v4.1.0
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/setup-java@v3.13.0
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+
if: ${{ secrets.KEYSTORE_BASE64 != '' }}
34+
run: |
35+
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/keystore/release.keystore
36+
echo "keystore=keystore/release.keystore" > app/keystore/signing.properties
37+
echo "keystore.alias=${{ secrets.KEYSTORE_ALIAS }}" >> app/keystore/signing.properties
38+
echo "keystore.password=${{ secrets.KEYSTORE_PASSWORD }}" >> app/keystore/signing.properties
39+
40+
- name: Build Full Release APK
41+
run: ./gradlew :app:assembleFullRelease
42+
43+
- name: Build FOSS Release APK
44+
run: ./gradlew :app:assembleFossRelease
45+
46+
- name: Rename APKs
47+
run: |
48+
VERSION="${{ steps.version.outputs.name }}"
49+
mkdir -p release-apks
50+
51+
# Full Release
52+
if [ -f app/build/outputs/apk/full/release/app-full-release.apk ]; then
53+
cp app/build/outputs/apk/full/release/app-full-release.apk release-apks/pdai-full-release-${VERSION}.apk
54+
fi
55+
56+
# FOSS Release
57+
if [ -f app/build/outputs/apk/foss/release/app-foss-release.apk ]; then
58+
cp app/build/outputs/apk/foss/release/app-foss-release.apk release-apks/pdai-foss-release-${VERSION}.apk
59+
fi
60+
61+
- name: Upload Release APKs
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: pdai-release-${{ steps.version.outputs.name }}
65+
path: release-apks/*.apk
66+
retention-days: 90
67+
68+
- name: Create Release Draft
69+
uses: softprops/action-gh-release@v1
70+
with:
71+
tag_name: ${{ steps.version.outputs.name }}
72+
name: PDAI v${{ steps.version.outputs.name }}
73+
draft: true
74+
files: release-apks/*.apk
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)