19
19
# Ignore any error to not stop the script
20
20
set +e
21
21
22
- printf " \n"
23
- printf " ================================================================================\n"
22
+ printf " \n================================================================================\n"
24
23
printf " | Welcome to the release script! |\n"
25
24
printf " ================================================================================\n"
26
25
27
- releaseScriptLocation=" ${RELEASE_SCRIPT_PATH} "
26
+ printf " Checking environment...\n"
27
+ envError=0
28
28
29
- if [[ -z " ${releaseScriptLocation} " ]]; then
30
- printf " Fatal: RELEASE_SCRIPT_PATH is not defined in the environment. Please set to the path of your local file 'releaseElement2.sh'.\n"
31
- exit 1
29
+ # Path of the key store (it's a file)
30
+ keyStorePath=" ${ELEMENT_KEYSTORE_PATH} "
31
+ if [[ -z " ${keyStorePath} " ]]; then
32
+ printf " Fatal: ELEMENT_KEYSTORE_PATH is not defined in the environment.\n"
33
+ envError=1
34
+ fi
35
+ # Keystore password
36
+ keyStorePassword=" ${ELEMENT_KEYSTORE_PASSWORD} "
37
+ if [[ -z " ${keyStorePassword} " ]]; then
38
+ printf " Fatal: ELEMENT_KEYSTORE_PASSWORD is not defined in the environment.\n"
39
+ envError=1
40
+ fi
41
+ # Key password
42
+ keyPassword=" ${ELEMENT_KEY_PASSWORD} "
43
+ if [[ -z " ${keyPassword} " ]]; then
44
+ printf " Fatal: ELEMENT_KEY_PASSWORD is not defined in the environment.\n"
45
+ envError=1
46
+ fi
47
+ # GitHub token
48
+ gitHubToken=" ${ELEMENT_GITHUB_TOKEN} "
49
+ if [[ -z " ${gitHubToken} " ]]; then
50
+ printf " Fatal: ELEMENT_GITHUB_TOKEN is not defined in the environment.\n"
51
+ envError=1
52
+ fi
53
+ # Android home
54
+ androidHome=" ${ANDROID_HOME} "
55
+ if [[ -z " ${androidHome} " ]]; then
56
+ printf " Fatal: ANDROID_HOME is not defined in the environment.\n"
57
+ envError=1
58
+ fi
59
+ # @elementbot:matrix.org matrix token / Not mandatory
60
+ elementBotToken=" ${ELEMENT_BOT_MATRIX_TOKEN} "
61
+ if [[ -z " ${elementBotToken} " ]]; then
62
+ printf " Warning: ELEMENT_BOT_MATRIX_TOKEN is not defined in the environment.\n"
32
63
fi
33
64
34
- releaseScriptFullPath=" ${releaseScriptLocation} /releaseElement2.sh"
35
-
36
- if [[ ! -f ${releaseScriptFullPath} ]]; then
37
- printf " Fatal: release script not found at ${releaseScriptFullPath} .\n"
65
+ if [ ${envError} == 1 ]; then
38
66
exit 1
39
67
fi
40
68
69
+ buildToolsVersion=" 30.0.2"
70
+ buildToolsPath=" ${androidHome} /build-tools/${buildToolsVersion} "
71
+
72
+ if [[ ! -d ${buildToolsPath} ]]; then
73
+ printf " Fatal: ${buildToolsPath} folder not found, ensure that you have installed the SDK version ${buildToolsVersion} .\n"
74
+ exit 1
75
+ fi
76
+
41
77
# Check if git flow is enabled
42
78
git flow config > /dev/null 2>&1
43
79
if [[ $? == 0 ]]
44
80
then
45
- printf " Git flow is initialized"
81
+ printf " Git flow is initialized\n "
46
82
else
47
83
printf " Git flow is not initialized. Initializing...\n"
48
84
# All default value, just set 'v' for tag prefix
49
85
git flow init -d -t ' v'
50
86
fi
51
87
88
+ printf " OK\n"
89
+
90
+ printf " \n================================================================================\n"
52
91
# Guessing version to propose a default version
53
92
versionMajorCandidate=` grep " ext.versionMajor" ./vector-app/build.gradle | cut -d " " -f3`
54
93
versionMinorCandidate=` grep " ext.versionMinor" ./vector-app/build.gradle | cut -d " " -f3`
55
94
versionPatchCandidate=` grep " ext.versionPatch" ./vector-app/build.gradle | cut -d " " -f3`
56
95
versionCandidate=" ${versionMajorCandidate} .${versionMinorCandidate} .${versionPatchCandidate} "
57
96
58
- printf " \n"
59
97
read -p " Please enter the release version (example: ${versionCandidate} ). Just press enter if ${versionCandidate} is correct. " version
60
98
version=${version:- ${versionCandidate} }
61
99
@@ -229,14 +267,89 @@ printf "Wait for the GitHub action https://github.com/vector-im/element-android/
229
267
read -p " After GHA is finished, please enter the artifact URL (for 'vector-gplay-release-unsigned'): " artifactUrl
230
268
231
269
printf " \n================================================================================\n"
232
- printf " Running the release script...\n"
233
- cd ${releaseScriptLocation}
234
- ${releaseScriptFullPath} " v${version} " ${artifactUrl}
235
- cd -
270
+ printf " Downloading the artifact...\n"
271
+
272
+ # Download files
273
+ targetPath=" ./tmp/Element/${version} "
274
+
275
+ # Ignore error
276
+ set +e
277
+
278
+ python3 ./tools/release/download_github_artifacts.py \
279
+ --token ${gitHubToken} \
280
+ --artifactUrl ${artifactUrl} \
281
+ --directory ${targetPath} \
282
+ --ignoreErrors
283
+
284
+ # Do not ignore error
285
+ set -e
286
+
287
+ printf " \n================================================================================\n"
288
+ printf " Unzipping the artifact...\n"
289
+
290
+ unzip ${targetPath} /vector-gplay-release-unsigned.zip -d ${targetPath}
291
+
292
+ # Flatten folder hierarchy
293
+ mv ${targetPath} /gplay/release/* ${targetPath}
294
+ rm -rf ${targetPath} /gplay
295
+
296
+ printf " \n================================================================================\n"
297
+ printf " Signing the APKs...\n"
298
+
299
+ cp ${targetPath} /vector-gplay-arm64-v8a-release-unsigned.apk \
300
+ ${targetPath} /vector-gplay-arm64-v8a-release-signed.apk
301
+ ./tools/release/sign_apk_unsafe.sh \
302
+ ${keyStorePath} \
303
+ ${targetPath} /vector-gplay-arm64-v8a-release-signed.apk \
304
+ ${keyStorePassword} \
305
+ ${keyPassword}
306
+
307
+ cp ${targetPath} /vector-gplay-armeabi-v7a-release-unsigned.apk \
308
+ ${targetPath} /vector-gplay-armeabi-v7a-release-signed.apk
309
+ ./tools/release/sign_apk_unsafe.sh \
310
+ ${keyStorePath} \
311
+ ${targetPath} /vector-gplay-armeabi-v7a-release-signed.apk \
312
+ ${keyStorePassword} \
313
+ ${keyPassword}
314
+
315
+ cp ${targetPath} /vector-gplay-x86-release-unsigned.apk \
316
+ ${targetPath} /vector-gplay-x86-release-signed.apk
317
+ ./tools/release/sign_apk_unsafe.sh \
318
+ ${keyStorePath} \
319
+ ${targetPath} /vector-gplay-x86-release-signed.apk \
320
+ ${keyStorePassword} \
321
+ ${keyPassword}
322
+
323
+ cp ${targetPath} /vector-gplay-x86_64-release-unsigned.apk \
324
+ ${targetPath} /vector-gplay-x86_64-release-signed.apk
325
+ ./tools/release/sign_apk_unsafe.sh \
326
+ ${keyStorePath} \
327
+ ${targetPath} /vector-gplay-x86_64-release-signed.apk \
328
+ ${keyStorePassword} \
329
+ ${keyPassword}
330
+
331
+ # Ref: https://docs.fastlane.tools/getting-started/android/beta-deployment/#uploading-your-app
332
+ # set SUPPLY_APK_PATHS="${targetPath}/vector-gplay-arm64-v8a-release-unsigned.apk,${targetPath}/vector-gplay-armeabi-v7a-release-unsigned.apk,${targetPath}/vector-gplay-x86-release-unsigned.apk,${targetPath}/vector-gplay-x86_64-release-unsigned.apk"
333
+ #
334
+ # ./fastlane beta
335
+
336
+ printf " \n================================================================================\n"
337
+ printf " Please check the information below:\n"
338
+
339
+ printf " File vector-gplay-arm64-v8a-release-signed.apk:\n"
340
+ ${buildToolsPath} /aapt dump badging ${targetPath} /vector-gplay-arm64-v8a-release-signed.apk | grep package
341
+ printf " File vector-gplay-armeabi-v7a-release-signed.apk:\n"
342
+ ${buildToolsPath} /aapt dump badging ${targetPath} /vector-gplay-armeabi-v7a-release-signed.apk | grep package
343
+ printf " File vector-gplay-x86-release-signed.apk:\n"
344
+ ${buildToolsPath} /aapt dump badging ${targetPath} /vector-gplay-x86-release-signed.apk | grep package
345
+ printf " File vector-gplay-x86_64-release-signed.apk:\n"
346
+ ${buildToolsPath} /aapt dump badging ${targetPath} /vector-gplay-x86_64-release-signed.apk | grep package
347
+
348
+ read -p " \nDoes it look correct? Press enter when it's done."
236
349
237
350
printf " \n================================================================================\n"
238
351
read -p " Installing apk on a real device, press enter when a real device is connected. "
239
- apkPath=" ${releaseScriptLocation} /Element/v ${version } /vector-gplay-arm64-v8a-release-signed.apk"
352
+ apkPath=" ${targetPath } /vector-gplay-arm64-v8a-release-signed.apk"
240
353
adb -d install ${apkPath}
241
354
242
355
read -p " Please run the APK on your phone to check that the upgrade went well (no init sync, etc.). Press enter when it's done."
@@ -250,9 +363,8 @@ printf "Message for the Android internal room:\n\n"
250
363
message=" @room Element Android ${version} is ready to be tested. You can get if from https://github.com/vector-im/element-android/releases/tag/v${version} . Please report any feedback here. Thanks!"
251
364
printf " ${message} \n\n"
252
365
253
- matrixOrgToken=" ${MATRIX_ORG_TOKEN} "
254
- if [[ -z " ${matrixOrgToken} " ]]; then
255
- read -p " MATRIX_ORG_TOKEN is not defined in the environment. Cannot send the message for you. Please send it manually, and press enter when it's done "
366
+ if [[ -z " ${elementBotToken} " ]]; then
367
+ read -p " ELEMENT_BOT_MATRIX_TOKEN is not defined in the environment. Cannot send the message for you. Please send it manually, and press enter when it's done "
256
368
else
257
369
read -p " Send this message to the room (yes/no) default to yes? " doSend
258
370
doSend=${doSend:- yes}
261
373
transactionId=` openssl rand -hex 16`
262
374
# Element Android internal
263
375
matrixRoomId=" !LiSLXinTDCsepePiYW:matrix.org"
264
- curl -X PUT --data $" {\" msgtype\" :\" m.text\" ,\" body\" :\" ${message} \" }" -H " Authorization: Bearer ${matrixOrgToken } " https://matrix-client.matrix.org/_matrix/client/r0/rooms/${matrixRoomId} /send/m.room.message/\$ local.${transactionId}
376
+ curl -X PUT --data $" {\" msgtype\" :\" m.text\" ,\" body\" :\" ${message} \" }" -H " Authorization: Bearer ${elementBotToken } " https://matrix-client.matrix.org/_matrix/client/r0/rooms/${matrixRoomId} /send/m.room.message/\$ local.${transactionId}
265
377
else
266
378
printf " Message not sent, please send it manually!\n"
267
379
fi
0 commit comments