diff --git a/.github/workflows/container-release.yml b/.github/workflows/container-release.yml index b6c89219..9c3fd953 100644 --- a/.github/workflows/container-release.yml +++ b/.github/workflows/container-release.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: push: tags: - - 'v*' + - 'contender_cli_v*' permissions: contents: write @@ -32,7 +32,14 @@ jobs: run: | platform=${{ matrix.config.platform }} echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + # Extract version part after last underscore + ver="${GITHUB_REF#refs/*/}" + ver="${ver##*_}" + # Ensure it starts with 'v' + if [[ "$ver" != v* ]]; then + ver="v$ver" + fi + echo "RELEASE_VERSION=$ver" >> $GITHUB_ENV - name: Print version run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50848431..eb68e407 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ name: release on: push: tags: - - v* + - contender_cli_v* workflow_dispatch: inputs: dry_run: @@ -37,6 +37,12 @@ jobs: run: | vv="${GITHUB_REF_NAME}" vv="${vv//\//-}" + # Extract version part after the last underscore + vv="${vv##*_}" + # Ensure it starts with 'v' + if [[ "$vv" != v* ]]; then + vv="v$vv" + fi echo "VERSION=$vv" >> $GITHUB_OUTPUT id: extract_version outputs: diff --git a/Cargo.toml b/Cargo.toml index 792cce37..116d7173 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ resolver = "2" [workspace.package] edition = "2021" -version = "0.10.0" rust-version = "1.86" authors = ["Flashbots"] license = "MIT OR Apache-2.0" diff --git a/crates/bundle_provider/Cargo.toml b/crates/bundle_provider/Cargo.toml index c5485425..f4398431 100644 --- a/crates/bundle_provider/Cargo.toml +++ b/crates/bundle_provider/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "contender_bundle_provider" -version.workspace = true +description = "Contender bundle provider" +version = "0.10.0" edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -description = "Contender bundle provider" [dependencies] alloy = { workspace = true, features = ["node-bindings", "rpc-types-mev"] } diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 2dc50deb..e94e31e1 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "contender_cli" -version.workspace = true +description = "Contender CLI" +version = "0.10.0" edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -description = "Contender CLI" [[bin]] name = "contender" diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 21b40e96..e40061ad 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "contender_core" -version.workspace = true +description = "Contender core library" +version = "0.10.0" edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -description = "Contender core library" [dependencies] contender_bundle_provider = { workspace = true } diff --git a/crates/engine_provider/Cargo.toml b/crates/engine_provider/Cargo.toml index 52da304c..4cd1811d 100644 --- a/crates/engine_provider/Cargo.toml +++ b/crates/engine_provider/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "contender_engine_provider" -version.workspace = true +description = "Contender engine_ API provider" +version = "0.10.0" edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -description = "Contender engine_ API provider" [lib] name = "contender_engine_provider" diff --git a/crates/report/Cargo.toml b/crates/report/Cargo.toml index e4865c90..b938b739 100644 --- a/crates/report/Cargo.toml +++ b/crates/report/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "contender_report" -version.workspace = true +description = "Generate reports to analyze chain performance and orderflow from contender spam runs." +version = "0.10.0" edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/crates/sqlite_db/Cargo.toml b/crates/sqlite_db/Cargo.toml index 63c08101..418d5807 100644 --- a/crates/sqlite_db/Cargo.toml +++ b/crates/sqlite_db/Cargo.toml @@ -1,13 +1,13 @@ [package] +name = "contender_sqlite" +description = "SQLite database for contender" +version = "0.10.0" authors.workspace = true edition.workspace = true homepage.workspace = true license.workspace = true -name = "contender_sqlite" -description = "SQLite database for contender" repository.workspace = true rust-version.workspace = true -version.workspace = true [dependencies] alloy = { workspace = true } diff --git a/crates/testfile/Cargo.toml b/crates/testfile/Cargo.toml index 3f18b4e3..c91f1c4a 100644 --- a/crates/testfile/Cargo.toml +++ b/crates/testfile/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "contender_testfile" -version.workspace = true +description = "Definitions for contender scenarios to be encoded as TOML files." +version = "0.10.0" edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -description = "Definitions for contender scenarios to be encoded as TOML files." [dependencies] toml = { workspace = true } diff --git a/docs/library-usage.md b/docs/library-usage.md index cc1677eb..5d66d0ba 100644 --- a/docs/library-usage.md +++ b/docs/library-usage.md @@ -1,14 +1,19 @@ # Using Contender as a library -Add crates you need: + +Add crates you need (using the new per-crate tag scheme): ```toml [dependencies] -contender_core = { git = "https://github.com/flashbots/contender" } -contender_sqlite = { git = "https://github.com/flashbots/contender" } -contender_testfile = { git = "https://github.com/flashbots/contender" } +# Use the new tag format: _v +contender_core = { git = "https://github.com/flashbots/contender", tag = "contender_core_v0.11.0" } +contender_sqlite = { git = "https://github.com/flashbots/contender", tag = "contender_sqlite_v0.10.0" } +contender_testfile = { git = "https://github.com/flashbots/contender", tag = "contender_testfile_v0.10.1" } # recommended tokio = { version = "1.40.0", features = ["rt-multi-thread"] } ``` +> **Note:** +> Each crate is now versioned and tagged individually. Use the tag format `_v` for the crate you want to depend on. For example, to use version 0.10.1 of `contender_core`, use `tag = "contender_core_v0.10.1"`. + Example of contender being used as a library: [op-interop-contender](https://github.com/zeroxbrock/op-interop-contender) diff --git a/scripts/2_tag-version.sh b/scripts/2_tag-version.sh index 0f3ec48a..28992744 100755 --- a/scripts/2_tag-version.sh +++ b/scripts/2_tag-version.sh @@ -1,53 +1,157 @@ #!/bin/bash + set -e -if [ -z "$1" ]; then - echo "Usage: $0 " + + +# Enumerate crates by package name and map to their directory (POSIX-compatible) +CRATES_DIR="/Users/brock/code/contender/crates" +PKG_ARR=() +DIR_ARR=() +for dir in "$CRATES_DIR"/*/; do + [ -d "$dir" ] || continue + CARGO_TOML="$dir/Cargo.toml" + if [ -f "$CARGO_TOML" ]; then + PKG_NAME=$(grep '^name =' "$CARGO_TOML" | head -n1 | sed -E 's/name = "([^"]+)"/\1/') + if [ -n "$PKG_NAME" ]; then + PKG_ARR+=("$PKG_NAME") + DIR_ARR+=("${dir%/}") + fi + fi +done + +if [ ${#PKG_ARR[@]} -eq 0 ]; then + echo "No crates found in $CRATES_DIR" exit 1 fi -TAG="$1" -echo "tag: $TAG" +echo "Select a crate to tag (by package name):" +select CRATE in "${PKG_ARR[@]}"; do + if [ -n "$CRATE" ]; then + IDX=$((REPLY-1)) + CRATE_DIR="${DIR_ARR[$IDX]}" + # Remove trailing slash if present + CRATE_DIR="${CRATE_DIR%/}" + CARGO_TOML="$CRATE_DIR/Cargo.toml" + if [ ! -f "$CARGO_TOML" ]; then + echo "Cargo.toml not found for crate $CRATE" + echo "Checked path: $CARGO_TOML" + echo "Directory contents:" + ls -l "$CRATE_DIR" + exit 1 + fi + break + fi +done + -if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Tag must start with 'v' and follow semantic versioning (e.g., v1.2.3)" + +# Extract current version +CURRENT_VERSION=$(grep '^version' "$CARGO_TOML" | head -n1 | sed -E 's/version *= *"([0-9]+\.[0-9]+\.[0-9]+)"/\1/') +if [[ ! "$CURRENT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Could not determine current version for $CRATE" exit 1 fi + +# Preview version bumps for the selected crate +IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" +PATCH_NEXT=$((PATCH + 1)) +MINOR_NEXT=$((MINOR + 1)) +MAJOR_NEXT=$((MAJOR + 1)) + +PATCH_VERSION="v$MAJOR.$MINOR.$PATCH_NEXT" +MINOR_VERSION="v$MAJOR.$MINOR_NEXT.0" +MAJOR_VERSION="v$MAJOR_NEXT.0.0" + +echo "Current version: v$CURRENT_VERSION" +echo "Select version bump type:" +echo "1) patch -> $PATCH_VERSION" +echo "2) minor -> $MINOR_VERSION" +echo "3) major -> $MAJOR_VERSION" + +while true; do + read -p "Enter choice [1-3]: " bump_choice + case $bump_choice in + 1|patch) + BUMP="patch" + NEW_VERSION="${PATCH_VERSION#v}" + break + ;; + 2|minor) + BUMP="minor" + NEW_VERSION="${MINOR_VERSION#v}" + break + ;; + 3|major) + BUMP="major" + NEW_VERSION="${MAJOR_VERSION#v}" + break + ;; + *) + echo "Invalid choice. Please enter 1, 2, or 3." + ;; + esac +done + + +# Update the version in the selected crate's Cargo.toml (after bump selection) +if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "s/^version = \".*\"/version = \"$NEW_VERSION\"/" "$CARGO_TOML" +else + sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" "$CARGO_TOML" +fi +echo "Updated $CRATE version to $NEW_VERSION in $CARGO_TOML" + +TAG="${CRATE}_v${NEW_VERSION}" +echo "Will create tag: $TAG" + +confirmed=0 + confirm() { - read -p "$1 (y/N): " confirm - if [[ ! "$confirm" =~ ^[Yy] ]]; then - echo "Aborting." - exit 1 - fi + read -p "$1 (y/N): " confirm + if [[ ! "$confirm" =~ ^[Yy] ]]; then + echo "Aborting." + confirmed=0 + else + confirmed=1 + fi } -echo """Please confirm that the following tasks have been performed: - - run 1_change-version.sh - - check Cargo.lock to make sure the versions have been updated (run 'cargo build' if they haven't) - - push changes to a new 'release/' branch - - create & merge a PR w/ the new version changes -""" -confirm "Have you completed all the above tasks?" +undoVersionChange() { + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "s/^version = \".*\"/version = \"$CURRENT_VERSION\"/" "$CARGO_TOML" + else + sed -i "s/^version = \".*\"/version = \"$CURRENT_VERSION\"/" "$CARGO_TOML" + fi + echo "Reverted $CRATE version back to $CURRENT_VERSION in $CARGO_TOML" +} echo "Enter a message to attach to the tag. Press Enter twice to finish or CTRL-C to quit:" TAG_MESSAGE="" while true; do - IFS= read -r line - if [ -z "$line" ]; then - break - fi - TAG_MESSAGE="${TAG_MESSAGE}${line}\n" + IFS= read -r line + if [ -z "$line" ]; then + break + fi + TAG_MESSAGE="${TAG_MESSAGE}${line}\n" done if [ -z "$TAG_MESSAGE" ]; then - echo "No message entered. Aborting." - exit 1 + echo "No message entered. Aborting." + undoVersionChange + exit 1 fi git tag -a "$TAG" -m "$(echo -e "$TAG_MESSAGE")" confirm "Do you want to push this tag to the remote origin?" +if [ $confirmed -ne 1 ]; then + git tag -d "$TAG" + echo "Tag $TAG deleted locally. Aborting push." + undoVersionChange + exit 1 +fi git push origin "$TAG"