-
Notifications
You must be signed in to change notification settings - Fork 20
124 lines (103 loc) · 3.58 KB
/
build-signed-bundle.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Build Signed Bundle
on:
# Enables this workflow to be called from other workflows
workflow_call:
jobs:
build-and-sign-bundle:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: >
${{ runner.os }}-gradle-
${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Download Google Service JSON from GitHub artifacts
uses: actions/download-artifact@v4
with:
name: google_service_json
path: ./app
- name: Update dependencies
run: ./gradlew dependencies
# - name: Run Unit tests
# run: ./gradlew test
- name: Create Keystore Properties
run: |
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > \
${{ github.workspace }}/keystore.properties
- name: Check Keystore Properties file is created
run: |
if [ -f ./keystore.properties ]; then
echo "keystore.properties exists."
else
echo "keystore.properties does not exist." >&2
exit 1
fi
continue-on-error: false
- name: Check Keystore Properties contain required variables
run: |
required_vars=\
("KSTOREPWD" "KEYSTORE_ALIAS" "KEYPWD" "KEYSTORE_SECRET")
missing_vars=()
for var in "${required_vars[@]}"; do
if ! grep -q "^$var=" ./keystore.properties; then
missing_vars+=("$var")
fi
done
if [ ${#missing_vars[@]} -ne 0 ]; then
echo "Missing variables in keystore.properties: ${missing_vars[*]}"
exit 1
else
echo "All required variables are present in keystore.properties."
fi
shell: bash
- name: Decode Release Key
run: |
. './keystore.properties' &&
echo "$KEYSTORE_SECRET" > ./app/release.asc &&
gpg -d \
--passphrase "$KEYSTORE_SECRET_PASSPHRASE" \
--batch ./app/release.asc > ./app/release.jks &&
rm ./app/release.asc
continue-on-error: false
- name: Check Release Key is created
run: |
if [ -f ./app/release.jks ]; then
echo "Release key exists."
else
echo "Release key does not exist." >&2
exit 1
fi
continue-on-error: false
- name: Build Signed Bundle (AAB)
# run: ./gradlew clean bundleRelease --stacktrace --no-build-cache
run: |
./gradlew clean bundleProductionRelease \
--stacktrace \
--no-build-cache
- name: Remove Release Key
run: rm ./app/release.jks
- name: Upload AAB to GitHub Artifacts
uses: actions/upload-artifact@v4
with:
name: bundles
path: ./app/build/outputs/bundle/*/*-release.aab
- name: Check Build Status = ${{ job.status }}
run: echo "Build status report=${{ job.status }}."