Build & Publish Several brands OOO #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Publish Several brands | |
on: | |
workflow_dispatch: # run manually | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
brand: | |
- Badminton | |
- Racketlon | |
- Tabletennis | |
- TennisPadel | |
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: 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: 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 }}.${{ steps.extract_version.outputs.version }}} | |
${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: Wait a bit to ensure all matrix file go into same release | |
if: ${{ matrix.brand != 'Badminton' }} | |
run: | | |
set -x | |
if [ '${{ matrix.brand }}' != "Badminton" ]; then | |
read -p "wait to ensure repo exists created by Badminton part of matrix" -t 90 | |
fi | |
#- name: Create upload .apk to /releases (ncipollo) | |
# 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 | |
- name: Create upload .apk to /releases (softprops) | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true # Sets the release as a draft instead of publishing it, allowing you to make any edits needed before releasing | |
token: ${{ secrets.GH_ACCESS_TOKEN }} | |
tag_name: "Release.${{ steps.extract_version.outputs.version }}" | |
files: ./build/outputs/apk/*/release/*-*-release-signed.apk | |
generate_release_notes: false |