-
Notifications
You must be signed in to change notification settings - Fork 4
93 lines (84 loc) · 3.34 KB
/
buildrelease.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#
# written in such a way that this exact same file can be created in .github/workflows in
# obbimi/Squore
# obbimi/TennisPadel
# obbimi/Tabletennis
# obbimi/Badminton etc to create obbimi/xxx/Release.###
#
# please note that all 4 secrets (GSM_API_KEY, KEYSTORE_BASE64, KEYSTORE_PASSWORD, GH_ACCESS_TOKEN) need to be present in EACH repo
#
name: Build APK & Create Release
on:
workflow_dispatch: # run manually
inputs:
release_in_draft:
description: Leave the release in draft
type: boolean
default: true
required: true
generateReleaseNotes:
description: Generate release notes for the release
type: boolean
default: false
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses:
actions/[email protected]
with:
java-version: 17
distribution: 'adopt'
- name: Checkout the code
uses: actions/[email protected]
with:
repository: obbimi/Squore # overwrite the default ${{ github.repository }}. Our java code/resources is always in the Squore repo
#ref: main
- name: Prepare for build
id: prepare_for_build
env:
GSM_API_KEY: ${{ secrets.GSM_API_KEY }}
run: |
set -x
# make support files executable
chmod +x ./gradlew ./build.gradle.adapt.for.github.workflow.sh ./change.R.package.sh
./build.gradle.adapt.for.github.workflow.sh ${GSM_API_KEY}
# adapt sources and res files to build different brand
brand=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
./change.R.package.sh ${brand}
# Extract the version from build.gradle
VERSION=$(grep 'def\s*versionCodeXXX' build.gradle | cut -d '=' -f 2 | 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: |
set -x
brand=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
#baseBrand=Squore
baseBrand=$brand
echo "${KEYSTORE_BASE64}" | base64 -d > apksign.keystore
androidhome="${ANDROID_HOME:-${ANDROID_SDK}}"
find . -name *.apk
for unsignedFn in build/outputs/apk/*/release/*.apk; do
unbrandedSignedFn=${unsignedFn/release-unsigned/release-signed}
signedFn=${unbrandedSignedFn/${baseBrand}/${brand}.${{ steps.prepare_for_build.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
find . -name *.apk
- name: Upload .apk to /releases
uses: ncipollo/release-action@v1
with:
draft: ${{ inputs.release_in_draft }} # Sets the release as a draft instead of publishing it, allowing you to make any edits needed before publishing
token: ${{ secrets.GH_ACCESS_TOKEN }}
tag: "${{ steps.prepare_for_build.outputs.version }}"
artifacts: ./build/outputs/apk/*/release/*-*-release-signed.apk
generateReleaseNotes: ${{ inputs.generateReleaseNotes }}
#make_latest: true