-
Notifications
You must be signed in to change notification settings - Fork 8
268 lines (229 loc) · 12.2 KB
/
Copy pathbuild-app.yaml
File metadata and controls
268 lines (229 loc) · 12.2 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
name: Tag and build release
env:
# The name of the main module repository
main_project_module: app
# The name in the Play Store
playstore_name: Soundscape
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
environment: development
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- name: Setup offline maps for tests
run: |
pwd
wget --no-verbose --show-progress --progress=dot:giga https://pub-0a3501283b024ab3bbfbb6d1e217f5d0.r2.dev/street-metadata/bristol-gb.pmtiles -O ${{ env.main_project_module }}/src/test/res/org/scottishtecharmy/soundscape/bristol-gb.pmtiles
wget --no-verbose --show-progress --progress=dot:giga https://pub-0a3501283b024ab3bbfbb6d1e217f5d0.r2.dev/street-metadata/glasgow-gb.pmtiles -O ${{ env.main_project_module }}/src/test/res/org/scottishtecharmy/soundscape/glasgow-gb.pmtiles
wget --no-verbose --show-progress --progress=dot:giga https://pub-0a3501283b024ab3bbfbb6d1e217f5d0.r2.dev/street-metadata/liverpool-gb.pmtiles -O ${{ env.main_project_module }}/src/test/res/org/scottishtecharmy/soundscape/liverpool-gb.pmtiles
wget --no-verbose --show-progress --progress=dot:giga https://pub-0a3501283b024ab3bbfbb6d1e217f5d0.r2.dev/manifest.geojson.gz -O ${{ env.main_project_module }}/src/test/res/org/scottishtecharmy/soundscape/manifest.geojson.gz
- name: Extract existing version code from build.gradle
id: current-version
run: |
# Get existing version code from build.gradle
version_code=$(grep "versionCode" app/build.gradle.kts | awk '{print $3}' | tr -d '\n')
version_name=$(grep "versionName =" app/build.gradle.kts | awk '{print $3}' | tr -d '\"\"')
major_version=$(echo $version_name | awk -F \. {'print $1'})
minor_version=$(echo $version_name | awk -F \. {'print $2'})
build_version=$(echo $version_name | awk -F \. {'print $3'})
# Increment existing version code and build version by 1
version_code=$((version_code + 1))
build_version=$((build_version + 1))
# The major and minor versions can be bumped manually by editing
# app/build.gradle.kts. When doing this, reset the build version
# to zero.
# Set output variables for later use
echo "VERSION_CODE=$version_code" >> $GITHUB_OUTPUT
echo "VERSION_NAME=$major_version.$minor_version.$build_version" >> $GITHUB_OUTPUT
- name: Increase version code and change version name
env:
VERSION_CODE: ${{ steps.current-version.outputs.VERSION_CODE }}
VERSION_NAME: ${{ steps.current-version.outputs.VERSION_NAME }}
run: |
# Update build.gradle with new version code and name
echo "$VERSION_CODE - $env.VERSION_NAME"
sed -i "s/versionCode = [0-9]\+/versionCode = $VERSION_CODE/g" app/build.gradle.kts
sed -i "s/versionName = \"[^\"]*\"/versionName = \"$VERSION_NAME\"/g" app/build.gradle.kts
- name: Bump version from "${{ steps.current-version.outputs.VERSION_NAME }}"
env:
VERSION_CODE: ${{ steps.current-version.outputs.VERSION_CODE }}
VERSION_NAME: ${{ steps.current-version.outputs.VERSION_NAME }}
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "Bump version to ${{ env.VERSION_NAME }}, version code ${{ env.VERSION_CODE }}"
tagging_message: "soundscape-${{ env.VERSION_NAME }}"
# Set version
- name: Set 'git describe --tags' as version
id: get-version
run: echo "VERSION=$(git describe --tags)" >> $GITHUB_OUTPUT
- name: Setup tile and search providers
env:
TILE_PROVIDER_API_KEY: ${{ secrets.TILE_PROVIDER_API_KEY }}
TILE_PROVIDER_URL: ${{ secrets.TILE_PROVIDER_URL }}
SEARCH_PROVIDER_API_KEY: ${{ secrets.SEARCH_PROVIDER_API_KEY }}
SEARCH_PROVIDER_URL: ${{ secrets.SEARCH_PROVIDER_URL }}
EXTRACT_PROVIDER_URL: ${{ secrets.EXTRACT_PROVIDER_URL }}
run: |
echo tileProviderUrl="$TILE_PROVIDER_URL" > local.properties
echo tileProviderApiKey="$TILE_PROVIDER_API_KEY" >> local.properties
echo searchProviderUrl="$SEARCH_PROVIDER_URL" >> local.properties
echo searchProviderApiKey="$SEARCH_PROVIDER_API_KEY" >> local.properties
echo extractProviderUrl="$EXTRACT_PROVIDER_URL" >> local.properties
- name: Decode Google services
env:
ENCODED_STRING: ${{ secrets.GOOGLE_SERVICES }}
GOOGLE_SERVICES_PATH: ${{ secrets.GOOGLE_SERVICES_PATH }}
run: |
echo $ENCODED_STRING > google-services-b64.txt
base64 -d google-services-b64.txt > ${{ env.main_project_module }}/$GOOGLE_SERVICES_PATH
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Set Up JDK
uses: actions/setup-java@v5
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '19'
- name: Run lint over the repo
run: ./gradlew lint
# Setup release build keys
- name: Decode Keystore
env:
ENCODED_STRING: ${{ secrets.SIGNING_KEY_STORE_BASE64 }}
SIGNING_KEY_STORE_PATH: ${{ secrets.SIGNING_KEY_STORE_PATH }}
run: |
echo $ENCODED_STRING > keystore-b64.txt
base64 -d keystore-b64.txt > ${{ env.main_project_module }}/$SIGNING_KEY_STORE_PATH
# Run Tests Build
- name: Run gradle tests
run: ./gradlew test
#
# This is fragile with small changes causing it to run out of memory. Comment out until Google fixes it
#
# - name: Generate test screenshots
# run: |
# ./gradlew updateDebugScreenshotTest
# ./categorise.sh app/src/screenshotTestDebug/reference/org/scottishtecharmy/soundscape/ThemeTestClass/
# cd app/src/screenshotTestDebug/reference/org/scottishtecharmy/soundscape/ThemeTestClass/
# zip -r screenshots.zip .
#
# - name: Upload screenshots
# uses: actions/upload-artifact@v6
# with:
# name: test-screenshots
# path: app/src/screenshotTestDebug/reference/org/scottishtecharmy/soundscape/ThemeTestClass/screenshots.zip
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Build instrumentation tests to generate screenshots for documentation
id: documentation-screenshot-tests
uses: reactivecircus/android-emulator-runner@v2
continue-on-error: true
with:
api-level: 34
target: default
arch: x86_64
profile: pixel_7
script: |
mkdir -p docs/documentationScreens
adb logcat -c # clear logs
adb shell settings put global policy_control immersive.status=* # Disable status bar at top of screen
touch app/emulator.log # create log file
chmod 777 app/emulator.log # allow writing to log file
adb logcat >> app/emulator.log & # pipe all logcat messages into log file as a background process
# Run only the DocumentationScreens tests
./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=org.scottishtecharmy.soundscape.DocumentationScreens
# And then get the resulting screenshots from the emulator
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/homeScreen.png docs/documentationScreens/homeScreen.png
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/homeScreenWithRoute.png docs/documentationScreens/homeScreenWithRoute.png
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/routeDetails.png docs/documentationScreens/routeDetails.png
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Pictures/screenshots/routeEdit.png docs/documentationScreens/routeEdit.png
adb pull /storage/emulated/0/Android/data/org.scottishtecharmy.soundscape/files/Documents/help docs/users/
mv docs/users/help/* docs/users/
- name: ImageMagick Action to trim off status and navigation bars from screenshots
uses: jruipinto/ImageMagick-action@v1
with:
command: mogrify -path docs/documentationScreens -crop 1080x2130+0+140 docs/documentationScreens/*.*
- name: Commit new screenshots
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "New documentation screenshots"
file_pattern: 'docs/documentationScreens/*.png docs/users/help-*.md'
# Run Build Project
- name: Build gradle project
env:
SIGNING_KEY_STORE_PATH: ${{ secrets.SIGNING_KEY_STORE_PATH }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
run: |
./gradlew build
# Create APK Release
- name: Build apk release project (APK)
env:
SIGNING_KEY_STORE_PATH: ${{ secrets.SIGNING_KEY_STORE_PATH }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
run: ./gradlew assemble
# Create Bundle AAB Release
# Noted for main module build [main_project_module]:bundleRelease
- name: Build app bundle release (AAB)
env:
SIGNING_KEY_STORE_PATH: ${{ secrets.SIGNING_KEY_STORE_PATH }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
run: ./gradlew ${{ env.main_project_module }}:bundleRelease
# Upload Artifact Build
# Noted For Output [main_project_module]/build/outputs/apk/releaseTest/
- name: Upload APK ReleaseTest
uses: actions/upload-artifact@v6
with:
name: releaseTest-apk
path: |
${{ env.main_project_module }}/build/outputs/apk/releaseTest/
# Noted For Output [main_project_module]/build/outputs/apk/release/
- name: Upload APK Release
uses: actions/upload-artifact@v6
with:
name: release-apk
path: |
${{ env.main_project_module }}/build/outputs/apk/release/
# Noted For Output [main_project_module]/build/outputs/bundle/release/
- name: Upload AAB (App Bundle) Release
uses: actions/upload-artifact@v6
with:
name: release-aab
path: |
${{ env.main_project_module }}/build/outputs/bundle/release/
${{ env.main_project_module }}/build/outputs/mapping/release/
firebase:
name: Run UI tests with Firebase Test Lab
needs: build
environment: development
runs-on: ubuntu-latest
steps:
- name: Download app releaseTest APK
uses: actions/download-artifact@v8
with:
name: releaseTest-apk
- name: Auth
uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.GCLOUD_CREDENTIALS_JSON }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v3
- name: Set current project
run: gcloud config set project ${{ secrets.FIREBASE_PROJECT_ID }}
- name: Run Robo test in Firebase Test Lab
run: gcloud firebase test android run --type robo --app=app-releaseTest.apk --timeout=300s --device model=shiba,version=34,locale=en,orientation=portrait