forked from ProtonVPN/android-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci-release.yml
301 lines (281 loc) · 9.57 KB
/
.gitlab-ci-release.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
include:
- component: gitlab.protontech.ch/proton/devops/cicd-components/tools/artifactlift/[email protected]
inputs:
destination-cluster: prod
destination-repository: vpn-releases
destination-directory: android/
artifact-list: "ProtonVPN.apk"
make release branch:
before_script:
- git fetch origin development
- if [[ -f /load-env.sh ]]; then source /load-env.sh; fi
stage: deploy
when: manual
tags:
- shared-medium
only:
- development
- /^hotfix/
except:
- schedules
needs: []
script:
- |
if [ -z "$RELEASE_NOTES" ]; then
echo "Variable: RELEASE_NOTES manual var is required to continue"
exit 1;
else
echo "Updated env for $RELEASE_NOTES"
fi
- git config user.email "$GIT_CI_EMAIL"
- git config user.name "$GIT_CI_USERNAME"
# Compute version code and name
- export VERSION_NAME=$(./gradlew -q getVersionName | tail -n 1)
- export VERSION_CODE=$(./gradlew -q getVersionCode | tail -n 1)
# Make new release branch and add guestholes
- git checkout -b release/${VERSION_NAME}
- ./gradlew :app:prepareGuestHoleServers
- git add app/src/main/assets/GuestHoleServers.json
- git commit -m "Update guesthole servers"
# Add f-droid metadata
- echo -e "What's new\n${RELEASE_NOTES}" > metadata/en-US/changelogs/${VERSION_CODE}.txt
- echo -e "versionName=${VERSION_NAME}\nversionCode=${VERSION_CODE}" > metadata/version_fdroid.txt
- git add -- ./metadata
- git commit -m "Add fdroid metadata"
# Add remote with oauth and push new branch
- git remote add self_origin "$OAUTH_SELF_URL"
- git tag -a ${VERSION_NAME} -m "${VERSION_NAME} release"
- git push self_origin ${VERSION_NAME}
- git push self_origin release/${VERSION_NAME}
## Rules are shared between build and corresponding sign job
## If the job can be triggered manually, allow_failure=true must be added to the build job
.amazon_build_rules: &amazon_build_rules
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH =~ /^release/
when: always
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: manual
.vanilla_build_rules: &vanilla_build_rules
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH =~ /^release/
when: always
.bundle_build_rules: &bundle_build_rules
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "development"
when: always
- if: $CI_COMMIT_BRANCH =~ /^release/
when: always
- if: $CI_COMMIT_BRANCH =~ /^hotfix/
when: always
.payments_black_build_rules: &payments_black_build_rules
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: manual
## Only place build jobs in gitlab-ci-release.yml file if artifacts needs to be signed with release key.
## For all other debug/release jobs, use different .yml
build amazon release:
stage: build
rules: *amazon_build_rules
allow_failure: true
tags:
- xlarge-k8s
script:
- >
./gradlew openvpn:assembleRelease \
assembleProductionVanillaAmazonRelease
artifacts:
expire_in: 3 week
paths:
- app/build/outputs/apk
build google play bundle:
stage: build
rules: *bundle_build_rules
tags:
- xlarge-k8s
script:
# Build openvpn first, otherwise ovpnassets are not copied to app's assets.
- >
./gradlew :openvpn:assembleRelease \
:app:bundleProductionGooglePlayStoreRelease
artifacts:
expire_in: 1 week
paths:
- app/build/outputs/
build vanilla release:
stage: build
rules: *vanilla_build_rules
tags:
- xlarge-k8s
script:
- ./gradlew openvpn:assembleRelease assembleProductionVanillaDirectRelease
artifacts:
expire_in: 3 week
paths:
- app/build/outputs/apk
build payments black google dev:
stage: build
rules: *payments_black_build_rules
allow_failure: true
tags:
- xlarge-k8s
script:
- >
./gradlew openvpn:assembleRelease \
assembleBlackGoogleDevRelease \
bundleBlackGoogleDevRelease
variables:
TEST_ENV_DOMAIN: "payments.proton.black"
after_script:
# Avoid build files clashing with the test ones.
- mkdir paymentsBlack
- mv app/build/outputs/apk/* paymentsBlack
- mv app/build/outputs/bundle/* paymentsBlack
artifacts:
expire_in: 1 week
paths:
- paymentsBlack
.sign_base:
extends: .artifact-signing
stage: deploy
variables:
ARTIFACT_SIGNATURE_KIND: android-app
ARTIFACT_SIGNATURE_PROFILE: android
ARTIFACT_SIGNATURE_REF_TYPE: protected-branch
ARTIFACT_SIGNATURE_DEST: signedArtifacts/
sign google bundle:
extends: .sign_base
rules: *bundle_build_rules
needs: ["build google play bundle", "export archive name"]
variables:
ARTIFACT_SIGNATURE_KIND: android-app-bundle
ARTIFACT_SIGNATURE_FILES: app/build/outputs/bundle/productionGooglePlayStoreRelease/${ARCHIVES_BASE_NAME}-production-google-playStore-release.aab
sign payments-black bundle:
extends: .sign_base
rules: *payments_black_build_rules
needs: ["build payments black google dev", "export archive name"]
variables:
ARTIFACT_SIGNATURE_KIND: android-app-bundle
ARTIFACT_SIGNATURE_FILES: paymentsBlack/blackGoogleDevRelease/${ARCHIVES_BASE_NAME}-black-google-dev-release.aab
sign amazon:
extends: .sign_base
rules: *amazon_build_rules
needs: ["build amazon release", "export archive name"]
variables:
ARTIFACT_SIGNATURE_KIND: android-package-kit
ARTIFACT_SIGNATURE_FILES: app/build/outputs/apk/productionVanillaAmazon/release/${ARCHIVES_BASE_NAME}-production-vanilla-amazon-release.apk
sign vanilla apk:
extends: .sign_base
rules: *vanilla_build_rules
needs: ["build vanilla release", "export archive name"]
variables:
ARTIFACT_SIGNATURE_KIND: android-package-kit
ARTIFACT_SIGNATURE_FILES: app/build/outputs/apk/productionVanillaDirect/release/${ARCHIVES_BASE_NAME}-production-vanilla-direct-release.apk
sync-app:
cache: {}
stage: mirror
only:
- /^release/
except:
- schedules
script:
- apt update && apt-get install -y connect-proxy
- git remote add public $PUBLIC_REPO_URL
- git checkout $CI_COMMIT_REF_NAME
# Push current branch to github
- git push public $CI_COMMIT_REF_NAME
# Push the latest tag we can find
- git push public "$(git describe --abbrev=0)"
# Point github master to latest release branch
- git checkout -b master
- git push public master -f
publish-apk-internal:
stage: publish
tags:
- xlarge-k8s
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "development"
when: always
needs:
- job: sign google bundle
# Make sure tests pass before publishing. The dependency is on coverage report to avoid listing
# all test jobs here.
- job: coverage report
artifacts: false
script:
- ./gradlew generateReleaseNotesForPublishing
- ./gradlew publishProductionGooglePlayStoreBundle --artifact-dir signedArtifacts/
- ./gradlew notifyPublishOnSlack
publish-github:
stage: publish
dependencies: ["sign vanilla apk", "export archive name", "sync-app"]
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH =~ /^release/
when: always
variables:
RELEASE_NOTES: "metadata/en-US/changelogs/${VERSION_CODE}.txt"
GH_TOKEN: "${GITHUB_CLI_TOKEN}"
OAUTH_URL: "https://oauth2:${GH_TOKEN}@github.com/ProtonVPN/android-app.git"
ARTIFACT_PATH: "signedArtifacts/${ARCHIVES_BASE_NAME}-production-vanilla-direct-release.apk"
ARTIFACT_DISPLAY_NAME: "ProtonVPN-${VERSION_NAME}.apk"
script:
# Verify that uploaded artifact is signed with prod key
- ./verify_apk_signature.sh "${ARTIFACT_PATH}"
- gh release delete $VERSION_NAME -y || true
- gh release create $VERSION_NAME "$ARTIFACT_PATH#$ARTIFACT_DISPLAY_NAME" --title $VERSION_NAME --notes-file "$RELEASE_NOTES" --repo "${OAUTH_URL}"
# DEVOPS-2680: Push to S3 instead of download repo
artifactlift-s3-upload-prod:
stage: publish
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH =~ /^release/
when: always
dependencies: ["sign vanilla apk", "export archive name"]
interruptible: false
before_script:
- export DIRNAME="$( date -I )"
- mkdir "${DIRNAME}" && cd "${DIRNAME}"
- mv "${ARTIFACT_PATH}" "${ARTIFACT_OUTPUT_NAME}"
variables:
ARTIFACT_PATH: "signedArtifacts/${ARCHIVES_BASE_NAME}-production-vanilla-direct-release.apk"
ARTIFACT_OUTPUT_NAME: "ProtonVPN.apk"
publish nexus:
stage: publish
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH =~ /^release/
when: always
- when: manual
tags:
- shared-medium
image: $CI_REGISTRY/tpe/test-scripts
allow_failure: true
dependencies:
- build google play dev (monitoring release)
before_script: []
script:
# Delete old assets
- /usr/local/bin/nexus/delete_asset_on_nexus.py
--repository $NEXUS_REPO
--group $NEXUS_GROUP
# Upload release build
- /usr/local/bin/nexus/upload_to_nexus.py
--path "app/build/outputs/apk/productionGoogleDev/release/ProtonVPN-*-production-google-dev-release.apk"
--repository $NEXUS_REPO
--group $NEXUS_GROUP
--filename "vpn-latest-stable-release.apk"
# Upload release test build
- /usr/local/bin/nexus/upload_to_nexus.py
--path "release_tests/build/outputs/apk/release/release_tests-release.apk"
--repository $NEXUS_REPO
--group $NEXUS_GROUP
--filename "vpn-latest-stable-release-test.apk"