From 92d5e7f7ee25770ce204ccf7ed9ebc62607f4125 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 28 Aug 2026 07:27:37 -0700 Subject: [PATCH 1/6] Fix crate publish existence check Signed-off-by: James Sturtevant --- .github/workflows/CargoPublish.yml | 34 ++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CargoPublish.yml b/.github/workflows/CargoPublish.yml index 5d97a89d8c..4ef576acc5 100644 --- a/.github/workflows/CargoPublish.yml +++ b/.github/workflows/CargoPublish.yml @@ -61,13 +61,35 @@ jobs: return fi - if curl -s "https://crates.io/api/v1/crates/$crate/$VERSION" | jq -e .version > /dev/null; then - echo "PUBLISH_${crate_env_var}=false" >> "$GITHUB_ENV" - echo "✅ $crate@$VERSION already exists." - else - echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV" - echo "🚀 $crate@$VERSION will be published." + local response_file=$(mktemp) + local http_status + if ! http_status=$(curl -sS -A 'hyperlight-release-workflow (https://github.com/hyperlight-dev/hyperlight)' --retry 3 --retry-all-errors --connect-timeout 10 --max-time 30 -o "$response_file" -w '%{http_code}' "https://crates.io/api/v1/crates/$crate/$VERSION"); then + echo "::error::Failed to query crates.io for $crate@$VERSION." + rm -f "$response_file" + return 1 fi + + case "$http_status" in + 200) + if ! jq -e --arg version "$VERSION" '.version.num == $version' "$response_file" > /dev/null; then + echo "::error::crates.io returned malformed or mismatched version data for $crate@$VERSION." + rm -f "$response_file" + return 1 + fi + echo "PUBLISH_${crate_env_var}=false" >> "$GITHUB_ENV" + echo "✅ $crate@$VERSION already exists." + ;; + 404) + echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV" + echo "🚀 $crate@$VERSION will be published." + ;; + *) + echo "::error::crates.io returned HTTP $http_status for $crate@$VERSION." + rm -f "$response_file" + return 1 + ;; + esac + rm -f "$response_file" } needs_publish hyperlight-libc From 09b09aa356830e33718ef49b89ef21e208774350 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 28 Aug 2026 07:29:02 -0700 Subject: [PATCH 2/6] Extract crate publish check script Signed-off-by: James Sturtevant --- .github/workflows/CargoPublish.yml | 60 +++++------------------------- scripts/crates-to-publish.sh | 47 +++++++++++++++++++++++ 2 files changed, 57 insertions(+), 50 deletions(-) create mode 100755 scripts/crates-to-publish.sh diff --git a/.github/workflows/CargoPublish.yml b/.github/workflows/CargoPublish.yml index 4ef576acc5..cde4280294 100644 --- a/.github/workflows/CargoPublish.yml +++ b/.github/workflows/CargoPublish.yml @@ -51,56 +51,16 @@ jobs: - name: Determine which crates need publishing run: | - needs_publish() { - local crate=$1 - local crate_env_var=$(echo "$crate" | tr '[:lower:]' '[:upper:]' | tr '-' '_') - - if [ -z "$VERSION" ]; then - echo "No version set (dry run?), skipping crates.io existence checks." - echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV" - return - fi - - local response_file=$(mktemp) - local http_status - if ! http_status=$(curl -sS -A 'hyperlight-release-workflow (https://github.com/hyperlight-dev/hyperlight)' --retry 3 --retry-all-errors --connect-timeout 10 --max-time 30 -o "$response_file" -w '%{http_code}' "https://crates.io/api/v1/crates/$crate/$VERSION"); then - echo "::error::Failed to query crates.io for $crate@$VERSION." - rm -f "$response_file" - return 1 - fi - - case "$http_status" in - 200) - if ! jq -e --arg version "$VERSION" '.version.num == $version' "$response_file" > /dev/null; then - echo "::error::crates.io returned malformed or mismatched version data for $crate@$VERSION." - rm -f "$response_file" - return 1 - fi - echo "PUBLISH_${crate_env_var}=false" >> "$GITHUB_ENV" - echo "✅ $crate@$VERSION already exists." - ;; - 404) - echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV" - echo "🚀 $crate@$VERSION will be published." - ;; - *) - echo "::error::crates.io returned HTTP $http_status for $crate@$VERSION." - rm -f "$response_file" - return 1 - ;; - esac - rm -f "$response_file" - } - - needs_publish hyperlight-libc - needs_publish hyperlight-common - needs_publish hyperlight-guest - needs_publish hyperlight-guest-macro - needs_publish hyperlight-guest-bin - needs_publish hyperlight-component-util - needs_publish hyperlight-component-macro - needs_publish hyperlight-host - needs_publish hyperlight-guest-tracing + ./scripts/crates-to-publish.sh "$VERSION" \ + hyperlight-libc \ + hyperlight-common \ + hyperlight-guest \ + hyperlight-guest-macro \ + hyperlight-guest-bin \ + hyperlight-component-util \ + hyperlight-component-macro \ + hyperlight-host \ + hyperlight-guest-tracing >> "$GITHUB_ENV" - name: Authenticate with crates.io uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 diff --git a/scripts/crates-to-publish.sh b/scripts/crates-to-publish.sh new file mode 100755 index 0000000000..c066d51936 --- /dev/null +++ b/scripts/crates-to-publish.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -Eeuo pipefail + +if [ "$#" -lt 2 ]; then + echo "Usage: $0 VERSION CRATE..." >&2 + exit 1 +fi + +VERSION=$1 +shift + +response_file=$(mktemp) +trap 'rm -f "$response_file"' EXIT + +for crate in "$@"; do + crate_env_var=$(echo "$crate" | tr '[:lower:]' '[:upper:]' | tr '-' '_') + + if [ -z "$VERSION" ]; then + echo "No version set (dry run?), skipping crates.io existence checks." >&2 + echo "PUBLISH_${crate_env_var}=true" + continue + fi + + if ! http_status=$(curl -sS -A 'hyperlight-release-workflow (https://github.com/hyperlight-dev/hyperlight)' --retry 3 --retry-all-errors --connect-timeout 10 --max-time 30 -o "$response_file" -w '%{http_code}' "https://crates.io/api/v1/crates/$crate/$VERSION"); then + echo "Failed to query crates.io for $crate@$VERSION." >&2 + exit 1 + fi + + case "$http_status" in + 200) + if ! jq -e --arg version "$VERSION" '.version.num == $version' "$response_file" > /dev/null; then + echo "crates.io returned malformed or mismatched version data for $crate@$VERSION." >&2 + exit 1 + fi + echo "PUBLISH_${crate_env_var}=false" + echo "$crate@$VERSION already exists." >&2 + ;; + 404) + echo "PUBLISH_${crate_env_var}=true" + echo "$crate@$VERSION will be published." >&2 + ;; + *) + echo "crates.io returned HTTP $http_status for $crate@$VERSION." >&2 + exit 1 + ;; + esac +done From f25b762f34b500a08e7efebcfff35f65de494491 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 28 Aug 2026 07:42:41 -0700 Subject: [PATCH 3/6] Enforce LF endings for shell scripts Signed-off-by: James Sturtevant --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..dfdb8b771c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf From 23f992317310c4678b0fc4b23ec48729d07cf937 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 28 Aug 2026 07:50:56 -0700 Subject: [PATCH 4/6] Simplify crate publish script Signed-off-by: James Sturtevant --- scripts/crates-to-publish.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/crates-to-publish.sh b/scripts/crates-to-publish.sh index c066d51936..a82b769987 100755 --- a/scripts/crates-to-publish.sh +++ b/scripts/crates-to-publish.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -Eeuo pipefail +set -euo pipefail if [ "$#" -lt 2 ]; then echo "Usage: $0 VERSION CRATE..." >&2 @@ -13,7 +13,8 @@ response_file=$(mktemp) trap 'rm -f "$response_file"' EXIT for crate in "$@"; do - crate_env_var=$(echo "$crate" | tr '[:lower:]' '[:upper:]' | tr '-' '_') + crate_env_var=${crate^^} + crate_env_var=${crate_env_var//-/_} if [ -z "$VERSION" ]; then echo "No version set (dry run?), skipping crates.io existence checks." >&2 @@ -21,7 +22,17 @@ for crate in "$@"; do continue fi - if ! http_status=$(curl -sS -A 'hyperlight-release-workflow (https://github.com/hyperlight-dev/hyperlight)' --retry 3 --retry-all-errors --connect-timeout 10 --max-time 30 -o "$response_file" -w '%{http_code}' "https://crates.io/api/v1/crates/$crate/$VERSION"); then + if ! http_status=$( + curl --silent --show-error \ + --user-agent 'hyperlight-release-workflow (https://github.com/hyperlight-dev/hyperlight)' \ + --retry 3 \ + --retry-all-errors \ + --connect-timeout 10 \ + --max-time 30 \ + --output "$response_file" \ + --write-out '%{http_code}' \ + "https://crates.io/api/v1/crates/$crate/$VERSION" + ); then echo "Failed to query crates.io for $crate@$VERSION." >&2 exit 1 fi From 47baaa43425232ce7f4ff27f0db686c5073a9111 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 28 Aug 2026 08:00:30 -0700 Subject: [PATCH 5/6] Move crate publish script to dev Signed-off-by: James Sturtevant --- .github/workflows/CargoPublish.yml | 2 +- {scripts => dev}/crates-to-publish.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {scripts => dev}/crates-to-publish.sh (100%) mode change 100755 => 100644 diff --git a/.github/workflows/CargoPublish.yml b/.github/workflows/CargoPublish.yml index cde4280294..4b91fffad3 100644 --- a/.github/workflows/CargoPublish.yml +++ b/.github/workflows/CargoPublish.yml @@ -51,7 +51,7 @@ jobs: - name: Determine which crates need publishing run: | - ./scripts/crates-to-publish.sh "$VERSION" \ + ./dev/crates-to-publish.sh "$VERSION" \ hyperlight-libc \ hyperlight-common \ hyperlight-guest \ diff --git a/scripts/crates-to-publish.sh b/dev/crates-to-publish.sh old mode 100755 new mode 100644 similarity index 100% rename from scripts/crates-to-publish.sh rename to dev/crates-to-publish.sh From 6b8cdd08a55ed390455d3c8edaa9692e1c5f8d24 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 28 Aug 2026 08:00:38 -0700 Subject: [PATCH 6/6] Keep crate publish script executable Signed-off-by: James Sturtevant --- dev/crates-to-publish.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 dev/crates-to-publish.sh diff --git a/dev/crates-to-publish.sh b/dev/crates-to-publish.sh old mode 100644 new mode 100755