-
-
Notifications
You must be signed in to change notification settings - Fork 50
323 lines (277 loc) · 14 KB
/
alpha.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# Copyright (c) 2022 Sharezone UG (haftungsbeschränkt)
# Licensed under the EUPL-1.2-or-later.
#
# You may obtain a copy of the Licence at:
# https://joinup.ec.europa.eu/software/page/eupl
#
# SPDX-License-Identifier: EUPL-1.2
name: alpha
concurrency:
# Our iOS builds require unique build numbers. Therefore, we should never
# build a new version while a build is already running. This is why we use the
# branch name as a concurrency group. This way, we can only build one version
# per branch at the same time.
group: app-release
on:
push:
branches:
- main
paths:
# When we change the Flutter version, we need to trigger this workflow.
- ".fvm/fvm_config.json"
# We only build and deploy a new version, when a user relevant files
# changed.
- "app/**"
- "lib/**"
# We trigger also this workflow, if this workflow is changed, so that new
# changes will be applied.
- ".github/workflows/alpha.yml"
# The following paths are excluded from the above paths. It's important to
# list the paths at the end of the file, so that the exclude paths are
# applied.
#
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-paths.
- "!**/*.md"
- "!**/*.mdx"
- "!**/*.gitignore"
# Test files are not relevant for the alpha program.
- "!**/test/**"
- "!**/test_driver/**"
- "!**/integration_test/**"
# Example files are not relevant for the alpha program.
- "!**/example/**"
- "!**/analysis_options.yaml"
- "!**/dart_test.yaml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
CI_CD_DART_SCRIPTS_PACKAGE_PATH: "tools/sz_repo_cli/"
# Set permissions to none.
#
# Using the broad default permissions is considered a bad security practice
# and would cause alerts from our scanning tools.
permissions: {}
jobs:
deploy-alpha-web-app:
name: "deploy-alpha-web-app-${{ matrix.environment.flavor }}"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
environment:
- flavor: prod
serviceAccountSecret: FIREBASE_HOSTING_PROD_KEY
- flavor: dev
serviceAccountSecret: FIREBASE_SERVICE_ACCOUNT_SHAREZONE_DEBUG
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- name: Set Flutter version from FVM config file to environment variables
id: fvm-config-action
uses: kuhnroyal/flutter-fvm-config-action@34c3905bc939a4ff9d9cb07d5a977493fa73b2aa
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
- name: Activate sz_repo_cli package
run: flutter pub global activate --source path "$CI_CD_DART_SCRIPTS_PACKAGE_PATH"
# So we can just use "sz COMMAND" instead of "dart ../path/to/script.dart ..."
- run: echo $(realpath ./bin) >> $GITHUB_PATH
- name: Install Firebase CLI
run: npm i -g [email protected]
- name: Build and deploy web-app
env:
FIREBASE_HOSTING_KEY: ${{ secrets[matrix.environment.serviceAccountSecret] }}
run: |
echo $FIREBASE_HOSTING_KEY > firebase-hosting-key.json
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/firebase-hosting-key.json
sz deploy app web \
--stage alpha \
--message "Workflow $GITHUB_JOB, commit $GITHUB_SHA" \
--flavor ${{ matrix.environment.flavor }}
deploy-alpha-android-app:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
# Our Android configurations require Java 17.
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
distribution: "oracle"
java-version: "17"
- name: Set Flutter version from FVM config file to environment variables
id: fvm-config-action
uses: kuhnroyal/flutter-fvm-config-action@34c3905bc939a4ff9d9cb07d5a977493fa73b2aa
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
- name: Install Sharezone Repo CLI
run: |
flutter pub global activate --source path "$CI_CD_DART_SCRIPTS_PACKAGE_PATH"
echo $(realpath ./bin) >> $GITHUB_PATH
- name: Install Codemagic CLI Tools
run: pip3 install codemagic-cli-tools==0.50.7
- name: Setup signing
working-directory: app/android
env:
KEYSTORE_STRING: ${{ secrets.SHAREZONE_ANDROID_APP_KEYSTORE_STRING }}
KEY_PASSWORD: ${{ secrets.SHAREZONE_ANDROID_APP_KEY_PASSWORD }}
KEY_ALIAS: ${{ secrets.SHAREZONE_ANDROID_APP_KEY_ALIAS }}
STORE_PASSWORD: ${{ secrets.SHAREZONE_ANDROID_APP_STORE_PASSWORD }}
run: |
echo $KEYSTORE_STRING | base64 -di > app/key.jks
echo "storePassword=$STORE_PASSWORD" >> key.properties
echo "keyPassword=$KEY_PASSWORD" >> key.properties
echo "keyAlias=$KEY_ALIAS" >> key.properties
echo "storeFile=key.jks" >> key.properties
- name: Build Android
working-directory: app
env:
# The iOS and App Store environment variables are used by the Codemagic
# CLI tool. It's important to use the same names as the CLI tool
# expects.
#
# From https://appstoreconnect.apple.com/apps/1434868489/
IOS_APP_ID: 1434868489
# The following secrets are used by the Codemagic CLI tool. It's important
# to use the same names as the CLI tool expects.
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_KEY_IDENTIFIER }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_PRIVATE_KEY }}
run: |
# Even when Firebase Distribution does not require a new build number,
# we still bump it to identify the different builds easier. Therefore,
# users can easier say in which version of the app they encountered a
# bug.
#
# We use the latest build number from the App Store Connect API, because
# this build number is always the the newest one and there is no easy
# API to get the latest build number from Firebase Distribution and the
# build number from App Store Connect is the same as the one from
# Firebase Distribution.
#
# Bumping the build number for Firebase Distribution has no effect on
# the PlayStore build number.
LATEST_BUILD_NUMBER=$(app-store-connect get-latest-build-number $IOS_APP_ID --platform IOS | head -2 | tail -1)
BUMPED_BUILD_NUMBER=$(expr $LATEST_BUILD_NUMBER + 1)
# We are publishing APKs instead of App Bundles to Firebase Distribution
# because they easier to install. App Bundles are installed via the
# PlayStore which resulted in problems in the past.
sz build app android \
--stage alpha \
--build-number $BUMPED_BUILD_NUMBER \
--output-type apk
- name: Install Firebase CLI
run: sudo npm i -g [email protected]
- name: Publish to Firebase Distribution
working-directory: app
env:
FIREBASE_DISTRIBUTION_KEY: ${{ secrets.GCP_SA_FIREBASE_DISTRIBUTION_PROD_KEY }}
run: |
# Set up credentials for Firebase Distribution
echo $FIREBASE_DISTRIBUTION_KEY > sharezone-prod-key.json
export GOOGLE_APPLICATION_CREDENTIALS=sharezone-prod-key.json
# Because we are publishing every commit a new alpha version, we are
# able to use the last commit message (title and description) as release
# note for the alpha builds. This is not the most user friendly note but
# it's better than nothing.
export LAST_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
firebase appdistribution:distribute build/app/outputs/flutter-apk/app-prod-release.apk \
--app 1:730263787697:android:f0a3b3b856fd1383 \
--groups "alpha" \
--release-notes "$LAST_COMMIT_MESSAGE"
deploy-alpha-ios-app:
runs-on: macos-13
timeout-minutes: 120
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- name: Install Codemagic CLI Tools
run: pip3 install codemagic-cli-tools==0.50.7
- name: Set Flutter version from FVM config file to environment variables
id: fvm-config-action
uses: kuhnroyal/flutter-fvm-config-action@34c3905bc939a4ff9d9cb07d5a977493fa73b2aa
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
- name: Activate sz_repo_cli package
run: flutter pub global activate --source path "$CI_CD_DART_SCRIPTS_PACKAGE_PATH"
# So we can just use "sz COMMAND" instead of "dart ../path/to/script.dart ..."
- run: echo $(pwd)/bin >> $GITHUB_PATH
- name: Deploy iOS alpha to TestFlight
env:
# The following secrets are used by the Codemagic CLI tool. It's important
# to use the same names as the CLI tool expects.
CERTIFICATE_PRIVATE_KEY: ${{ secrets.SHAREZONE_CERTIFICATE_PRIVATE_KEY }}
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_KEY_IDENTIFIER }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_PRIVATE_KEY }}
run: |
# Because we are publishing every commit a new alpha version, we are
# able to use the last commit message (title and description) as release
# note for the alpha builds. This is not the most user friendly note but
# it's better than nothing.
#
# The "sed 's/[<>]//g'" part is to remove the "<" and ">" characters
# because the App Store doesn't allow them.
export LAST_COMMIT_MESSAGE=$(git log -1 --pretty=%B | sed 's/[<>]//g')
# The App Store Connect API only allows a maximum of 4000 characters for
# the release notes. So we need to truncate the commit message if it's
# longer than 4000 characters.
export SHORT_LAST_COMMIT_MESSAGE=${LAST_COMMIT_MESSAGE:0:4000}
# Note that we use '--whats-new "$SHORT_LAST_COMMIT_MESSAGE"' instead
# of '--whats-new="$SHORT_LAST_COMMIT_MESSAGE"' to correctly pass the
# multiline string stored in the $SHORT_LAST_COMMIT_MESSAGE variable
# as a single argument. Including "=" can cause issues with argument
# parsing in the shell, potentially leading to incorrect handling of
# the multiline string argument.
sz deploy app ios \
--stage alpha \
--whats-new "$SHORT_LAST_COMMIT_MESSAGE" \
--export-options-plist=$HOME/export_options.plist
deploy-alpha-macos-app:
runs-on: macos-13
timeout-minutes: 60
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- name: Install Codemagic CLI Tools
run: pip3 install codemagic-cli-tools==0.50.7
- name: Set Flutter version from FVM config file to environment variables
id: fvm-config-action
uses: kuhnroyal/flutter-fvm-config-action@34c3905bc939a4ff9d9cb07d5a977493fa73b2aa
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
- name: Install Sharezone Repo CLI
run: |
flutter pub global activate --source path "$CI_CD_DART_SCRIPTS_PACKAGE_PATH"
echo $(realpath ./bin) >> $GITHUB_PATH
# We need to install the FlutterFire CLI because we have Build Phases in
# XCode configured which are using the FlutterFire CLI. Without the CLI,
# the build would fail.
- name: Install FlutterFire CLI
run: flutter pub global activate flutterfire_cli 0.3.0-dev.19
- name: Deploy macOS to TestFlight
env:
# The following secrets are used by the Codemagic CLI tool. It's important
# to use the same names as the CLI tool expects.
CERTIFICATE_PRIVATE_KEY: ${{ secrets.SHAREZONE_CERTIFICATE_PRIVATE_KEY }}
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_KEY_IDENTIFIER }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_PRIVATE_KEY }}
run: |
# Because we are publishing every commit a new alpha version, we are
# able to use the last commit message (title and description) as release
# note for the alpha builds. This is not the most user friendly note but
# it's better than nothing.
#
# The "sed 's/[<>]//g'" part is to remove the "<" and ">" characters
# because the App Store doesn't allow them.
LAST_COMMIT_MESSAGE=$(git log -1 --pretty=%B | sed 's/[<>]//g')
# The App Store Connect API only allows a maximum of 4000 characters for
# the release notes. So we need to truncate the commit message if it's
# longer than 4000 characters.
SHORT_LAST_COMMIT_MESSAGE=${LAST_COMMIT_MESSAGE:0:4000}
sz deploy app macos \
--stage alpha \
--whats-new "$SHORT_LAST_COMMIT_MESSAGE"