Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github): action #12

Merged
merged 18 commits into from
Mar 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/build_apk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build APK

on:
pull_request:
# push:
# branches:
# - master
# - feat/add-release-apk-building

jobs:
build_release_apk:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.PUBLIVERSIONER_ID }}
private-key: ${{ secrets.PUBLIVERSIONER_SECRET }}

- name: Checkout repository
uses: actions/checkout@v4

- name: Get current version from source
env:
FILE_PATH: "version.properties"
id: version_source
run: |
current_version=$(awk -F"=" '/VERSION_NAME/ {print $2}' "$FILE_PATH")
echo "version=$current_version" >> $GITHUB_OUTPUT

- name: Decode and create google-services.json
run: |
mkdir -p app/src/prod/release
echo "$GOOGLE_SERVICES_JSON" | base64 -d > app/src/prod/release/google-services.json
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_FILE_AS_BASE64 }}

- name: Decode Keystore
run: |
echo "$KEYSTORE_AS_BASE64" | base64 --decode > app/keystore.jks
env:
KEYSTORE_AS_BASE64: ${{ secrets.GOOGLE_PLAY_SIGNING_KEY_FILE_AS_BASE64 }}

- name: Set up JDK 20
uses: actions/setup-java@v4
with:
java-version: "20"
distribution: "zulu"

- name: Build Release APK
run: ./gradlew assembleProdRelease
env:
SIGNING_STORE_FILE: ${{ github.workspace }}/app/keystore.jks
SIGNING_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}

- name: Prepare release directory
run: |
mkdir -p release
cp app/build/outputs/apk/prod/release/app-prod-release.apk release/

- name: Create release
env:
TAG: ${{ steps.version_source.outputs.version }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh release create "v$TAG" ./release/app-prod-release.apk \
--title=$TAG \
--generate-notes

# - name: Add release APK to git
# run: |
# git add release/app-prod-release.apk
#
# - name: Commit and push changes
# uses: planetscale/ghcommit-action@v0.1.44
# with:
# commit_message: "chore: add release APK"
# branch: ${{ github.ref }}
# file_pattern: "release/*"
# repo: ${{ github.repository }}

10 changes: 6 additions & 4 deletions buildConfig/src/main/kotlin/AppBuildConfig.kt
Original file line number Diff line number Diff line change
@@ -112,10 +112,12 @@ class AppBuildConfig : Plugin<Project> {

signingConfigs {
create(RELEASE_CONFIG) {
storeFile = File(localProperties.getProperty(RELEASE_STORE_FILE))
storePassword = localProperties.getProperty(RELEASE_STORE_PASSWORD)
keyAlias = localProperties.getProperty(RELEASE_KEY_ALIAS)
keyPassword = localProperties.getProperty(RELEASE_KEY_PASSWORD)
storeFile = File(
localProperties.getProperty(RELEASE_STORE_FILE) ?: System.getenv("SIGNING_STORE_FILE")
)
storePassword = localProperties.getProperty(RELEASE_STORE_PASSWORD) ?: System.getenv("SIGNING_STORE_PASSWORD")
keyAlias = localProperties.getProperty(RELEASE_KEY_ALIAS) ?: System.getenv("SIGNING_KEY_ALIAS")
keyPassword = localProperties.getProperty(RELEASE_KEY_PASSWORD) ?: System.getenv("SIGNING_KEY_PASSWORD")
}
create(DEBUG_CONFIG) {
}