Skip to content

Commit dc115fb

Browse files
committed
ci: add GitHub Actions workflows to build release APKs #22
1 parent f79b6a1 commit dc115fb

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
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 and Release Android APK
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build_apk:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
submodules: 'true'
15+
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
cache: gradle
22+
23+
- name: Decode keystore
24+
env:
25+
ENCODED_STRING: ${{ secrets.KEYSTORE_BASE_64 }}
26+
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
27+
RELEASE_KEYSTORE_ALIAS: ${{ secrets.RELEASE_KEYSTORE_ALIAS }}
28+
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
29+
run: |
30+
echo $ENCODED_STRING > keystore-b64.txt
31+
base64 -d keystore-b64.txt > keystore.jks
32+
- name: Grant execute permission for gradlew
33+
run: chmod +x gradlew
34+
35+
- name: Build with Gradle
36+
env:
37+
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
38+
RELEASE_KEYSTORE_ALIAS: ${{ secrets.RELEASE_KEYSTORE_ALIAS }}
39+
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
40+
run: ./gradlew build
41+
42+
- name: Build APK
43+
env:
44+
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
45+
RELEASE_KEYSTORE_ALIAS: ${{ secrets.RELEASE_KEYSTORE_ALIAS }}
46+
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
47+
run: ./gradlew assembleRelease --stacktrace
48+
49+
- name: Create a release
50+
uses: actions/create-release@v1
51+
id: create_release
52+
with:
53+
tag_name: ${{ github.ref }}
54+
release_name: ${{ github.ref }}
55+
draft: false
56+
prerelease: false
57+
body_path: CHANGELOG.md
58+
env:
59+
GITHUB_TOKEN: ${{ github.token }}
60+
61+
- name: Upload APK to release
62+
uses: actions/upload-release-asset@v1
63+
env:
64+
GITHUB_TOKEN: ${{ github.token }}
65+
with:
66+
upload_url: ${{ steps.create_release.outputs.upload_url }}
67+
asset_path: app/build/outputs/apk/release/app-release.apk
68+
asset_name: Android-Doc-QA_${{ github.ref_name }}.apk
69+
asset_content_type: application/vnd.android.package-archive

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Initial release of `Android-Doc-QA`
2+
- The app allows users to ask questions on PDF/DOCX documents and get natural-language answers.

app/build.gradle.kts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@ android {
1818
minSdk = 26
1919
targetSdk = 34
2020
versionCode = 1
21-
versionName = "1.0"
21+
versionName = "0.0.1"
2222

2323
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2424
vectorDrawables {
2525
useSupportLibrary = true
2626
}
2727
}
28-
28+
signingConfigs {
29+
create("release") {
30+
storeFile = file("../keystore.jks")
31+
storePassword = System.getenv("RELEASE_KEYSTORE_PASSWORD")
32+
keyAlias = System.getenv("RELEASE_KEYSTORE_ALIAS")
33+
keyPassword = System.getenv("RELEASE_KEY_PASSWORD")
34+
}
35+
}
2936
buildTypes {
3037
// Add the field 'geminiKey' in the build config
3138
// See https://stackoverflow.com/a/60474096/13546426
@@ -36,6 +43,7 @@ android {
3643
"proguard-rules.pro",
3744
)
3845
buildConfigField("String", "geminiKey", geminiKey)
46+
signingConfig = signingConfigs.getByName("release")
3947
}
4048
debug {
4149
buildConfigField("String", "geminiKey", geminiKey)

0 commit comments

Comments
 (0)