Skip to content

Commit 897a540

Browse files
committed
ci(release): harden R2 upload with aws CLI auto-install and R2-compatible checksums
1 parent edcd67d commit 897a540

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,29 @@ jobs:
255255
exit 0
256256
fi
257257
258+
# Ensure aws CLI is available; k8s/docker build images may not ship it.
259+
if ! command -v aws >/dev/null 2>&1; then
260+
echo "ℹ️ aws CLI not found, installing AWS CLI v2 for Linux..."
261+
ARCH="$(uname -m)"
262+
case "$ARCH" in
263+
x86_64) AWS_CLI_ARCH="x86_64" ;;
264+
aarch64|arm64) AWS_CLI_ARCH="aarch64" ;;
265+
*) echo "❌ Unsupported architecture for aws CLI install: $ARCH"; exit 1 ;;
266+
esac
267+
curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-${AWS_CLI_ARCH}.zip" -o awscliv2.zip
268+
unzip -q awscliv2.zip
269+
./aws/install --update -i "${RUNNER_TEMP:-/tmp}/aws-cli" -b "${RUNNER_TEMP:-/tmp}/aws-bin"
270+
export PATH="${RUNNER_TEMP:-/tmp}/aws-bin:$PATH"
271+
rm -rf awscliv2.zip aws
272+
fi
273+
258274
export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID"
259275
export AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY"
260276
export AWS_DEFAULT_REGION="auto"
277+
# AWS CLI v2.23+ enables data integrity checksums by default, which
278+
# Cloudflare R2 does not fully support; only send them when required.
279+
export AWS_REQUEST_CHECKSUM_CALCULATION="when_required"
280+
export AWS_RESPONSE_CHECKSUM_VALIDATION="when_required"
261281
262282
R2_PATH="s3://${R2_BUCKET}/artifacts/rustfs-cli/release/"
263283
@@ -380,9 +400,29 @@ jobs:
380400
exit 0
381401
fi
382402
403+
# Ensure aws CLI is available; k8s/docker build images may not ship it.
404+
if ! command -v aws >/dev/null 2>&1; then
405+
echo "ℹ️ aws CLI not found, installing AWS CLI v2 for Linux..."
406+
ARCH="$(uname -m)"
407+
case "$ARCH" in
408+
x86_64) AWS_CLI_ARCH="x86_64" ;;
409+
aarch64|arm64) AWS_CLI_ARCH="aarch64" ;;
410+
*) echo "❌ Unsupported architecture for aws CLI install: $ARCH"; exit 1 ;;
411+
esac
412+
curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-${AWS_CLI_ARCH}.zip" -o awscliv2.zip
413+
unzip -q awscliv2.zip
414+
./aws/install --update -i "${RUNNER_TEMP:-/tmp}/aws-cli" -b "${RUNNER_TEMP:-/tmp}/aws-bin"
415+
export PATH="${RUNNER_TEMP:-/tmp}/aws-bin:$PATH"
416+
rm -rf awscliv2.zip aws
417+
fi
418+
383419
export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID"
384420
export AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY"
385421
export AWS_DEFAULT_REGION="auto"
422+
# AWS CLI v2.23+ enables data integrity checksums by default, which
423+
# Cloudflare R2 does not fully support; only send them when required.
424+
export AWS_REQUEST_CHECKSUM_CALCULATION="when_required"
425+
export AWS_RESPONSE_CHECKSUM_VALIDATION="when_required"
386426
387427
R2_PATH="s3://${R2_BUCKET}/artifacts/rustfs-cli/release/${RELEASE_VERSION}/"
388428

0 commit comments

Comments
 (0)