-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathupload.sh
More file actions
executable file
·91 lines (72 loc) · 3.37 KB
/
upload.sh
File metadata and controls
executable file
·91 lines (72 loc) · 3.37 KB
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
#!/bin/bash
set -euxo pipefail
[ -z "${STORAGE_ACCOUNT_SUBSCRIPTION:-}" ] && echo "STORAGE_ACCOUNT_SUBSCRIPTION must be specified" && exit 1
[ -z "${STORAGE_ACCOUNT_RESOURCE_GROUP:-}" ] && echo "STORAGE_ACCOUNT_RESOURCE_GROUP must be specified" && exit 1
[ -z "${STORAGE_ACCOUNT_NAME:-}" ] && echo "STORAGE_ACCOUNT_NAME must be specified" && exit 1
[ -z "${VERSION:-}" ] && echo "VERSION must be specified" && exit 1
OS="${OS:-linux}"
display_download_url() {
local relpath="$1"
web_endpoint=$(az storage account show -g $STORAGE_ACCOUNT_RESOURCE_GROUP -n $STORAGE_ACCOUNT_NAME --subscription $STORAGE_ACCOUNT_SUBSCRIPTION --query primaryEndpoints.web | tr -d \")
echo "client download URL: ${web_endpoint}${relpath}"
}
build_and_upload_linux_amd64() {
make build OS=linux ARCH=amd64 VERSION="${VERSION}"
if [ ! -f "bin/aks-secure-tls-bootstrap-client-amd64" ]; then
echo "could not find client binary aks-secure-tls-bootstrap-client-amd64 for upload within bin/"
exit 1
fi
pushd "bin/"
client_path="aks-secure-tls-bootstrap-client"
mv "${client_path}-amd64" "$client_path"
tar_path="linux-amd64.tar.gz"
tar -czvf "$tar_path" "$client_path"
az storage blob upload -f "$tar_path" --auth-mode login --blob-url "https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net/\$web/client/linux/amd64/${VERSION}.tar.gz"
popd
rm -rf "bin/"
display_download_url "client/linux/amd64/${VERSION}.tar.gz"
}
build_and_upload_linux_arm64() {
make build OS=linux ARCH=arm64 VERSION="${VERSION}"
if [ ! -f "bin/aks-secure-tls-bootstrap-client-arm64" ]; then
echo "could not find client binary aks-secure-tls-bootstrap-client-arm64 for upload within bin/"
exit 1
fi
pushd "bin/"
client_path="aks-secure-tls-bootstrap-client"
mv "${client_path}-arm64" "$client_path"
tar_path="linux-arm64.tar.gz"
tar -czvf "$tar_path" "$client_path"
az storage blob upload -f "$tar_path" --auth-mode login --blob-url "https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net/\$web/client/linux/arm64/${VERSION}.tar.gz"
popd
rm -rf "bin/"
display_download_url "client/linux/arm64/${VERSION}.tar.gz"
}
build_and_upload_windows_amd64() {
make build OS=windows ARCH=amd64 EXTENSION=.exe VERSION="${VERSION}"
if [ ! -f "bin/aks-secure-tls-bootstrap-client-amd64.exe" ]; then
echo "could not find client binary aks-secure-tls-bootstrap-client-amd64.exe for upload within bin/"
exit 1
fi
pushd "bin/"
client_path="aks-secure-tls-bootstrap-client-amd64.exe"
mv "${client_path}" "aks-secure-tls-bootstrap-client.exe"
zip -r "windows-amd64.zip" "aks-secure-tls-bootstrap-client.exe"
az storage blob upload -f "windows-amd64.zip" --auth-mode login --blob-url "https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net/\$web/client/windows/amd64/${VERSION}.zip"
popd
rm -rf "bin/"
display_download_url "client/windows/amd64/${VERSION}.zip"
}
if [ "${OS}" == "all" ]; then
build_and_upload_linux_amd64
build_and_upload_linux_arm64
build_and_upload_windows_amd64
elif [ "${OS}" == "linux" ]; then
build_and_upload_linux_amd64
build_and_upload_linux_arm64
elif [ "${OS}" == "windows" ]; then
build_and_upload_windows_amd64
else
echo "unsupported OS: $OS, must be \"all\", \"linux\" or \"windows\""
exit 1
fi