Skip to content

Commit b1dd2a2

Browse files
committed
Download Rustup files from CDN
1 parent 1e516af commit b1dd2a2

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

local/rustup.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,51 @@
66

77
set -euo pipefail
88
IFS=$'\n\t'
9+
10+
RUSTUP_REPO="https://github.com/rust-lang/rustup"
11+
RUSTUP_DEFAULT_BRANCH="master"
12+
13+
# S3 bucket from which to download the Rustup artifacts
14+
S3_BUCKET="rustup-builds"
15+
16+
# CDN from which to download the CI artifacts
17+
DOWNLOAD_BASE="https://rustup-builds.rust-lang.org"
18+
19+
# The artifacts for the following targets will be downloaded and copied during
20+
# the release process. At least one target is required.
21+
DOWNLOAD_TARGETS=(
22+
"x86_64-unknown-linux-gnu"
23+
)
24+
25+
# The following files will be downloaded and put into the local MinIO instance.
26+
DOWNLOAD_FILES=(
27+
"rustup-init"
28+
"rustup-init.sha256"
29+
"rustup-setup"
30+
"rustup-setup.sha256"
31+
)
32+
33+
channel="$1"
34+
override_commit="$2"
35+
36+
if [[ "${override_commit}" = "" ]]; then
37+
echo "==> detecting the last Rustup commit on the default branch"
38+
commit="$(git ls-remote "${RUSTUP_REPO}" | grep "refs/heads/${RUSTUP_DEFAULT_BRANCH}" | awk '{print($1)}')"
39+
else
40+
echo "=>> using overridden commit ${override_commit}"
41+
commit="${override_commit}"
42+
fi
43+
44+
for target in "${DOWNLOAD_TARGETS[@]}"; do
45+
if ! mc stat "local/artifacts/builds/${commit}/dist/${target}" >/dev/null 2>&1; then
46+
echo "==> copying ${target} from S3"
47+
48+
for file in "${DOWNLOAD_FILES[@]}"; do
49+
if curl -Lo /tmp/component "${DOWNLOAD_BASE}/${commit}/dist/${target}/${file}" --fail; then
50+
mc cp /tmp/component "local/artifacts/builds/${commit}/dist/${target}/${file}" >/dev/null
51+
fi
52+
done
53+
else
54+
echo "==> reusing cached ${target} target"
55+
fi
56+
done

0 commit comments

Comments
 (0)