Skip to content

Commit 4068e9e

Browse files
committed
fix(release): keep workspace dep versions in lockstep and use SemVer in crates.io audit
1 parent 28f7d38 commit 4068e9e

2 files changed

Lines changed: 35 additions & 22 deletions

File tree

.github/workflows/publish-to-crates-io.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ jobs:
7878
-e 's/^([0-9]+)\.([0-9]+)\.([0-9]+)b([0-9]+)$/\1.\2.\3-beta.\4/' \
7979
-e 's/^([0-9]+)\.([0-9]+)\.([0-9]+)rc([0-9]+)$/\1.\2.\3-rc.\4/')
8080
ws_ver=$(sed -n 's/^version = //p' rust/Cargo.toml | head -n 1 | tr -d '"' | tr -d ' ')
81+
# ADR-009 lockstep: every [workspace.dependencies] version literal must
82+
# equal the workspace version, or cargo packs 0.6.0-alpha.N crates whose
83+
# manifests require stale sibling versions (0.6.0-alpha.N-1) — crates.io
84+
# rejects the upload. Fail here, before the dry-run/publish steps.
85+
dep_ver=$(sed -n '/^\[workspace.dependencies\]/,/^\[/p' rust/Cargo.toml | grep -o 'version = "[^"]*"' | sed -E 's/version = "([^"]+)"/\1/' | sort -u | grep -v "^$ws_ver$" | head -n 1)
86+
if [ -n "$dep_ver" ]; then
87+
echo "[workspace.dependencies] version '$dep_ver' is out of lockstep with workspace version '$ws_ver'" >&2
88+
exit 1
89+
fi
8190
if [ "$cargo_ver" != "$ws_ver" ]; then
8291
echo "Tag $GITHUB_REF_NAME does not match [workspace.package] version '$ws_ver'" >&2
8392
exit 1
@@ -106,7 +115,11 @@ jobs:
106115
run: |
107116
set -uo pipefail
108117
cd rust
109-
ver="${GITHUB_REF_NAME#v}"
118+
# The live-set audit below greps the crates.io index, which stores the
119+
# SEMVER literal (0.6.0-alpha.6), not the PEP440 tag (0.6.0a6). Read the
120+
# workspace version instead of deriving it from the tag so the grep
121+
# always matches what crates.io reports.
122+
ver=$(sed -n 's/^version = //p' Cargo.toml | head -n 1 | tr -d '"' | tr -d ' ')
110123
# Publishable members from cargo metadata itself (publish:null), so a
111124
# new non-publishable crate (publish=false -> []) is auto-skipped — no
112125
# hardcoded name list to drift. Today that's degenbot_rs + degenbot-execution-sample.

