Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-hashes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading