Skip to content
Merged
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
43 changes: 30 additions & 13 deletions .github/workflows/crates-io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,33 @@ jobs:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
shell: bash
run: |
cargo publish -p tare-tokenize --no-verify
sleep 20
cargo publish -p tare-cache --no-verify
sleep 20
cargo publish -p tare-core --no-verify
sleep 20
cargo publish -p tare-memory --no-verify
sleep 20
cargo publish -p tare-cli --no-verify
sleep 20
cargo publish -p tare-proxy --no-verify
sleep 20
cargo publish -p tare-mcp --no-verify
set -euo pipefail

# Publish in dependency order. Idempotent: if a crate's current
# version is already on crates.io (e.g. a prior run published some
# crates then failed on a rate limit), skip it instead of failing on
# the duplicate. This makes the workflow safe to re-run to resume.
crates=(tare-tokenize tare-cache tare-core tare-memory tare-cli tare-proxy tare-mcp)

version_published() {
local crate="$1" version="$2"
# crates.io returns 200 with the version object if it exists.
curl -sf "https://crates.io/api/v1/crates/${crate}/${version}" \
-H "User-Agent: tare-ci-publish" >/dev/null 2>&1
Comment on lines +42 to +43

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Distinguish missing versions from API failures

When crates.io returns 429/5xx or the lookup encounters a network failure—a relevant scenario because this workflow is intended to recover from rate limiting—curl -sf exits nonzero and the if treats that exactly like a 404. The loop then attempts to publish an already-published crate and fails on the duplicate, defeating the promised resumability. As curl --help all documents, --fail fails on HTTP errors generally; capture the status and publish only on 404, while retrying or failing explicitly for other errors.

Useful? React with 👍 / 👎.

}

for crate in "${crates[@]}"; do
version="$(cargo metadata --format-version=1 --no-deps \
| jq -r --arg c "$crate" '.packages[] | select(.name==$c) | .version')"
if [ -z "$version" ]; then
echo "::error::could not determine version for ${crate}"
exit 1
fi
if version_published "$crate" "$version"; then
echo "skip ${crate} ${version} (already published)"
continue
fi
echo "publishing ${crate} ${version}"
cargo publish -p "$crate" --no-verify
sleep 20
done