Skip to content

Commit 71ea387

Browse files
feat(github): action (#12)
1 parent fafafb4 commit 71ea387

File tree

2 files changed

+89
-4
lines changed

2 files changed

+89
-4
lines changed

.github/workflows/build_apk.yaml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build APK
2+
3+
on:
4+
pull_request:
5+
# push:
6+
# branches:
7+
# - master
8+
# - feat/add-release-apk-building
9+
10+
jobs:
11+
build_release_apk:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/create-github-app-token@v1
15+
id: app-token
16+
with:
17+
app-id: ${{ vars.PUBLIVERSIONER_ID }}
18+
private-key: ${{ secrets.PUBLIVERSIONER_SECRET }}
19+
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Get current version from source
24+
env:
25+
FILE_PATH: "version.properties"
26+
id: version_source
27+
run: |
28+
current_version=$(awk -F"=" '/VERSION_NAME/ {print $2}' "$FILE_PATH")
29+
echo "version=$current_version" >> $GITHUB_OUTPUT
30+
31+
- name: Decode and create google-services.json
32+
run: |
33+
mkdir -p app/src/prod/release
34+
echo "$GOOGLE_SERVICES_JSON" | base64 -d > app/src/prod/release/google-services.json
35+
env:
36+
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_FILE_AS_BASE64 }}
37+
38+
- name: Decode Keystore
39+
run: |
40+
echo "$KEYSTORE_AS_BASE64" | base64 --decode > app/keystore.jks
41+
env:
42+
KEYSTORE_AS_BASE64: ${{ secrets.GOOGLE_PLAY_SIGNING_KEY_FILE_AS_BASE64 }}
43+
44+
- name: Set up JDK 20
45+
uses: actions/setup-java@v4
46+
with:
47+
java-version: "20"
48+
distribution: "zulu"
49+
50+
- name: Build Release APK
51+
run: ./gradlew assembleProdRelease
52+
env:
53+
SIGNING_STORE_FILE: ${{ github.workspace }}/app/keystore.jks
54+
SIGNING_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
55+
SIGNING_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
56+
SIGNING_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
57+
58+
- name: Prepare release directory
59+
run: |
60+
mkdir -p release
61+
cp app/build/outputs/apk/prod/release/app-prod-release.apk release/
62+
63+
- name: Create release
64+
env:
65+
TAG: ${{ steps.version_source.outputs.version }}
66+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
67+
run: |
68+
gh release create "v$TAG" ./release/app-prod-release.apk \
69+
--title=$TAG \
70+
--generate-notes
71+
72+
# - name: Add release APK to git
73+
# run: |
74+
# git add release/app-prod-release.apk
75+
#
76+
# - name: Commit and push changes
77+
# uses: planetscale/ghcommit-action@v0.1.44
78+
# with:
79+
# commit_message: "chore: add release APK"
80+
# branch: ${{ github.ref }}
81+
# file_pattern: "release/*"
82+
# repo: ${{ github.repository }}
83+

buildConfig/src/main/kotlin/AppBuildConfig.kt

+6-4
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ class AppBuildConfig : Plugin<Project> {
112112

113113
signingConfigs {
114114
create(RELEASE_CONFIG) {
115-
storeFile = File(localProperties.getProperty(RELEASE_STORE_FILE))
116-
storePassword = localProperties.getProperty(RELEASE_STORE_PASSWORD)
117-
keyAlias = localProperties.getProperty(RELEASE_KEY_ALIAS)
118-
keyPassword = localProperties.getProperty(RELEASE_KEY_PASSWORD)
115+
storeFile = File(
116+
localProperties.getProperty(RELEASE_STORE_FILE) ?: System.getenv("SIGNING_STORE_FILE")
117+
)
118+
storePassword = localProperties.getProperty(RELEASE_STORE_PASSWORD) ?: System.getenv("SIGNING_STORE_PASSWORD")
119+
keyAlias = localProperties.getProperty(RELEASE_KEY_ALIAS) ?: System.getenv("SIGNING_KEY_ALIAS")
120+
keyPassword = localProperties.getProperty(RELEASE_KEY_PASSWORD) ?: System.getenv("SIGNING_KEY_PASSWORD")
119121
}
120122
create(DEBUG_CONFIG) {
121123
}

0 commit comments

Comments
 (0)