-
Notifications
You must be signed in to change notification settings - Fork 2
/
publish_dist.sh
executable file
·41 lines (33 loc) · 1.21 KB
/
publish_dist.sh
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
#!/usr/bin/env bash
#
# Uploads dist packages to testing/ on Chevah's server, then shows final links.
# To be used through GitHub actions.
set -o nounset
set -o errexit
set -o pipefail
# This is also defined in build.conf.
DIST_DIR="dist"
dest_server="bin.chevah.com"
dest_user="github-upload"
root_link="https://$dest_server:20443/testing"
# The build/publish_dist_sftp_batch file is generated by the build process.
# The private key comes from GitHub Secrets through the configured workflow.
sftp_opts=(-b build/publish_dist_sftp_batch -o IdentityFile=priv_key \
-o StrictHostKeyChecking=yes)
OS="$(uname -s)"
case "$OS" in
MINGW*|MSYS*)
# To use an RSA key, upstream SFTP is installed through GitHub actions.
sftp_cmd="/c/Progra~1/OpenSSH-Win64/sftp.exe"
;;
*)
sftp_cmd="sftp"
;;
esac
"$sftp_cmd" "${sftp_opts[@]}" "$dest_user"@"$dest_server"
# As dist/ is rebuilt on every build, it should only have 1 sub-dir with 1 pkg.
upload_dir="$(cd "$DIST_DIR" && ls -1)"
pkg_name="$(cd "$DIST_DIR"/"$upload_dir" && ls -1)"
# Local hierarchy matches the remote one.
echo "Package $pkg_name uploaded to: $root_link/$upload_dir/"
echo "Direct link: $root_link/$upload_dir/$pkg_name"