Skip to content

Commit

Permalink
workflow to automatically build apk
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeveid committed Aug 3, 2024
1 parent 19de517 commit 32d8c2c
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/brands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build & Publish Several brands

on:
workflow_dispatch: # run manually

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
brand:
- TennisPadel
- Badminton
- Tabletennis

steps:
- name: Setup Java JDK
uses:
actions/[email protected]
with:
java-version: 11
distribution: 'adopt'

- name: Checkout the code
uses: actions/[email protected]

- name: Make pipeline script files executable where needed
run: chmod +x ./gradlew ./build.gradle.adapt.for.github.workflow.sh ./change.R.package.sh

- name: Adapt build.gradle and google-services.json by means of script
env:
GSM_API_KEY: ${{ secrets.GSM_API_KEY }}
run: ./build.gradle.adapt.for.github.workflow.sh ${GSM_API_KEY}

- name: adapt sources and res files to build different brand
run: ./change.R.package.sh ${{ matrix.brand }}

- name: Build unsigned release .apk files
run: ./gradlew build

- name: Sign .apk files
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
run: |
echo "${KEYSTORE_BASE64}" | base64 -d > apksign.keystore
set -x
androidhome="${ANDROID_HOME:-${ANDROID_SDK}}"
for unsignedFn in build/outputs/apk/*/release/*.apk; do
unbrandedSignedFn=${unsignedFn/release-unsigned/release-signed}
signedFn=${unbrandedSignedFn/Squore/${{ matrix.brand }}}
${androidhome}/build-tools/$(ls ${androidhome}/build-tools/ | tail -1)/apksigner sign --ks apksign.keystore --ks-pass pass:"${KEYSTORE_PASSWORD}" --out "${signedFn}" "${unsignedFn}"
done
rm -v apksign.keystore
- name: Extract the version from build.gradle
id: extract_version
run: |
VERSION=$(grep '^\s*versionCode' build.gradle | cut -d '+' -f 2 | sort -u | tr -d ' ')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create upload .apk to /releases
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
tag: "Release.${{ steps.extract_version.outputs.version }}"
artifacts: ./build/outputs/apk/*/release/*-*-release-signed.apk
generateReleaseNotes: false
draft: true # Sets the release as a draft instead of publishing it, allowing you to make any edits needed before releasing
make_latest: false

0 comments on commit 32d8c2c

Please sign in to comment.