diff --git a/action.yml b/action.yml index 0864e9e..a3b594f 100644 --- a/action.yml +++ b/action.yml @@ -206,17 +206,31 @@ runs: SKIP_HASH_CHECK_WARNING="${{ inputs.skip-hash-check-warning }}" + INSTALLER_TMP=$(mktemp) + CURL_ERR=$(mktemp) + trap 'rm -f "$INSTALLER_TMP" "$CURL_ERR"' EXIT + # GitHub Releases fails transiently (5xx, HTTP 618 for an expired signed link). Each retry + # starts again from the codspeed.io URL, so GitHub issues a fresh link. + download_installer() { + if ! curl -fsSL --retry 5 --retry-all-errors -o "$INSTALLER_TMP" "$1" 2>"$CURL_ERR"; then + echo "::error title=Failed to install CodSpeed CLI::Failed to download $1 after 6 attempts: $(tail -n 1 "$CURL_ERR").%0AThe installer is hosted on GitHub Releases. Re-run the job, and check https://www.githubstatus.com if it keeps failing." + exit 1 + fi + } + if [ "$VERSION_TYPE" = "latest" ]; then if [ "$SKIP_HASH_CHECK_WARNING" != "true" ]; then echo "::warning::Hash verification is not available when using 'latest' version. Consider pinning a specific version for supply chain security." fi - curl -fsSL https://codspeed.io/install.sh | bash -s -- --quiet + download_installer https://codspeed.io/install.sh + bash "$INSTALLER_TMP" --quiet elif [ "$VERSION_TYPE" = "prerelease" ]; then # Prereleases are not pinned, so install from the versioned installer without hash verification. if [ "$SKIP_HASH_CHECK_WARNING" != "true" ]; then echo "::warning::Hash verification is not available for prerelease version $RUNNER_VERSION." fi - curl -fsSL "https://codspeed.io/v$RUNNER_VERSION/install.sh" | bash -s -- --quiet + download_installer "https://codspeed.io/v$RUNNER_VERSION/install.sh" + bash "$INSTALLER_TMP" --quiet elif [ "$VERSION_TYPE" = "branch" ]; then # Install from specific branch using cargo if [ "$SKIP_HASH_CHECK_WARNING" != "true" ]; then @@ -233,20 +247,7 @@ runs: cargo install --locked --git https://github.com/CodSpeedHQ/codspeed --rev "$RUNNER_VERSION" codspeed-runner else # Release version - download to temp file and verify hash - INSTALLER_URL="https://codspeed.io/v$RUNNER_VERSION/install.sh" - INSTALLER_TMP=$(mktemp) - trap "rm -f $INSTALLER_TMP" EXIT - - CURL_ERR=$(mktemp) - if ! HTTP_CODE=$(curl -sSL -o "$INSTALLER_TMP" -w "%{http_code}" "$INSTALLER_URL" 2>"$CURL_ERR"); then - echo "::error title=Failed to install CodSpeed CLI::Installation of CodSpeed CLI with version $RUNNER_VERSION failed.%0AReason: $(cat "$CURL_ERR")" - exit 1 - fi - if [ "$HTTP_CODE" -ge 400 ]; then - error_body=$(cat "$INSTALLER_TMP") - echo "::error title=Failed to install CodSpeed CLI::Installation of CodSpeed CLI with version $RUNNER_VERSION failed.%0AReason: HTTP $HTTP_CODE - ${error_body:-no response body}" - exit 1 - fi + download_installer "https://codspeed.io/v$RUNNER_VERSION/install.sh" EXPECTED_HASH="${{ steps.installer-hash.outputs.hash }}" if [ -z "$EXPECTED_HASH" ]; then diff --git a/scripts/check-hashes.sh b/scripts/check-hashes.sh index acd45d5..f5b20d3 100755 --- a/scripts/check-hashes.sh +++ b/scripts/check-hashes.sh @@ -27,7 +27,7 @@ for VERSION in $VERSIONS; do INSTALLER_TMP=$(mktemp) trap 'rm -f $INSTALLER_TMP' EXIT - if ! curl -fsSL "$URL" -o "$INSTALLER_TMP" 2>/dev/null; then + if ! curl -fsSL --retry 5 --retry-all-errors "$URL" -o "$INSTALLER_TMP" 2>/dev/null; then echo "FAIL $VERSION - download failed ($URL)" FAILED=$((FAILED + 1)) continue