rust/Cargo.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,28 @@ exit = "deny"
6969
# Internal path deps carry explicit version requirements here so the 26
7070
# publishable crates pass cargo publish manifest validation. Keep these
7171
# version literals in sync with [workspace.package].version (lockstep, ADR-009).
72-
degenbot-aave = { version = "0.6.0-alpha.5", path = "crates/degenbot-aave" }
73-
degenbot-abi = { version = "0.6.0-alpha.5", path = "crates/degenbot-abi" }
74-
degenbot-arbitrage = { version = "0.6.0-alpha.5", path = "crates/degenbot-arbitrage" }
75-
degenbot-bot = { version = "0.6.0-alpha.5", path = "crates/degenbot-bot" }
76-
degenbot-core = { version = "0.6.0-alpha.5", path = "crates/degenbot-core" }
77-
degenbot-db = { version = "0.6.0-alpha.5", path = "crates/degenbot-db" }
78-
degenbot-decoders = { version = "0.6.0-alpha.5", path = "crates/degenbot-decoders" }
79-
degenbot-execution = { version = "0.6.0-alpha.5", path = "crates/degenbot-execution" }
80-
degenbot-executor = { version = "0.6.0-alpha.5", path = "crates/degenbot-executor" }
81-
degenbot-fork = { version = "0.6.0-alpha.5", path = "crates/degenbot-fork" }
72+
degenbot-aave = { version = "0.6.0-alpha.6", path = "crates/degenbot-aave" }
73+
degenbot-abi = { version = "0.6.0-alpha.6", path = "crates/degenbot-abi" }
74+
degenbot-arbitrage = { version = "0.6.0-alpha.6", path = "crates/degenbot-arbitrage" }
75+
degenbot-bot = { version = "0.6.0-alpha.6", path = "crates/degenbot-bot" }
76+
degenbot-core = { version = "0.6.0-alpha.6", path = "crates/degenbot-core" }
77+
degenbot-db = { version = "0.6.0-alpha.6", path = "crates/degenbot-db" }
78+
degenbot-decoders = { version = "0.6.0-alpha.6", path = "crates/degenbot-decoders" }
79+
degenbot-execution = { version = "0.6.0-alpha.6", path = "crates/degenbot-execution" }
80+
degenbot-executor = { version = "0.6.0-alpha.6", path = "crates/degenbot-executor" }
81+
degenbot-fork = { version = "0.6.0-alpha.6", path = "crates/degenbot-fork" }
8282
# degenbot-math: consolidated AMM math family (ADR-035: v2, cl, curve, balancer, solidly).
83-
degenbot-math = { version = "0.6.0-alpha.5", path = "crates/degenbot-math" }
84-
degenbot-order-index = { version = "0.6.0-alpha.5", path = "crates/degenbot-order-index" }
85-
degenbot-pathfinding = { version = "0.6.0-alpha.5", path = "crates/degenbot-pathfinding" }
86-
degenbot-pool-updater = { version = "0.6.0-alpha.5", path = "crates/degenbot-pool-updater" }
87-
degenbot-pools = { version = "0.6.0-alpha.5", path = "crates/degenbot-pools" }
88-
degenbot-price = { version = "0.6.0-alpha.5", path = "crates/degenbot-price" }
89-
degenbot-rpc = { version = "0.6.0-alpha.5", path = "crates/degenbot-rpc" }
90-
degenbot-simulation = { version = "0.6.0-alpha.5", path = "crates/degenbot-simulation" }
91-
degenbot-solvers = { version = "0.6.0-alpha.5", path = "crates/degenbot-solvers" }
92-
degenbot-submission = { version = "0.6.0-alpha.5", path = "crates/degenbot-submission" }
93-
degenbot-uniswap = { version = "0.6.0-alpha.5", path = "crates/degenbot-uniswap" }
83+
degenbot-math = { version = "0.6.0-alpha.6", path = "crates/degenbot-math" }
84+
degenbot-order-index = { version = "0.6.0-alpha.6", path = "crates/degenbot-order-index" }
85+
degenbot-pathfinding = { version = "0.6.0-alpha.6", path = "crates/degenbot-pathfinding" }
86+
degenbot-pool-updater = { version = "0.6.0-alpha.6", path = "crates/degenbot-pool-updater" }
87+
degenbot-pools = { version = "0.6.0-alpha.6", path = "crates/degenbot-pools" }
88+
degenbot-price = { version = "0.6.0-alpha.6", path = "crates/degenbot-price" }
89+
degenbot-rpc = { version = "0.6.0-alpha.6", path = "crates/degenbot-rpc" }
90+
degenbot-simulation = { version = "0.6.0-alpha.6", path = "crates/degenbot-simulation" }
91+
degenbot-solvers = { version = "0.6.0-alpha.6", path = "crates/degenbot-solvers" }
92+
degenbot-submission = { version = "0.6.0-alpha.6", path = "crates/degenbot-submission" }
93+
degenbot-uniswap = { version = "0.6.0-alpha.6", path = "crates/degenbot-uniswap" }
9494

9595
[workspace]
9696
resolver = "3"

0 commit comments

Comments
 (0)