Skip to content

Commit aa5db48

Browse files
committed
Add --upload flag to installer-downloader build script
This flag causes a signed build to be uploaded to app-build-linux
1 parent e5b0413 commit aa5db48

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

installer-downloader/build.sh

+59-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-"../target"}
2828
export CARGO_TARGET_DIR
2929

3030
# Temporary build directory
31-
BUILD_DIR="./build"
31+
BUILD_DIR="$SCRIPT_DIR/build"
3232
# Successfully built (and signed) artifacts
33-
DIST_DIR="../dist"
33+
DIST_DIR="$SCRIPT_DIR/../dist"
3434

3535
BUNDLE_NAME="MullvadVPNInstaller"
3636
BUNDLE_ID="net.mullvad.$BUNDLE_NAME"
@@ -45,6 +45,9 @@ mkdir -p "$DIST_DIR"
4545
# Whether to sign and notarized produced binaries
4646
SIGN="false"
4747

48+
# Whether to upload signed binaries
49+
UPLOAD="false"
50+
4851
# Temporary keychain to store the .p12 in.
4952
# This is automatically created/replaced when signing on macOS.
5053
SIGN_KEYCHAIN_PATH="$HOME/Library/Keychains/mv-metadata-keychain-db"
@@ -55,6 +58,9 @@ while [[ "$#" -gt 0 ]]; do
5558
--sign)
5659
SIGN="true"
5760
;;
61+
--upload)
62+
UPLOAD="true"
63+
;;
5864
*)
5965
log_error "Unknown parameter: $1"
6066
exit 1
@@ -63,6 +69,11 @@ while [[ "$#" -gt 0 ]]; do
6369
shift
6470
done
6571

72+
if [[ "$UPLOAD" == "true" && "$SIGN" != "true" ]]; then
73+
log_error "'--upload' requires '--sign' to be specified"
74+
exit 1
75+
fi
76+
6677
# Check that we have the correct environment set for signing
6778
function assert_can_sign {
6879
if [[ "$(uname -s)" == "Darwin" ]]; then
@@ -305,6 +316,46 @@ function dist_windows_app {
305316
mv "$BUILD_DIR/$FILENAME.exe" "$DIST_DIR/"
306317
}
307318

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+
308359
function main {
309360
if [[ "$SIGN" != "false" ]]; then
310361
assert_can_sign
@@ -327,6 +378,12 @@ function main {
327378
build_executable
328379
dist_windows_app
329380
fi
381+
382+
if [[ "$UPLOAD" == "true" ]]; then
383+
local version
384+
version=$(product_version)
385+
(cd "$DIST_DIR" && upload "$version") || return 1
386+
fi
330387
}
331388

332389
main

0 commit comments

Comments
 (0)