From f88dd397f45d15666fdb0a67225a5d13248b4d61 Mon Sep 17 00:00:00 2001 From: Bart Waardenburg Date: Wed, 21 Oct 2026 19:31:35 +0200 Subject: [PATCH] fix(release): send a user agent in the crates.io lookup crates.io now answers a request without a user agent with HTTP 403. The publish helper then stopped before cargo publish, so the v0.4.0 release run published no crate. Signed-off-by: Bart Waardenburg --- .github/scripts/publish-crate-if-needed.sh | 1 + .github/scripts/publish-crate-if-needed.test.mjs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.github/scripts/publish-crate-if-needed.sh b/.github/scripts/publish-crate-if-needed.sh index 48048a3..73473ce 100755 --- a/.github/scripts/publish-crate-if-needed.sh +++ b/.github/scripts/publish-crate-if-needed.sh @@ -19,6 +19,7 @@ trap 'rm -f "$response_file"' EXIT status="$( curl --silent --show-error \ + --user-agent "srcmap-release (https://github.com/fallow-rs/srcmap)" \ --output "$response_file" \ --write-out '%{http_code}' \ "https://crates.io/api/v1/crates/${crate_name}/${version}" diff --git a/.github/scripts/publish-crate-if-needed.test.mjs b/.github/scripts/publish-crate-if-needed.test.mjs index 7112d49..6f57b33 100644 --- a/.github/scripts/publish-crate-if-needed.test.mjs +++ b/.github/scripts/publish-crate-if-needed.test.mjs @@ -115,6 +115,12 @@ describe("publish-crate-if-needed", () => { assert.match(result.commands, /cargo publish -p srcmap-codec --no-verify/); }); + it("sends a user agent, because crates.io refuses a lookup without one", async () => { + const result = await runPublishHelper(); + + assert.match(result.commands, /curl [^\n]*--user-agent /); + }); + it("stops when the crates.io lookup fails", async () => { const result = await runPublishHelper({ lookup: "failure" });