File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545 BUCKET : ${{ secrets.MIRROR_S3_BUCKET }}
4646 ENDPOINT : ${{ secrets.MIRROR_S3_ENDPOINT }}
4747 PREFIX : ${{ secrets.MIRROR_S3_PATH_PREFIX }}
48+ MIRROR_PUBLIC_URL : ${{ secrets.MIRROR_PUBLIC_URL }}
4849 run : |
4950 set -eu
5051 if [ -z "${BUCKET:-}" ] || [ -z "${ENDPOINT:-}" ]; then
5960 aws configure set default.response_checksum_validation when_required
6061 PREFIX="${PREFIX#/}"; PREFIX="${PREFIX%/}"
6162
63+ # Bake the CDN as the default MIRROR_URL into the copy we serve from the
64+ # CDN, so `curl <cdn>/install.sh | sh` pulls binaries from the CDN with
65+ # no MIRROR_URL arg. The repo / GitHub copy stays generic (GitHub default).
66+ src_sh=install.sh
67+ if [ -n "${MIRROR_PUBLIC_URL:-}" ]; then
68+ pub="${MIRROR_PUBLIC_URL%/}${PREFIX:+/${PREFIX}}"
69+ sed "s#MIRROR_URL=\"\${MIRROR_URL:-}\"#MIRROR_URL=\"\${MIRROR_URL:-${pub}}\"#" install.sh > /tmp/install.sh
70+ grep -q "MIRROR_URL:-${pub}" /tmp/install.sh || { echo "ERROR: MIRROR_URL default not injected (install.sh default line changed?)" >&2; exit 1; }
71+ src_sh=/tmp/install.sh
72+ fi
6273 sh_key="${PREFIX:+${PREFIX}/}install.sh"
63- aws --endpoint-url="$ENDPOINT" s3 cp install.sh "s3://${BUCKET}/${sh_key}" \
74+ aws --endpoint-url="$ENDPOINT" s3 cp "$src_sh" "s3://${BUCKET}/${sh_key}" \
6475 --cache-control "public, max-age=300" \
6576 --content-type "text/x-shellscript; charset=utf-8"
6677
Original file line number Diff line number Diff line change 5353 BUCKET : ${{ secrets.MIRROR_S3_BUCKET }}
5454 ENDPOINT : ${{ secrets.MIRROR_S3_ENDPOINT }}
5555 PREFIX : ${{ secrets.MIRROR_S3_PATH_PREFIX }}
56+ MIRROR_PUBLIC_URL : ${{ secrets.MIRROR_PUBLIC_URL }}
5657 VERSION : ${{ github.ref_name }}
5758 run : |
5859 set -eu
@@ -102,8 +103,18 @@ jobs:
102103 # ships a stale/missing installer (install-scripts.yml only fires when
103104 # install.sh/.ps1 change on main; the scripts are version-agnostic, so
104105 # re-uploading the current copy here is the belt-and-suspenders guarantee).
106+ # Bake the CDN as the default MIRROR_URL into the served copy so
107+ # `curl <cdn>/install.sh | sh` pulls binaries from the CDN with no
108+ # MIRROR_URL arg. The repo / GitHub copy stays generic (GitHub default).
109+ src_sh=install.sh
110+ if [ -n "${MIRROR_PUBLIC_URL:-}" ]; then
111+ pub="${MIRROR_PUBLIC_URL%/}${PREFIX:+/${PREFIX}}"
112+ sed "s#MIRROR_URL=\"\${MIRROR_URL:-}\"#MIRROR_URL=\"\${MIRROR_URL:-${pub}}\"#" install.sh > /tmp/install.sh
113+ grep -q "MIRROR_URL:-${pub}" /tmp/install.sh || { echo "ERROR: MIRROR_URL default not injected (install.sh default line changed?)" >&2; exit 1; }
114+ src_sh=/tmp/install.sh
115+ fi
105116 sh_key="${PREFIX:+${PREFIX}/}install.sh"
106- aws --endpoint-url="$ENDPOINT" s3 cp install.sh "s3://${BUCKET}/${sh_key}" \
117+ aws --endpoint-url="$ENDPOINT" s3 cp "$src_sh" "s3://${BUCKET}/${sh_key}" \
107118 --cache-control "public, max-age=300" \
108119 --content-type "text/x-shellscript; charset=utf-8"
109120 ps1_key="${PREFIX:+${PREFIX}/}install.ps1"
You can’t perform that action at this time.
0 commit comments