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 2, 2024
1 parent 881e260 commit c60d19e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
67 changes: 67 additions & 0 deletions .github/workflows/brand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build & Publish Other brands

on:
workflow_dispatch: # run manually
inputs:
brand:
description: 'The brand to build: TennisPadel/Tabletennis/Badminton/Racketlon'
default: "TennisPadel"
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest

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 ${{ inputs.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
signedFn=${unsignedFn/release-unsigned/release-signed}
${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: "${{ steps.extract_version.outputs.version }}"
artifacts: ./build/outputs/apk/*/release/*-*-release-signed.apk
generateReleaseNotes: false
6 changes: 5 additions & 1 deletion change.R.package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ else
echo "Could not determine package from ${brandMfFile}"
exit
fi
if [[ $(echo "$brandPkg" | wc -l) -gt 1 ]]; then
echo "Invalid multilined package $brandPkg derived from ${brandMfFile}"
exit
fi
read -t $defaultTimeout -p "New package ${brandPkg}"
fi

Expand Down Expand Up @@ -123,7 +127,7 @@ if ! grep -E -q "${tobranded}.*SportType" com/doubleyellow/scoreboard/Brand.java
exit 1
fi

# derive current package by looking for .R reference in Brand.java
# derive current package by looking for .R reference in ScoreBoard.java
pkgFrom=$(grep -E 'import[ ]+.*\.R;' com/doubleyellow/scoreboard/main/ScoreBoard.java | perl -ne 's~import\s+([\w\.]+)\.R;~\1~; print')
read -t $defaultTimeout -p "From package ${pkgFrom}"
if [[ -z "${pkgFrom}" ]]; then
Expand Down

0 comments on commit c60d19e

Please sign in to comment.