@@ -28,9 +28,9 @@ CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-"../target"}
28
28
export CARGO_TARGET_DIR
29
29
30
30
# Temporary build directory
31
- BUILD_DIR=" . /build"
31
+ BUILD_DIR=" $SCRIPT_DIR /build"
32
32
# Successfully built (and signed) artifacts
33
- DIST_DIR=" ../dist"
33
+ DIST_DIR=" $SCRIPT_DIR / ../dist"
34
34
35
35
BUNDLE_NAME=" MullvadVPNInstaller"
36
36
BUNDLE_ID=" net.mullvad.$BUNDLE_NAME "
@@ -45,6 +45,9 @@ mkdir -p "$DIST_DIR"
45
45
# Whether to sign and notarized produced binaries
46
46
SIGN=" false"
47
47
48
+ # Whether to upload signed binaries
49
+ UPLOAD=" false"
50
+
48
51
# Temporary keychain to store the .p12 in.
49
52
# This is automatically created/replaced when signing on macOS.
50
53
SIGN_KEYCHAIN_PATH=" $HOME /Library/Keychains/mv-metadata-keychain-db"
@@ -55,6 +58,9 @@ while [[ "$#" -gt 0 ]]; do
55
58
--sign)
56
59
SIGN=" true"
57
60
;;
61
+ --upload)
62
+ UPLOAD=" true"
63
+ ;;
58
64
* )
59
65
log_error " Unknown parameter: $1 "
60
66
exit 1
@@ -63,6 +69,11 @@ while [[ "$#" -gt 0 ]]; do
63
69
shift
64
70
done
65
71
72
+ if [[ " $UPLOAD " == " true" && " $SIGN " != " true" ]]; then
73
+ log_error " '--upload' requires '--sign' to be specified"
74
+ exit 1
75
+ fi
76
+
66
77
# Check that we have the correct environment set for signing
67
78
function assert_can_sign {
68
79
if [[ " $( uname -s) " == " Darwin" ]]; then
@@ -305,6 +316,46 @@ function dist_windows_app {
305
316
mv " $BUILD_DIR /$FILENAME .exe" " $DIST_DIR /"
306
317
}
307
318
319
+ # Upload whatever matches the first argument to the Linux build server
320
+ # Arguments:
321
+ # - local file
322
+ # - version
323
+ function upload_sftp {
324
+ local local_path=$1
325
+ local version=$2
326
+ echo " Uploading \" $local_path \" to app-build-linux:upload/installer-downloader/$version "
327
+ sftp app-build-linux << EOF
328
+ mkdir upload/installer-downloader
329
+ mkdir upload/installer-downloader/$version
330
+ chmod 770 upload/installer-downloader
331
+ chmod 770 upload/installer-downloader/$version
332
+ cd upload/installer-downloader/$version
333
+ put "$local_path "
334
+ bye
335
+ EOF
336
+ }
337
+
338
+ # Upload latest build and checksum in the dist directory to Linux build server
339
+ # The artifacts MUST have been built already
340
+ # The working directory MUST be $DIST_DIR
341
+ #
342
+ # Arguments:
343
+ # - version
344
+ function upload {
345
+ local version=$1
346
+ local files=( " $FILENAME ." * )
347
+
348
+ local checksums_path
349
+ checksums_path=" desktop-downloader+$( hostname) +$version .sha256"
350
+
351
+ sha256sum " ${files[@]} " > " $checksums_path "
352
+
353
+ for file in " ${files[@]} " ; do
354
+ upload_sftp " $file " " $version " || return 1
355
+ done
356
+ upload_sftp " $checksums_path " " $version " || return 1
357
+ }
358
+
308
359
function main {
309
360
if [[ " $SIGN " != " false" ]]; then
310
361
assert_can_sign
@@ -327,6 +378,12 @@ function main {
327
378
build_executable
328
379
dist_windows_app
329
380
fi
381
+
382
+ if [[ " $UPLOAD " == " true" ]]; then
383
+ local version
384
+ version=$( product_version)
385
+ (cd " $DIST_DIR " && upload " $version " ) || return 1
386
+ fi
330
387
}
331
388
332
389
main
0 commit comments