workflow to automatically deploy apks #21
Workflow file for this run
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
# OLD, not longer needed?. We use buildrelease.yml and deploy.yml | |
name: Build & Publish Release APK | |
on: | |
workflow_dispatch: # run manually | |
push: | |
tags: | |
- 'Release*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# - name: get the date | |
# id: date | |
# run: | | |
# NOW=$(date +"%Y%m%d") | |
# echo "now=${NOW}" >> $GITHUB_OUTPUT | |
- 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 Squore | |
- 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 'def\s*versionCodeXXX' build.gradle | cut -d '=' -f 2 | tr -d ' ') | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Upload artifact for phone | |
uses: actions/[email protected] | |
with: | |
name: Squore.phone.${{ steps.extract_version.outputs.version }}.apk | |
path: build/outputs/apk/phoneTabletPost23/release/Squore-phoneTabletPost23-release-signed.apk | |
- name: Upload artifact for wearOs | |
uses: actions/[email protected] | |
with: | |
name: Squore.wearOs.${{ steps.extract_version.outputs.version }}.apk | |
path: build/outputs/apk/wearOs/release/Squore-wearOs-release-signed.apk | |
- name: Create upload .apk to /releases | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GH_ACCESS_TOKEN }} | |
tag: "${{ steps.extract_version.outputs.version }}" | |
#prerelease: "${{ steps.extract_version.outputs.beta }}" | |
#draft: "${{ inputs.draft }}" | |
artifacts: ./build/outputs/apk/*/release/*-*-release-signed.apk | |
generateReleaseNotes: false | |
#- name: Releasing using Hub | |
# uses: sangatdesai/release-apk@main | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
# APP_FOLDER: app |