From b3432b2ce0ae458fd68b0f519f5753e48a787b1d Mon Sep 17 00:00:00 2001 From: meh Date: Sun, 13 Sep 2026 14:44:54 +0700 Subject: [PATCH] ci: publish reviewed version bumps from master --- .github/workflows/rust.yml | 16 ++++++ Cargo.toml | 2 +- README.md | 26 ++------- release.toml | 19 ------- scripts/release.sh | 114 ------------------------------------- 5 files changed, 23 insertions(+), 154 deletions(-) delete mode 100644 release.toml delete mode 100755 scripts/release.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8e3c8fc..b4c89af 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -104,3 +104,19 @@ jobs: - uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} + + publish: + if: >- + github.event_name == 'push' && + github.ref == 'refs/heads/master' && + contains(github.event.head_commit.modified, 'Cargo.toml') + needs: [test, clippy_check, format_check, security_audit] + runs-on: ubicloud-standard-2 + steps: + - name: Checkout code + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable + - name: Publish a reviewed version bump + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: cargo publish --registry crates-io diff --git a/Cargo.toml b/Cargo.toml index adfd770..c182168 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "endpoint-libs" -version = "3.0.1" +version = "3.0.2" edition = "2024" authors = ["Veon "] description = "Launch MCP services fast: describe endpoints once in RON, and endpoint-gen generates the Rust models, docs and MCP tool schemas that this crate serves over WebSocket RPC, with roles and typed errors built in." diff --git a/README.md b/README.md index d15bca1..c83dcc8 100644 --- a/README.md +++ b/README.md @@ -513,27 +513,13 @@ A `load_config` utility parses a JSON config file, defaulting to `etc/config.jso ## Releasing -Releases are managed with [`cargo-release`](https://github.com/crate-ci/cargo-release) and [`git-cliff`](https://github.com/orhun/git-cliff). Both must be installed: +Put the `Cargo.toml` version bump in a pull request. After merge, the Rust +workflow waits for tests, clippy, formatting, and the security audit, then runs +`cargo publish` when the package version changed in that `master` update. The +workflow uses the repository's `CARGO_REGISTRY_TOKEN` secret. -```sh -cargo install cargo-release git-cliff -``` - -To cut a release: - -```sh -./scripts/release.sh [--skip-bump] -``` - -The script will: -1. Run `cargo release --execute ` — bumps the version in `Cargo.toml`, updates the deps.rs badge in this README, regenerates `CHANGELOG.md`, and commits everything as `chore(release): vX.Y.Z`. -2. Open your `$EDITOR` with the auto-generated tag notes (from `git-cliff`) for review. -3. Create an annotated tag using the edited notes as the tag body (shown as GitHub Release notes). -4. Push the commit and tag. -5. Prompt whether to publish to crates.io. - -To preview what `cargo-release` would do without making changes: +To verify the package locally without publishing: ```sh -cargo release patch # omit --execute for a dry run +cargo publish --dry-run ``` diff --git a/release.toml b/release.toml deleted file mode 100644 index 56e6757..0000000 --- a/release.toml +++ /dev/null @@ -1,19 +0,0 @@ -allow-branch = ["master"] -sign-commit = false -sign-tag = false -push = false # script handles push (tag message must be set first) -tag = false # script handles tag (uses git-cliff content as body) -publish = false # script handles publish (interactive prompt) -pre-release-commit-message = "chore(release): v{{version}}" - -pre-release-hook = ["git", "cliff", "--tag", "v{{version}}", "--output", "CHANGELOG.md"] - -[[pre-release-replacements]] -file = "README.md" -search = 'deps\.rs/crate/endpoint-libs/[^/]+/status\.svg' -replace = "deps.rs/crate/endpoint-libs/{{version}}/status.svg" - -[[pre-release-replacements]] -file = "README.md" -search = '\]\(https://deps\.rs/crate/endpoint-libs/[^\)/]+\)' -replace = "](https://deps.rs/crate/endpoint-libs/{{version}})" diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index 6dd3d80..0000000 --- a/scripts/release.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Usage: ./scripts/release.sh [--skip-bump] [--no-tag] - -REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" -CARGO_TOML="$REPO_ROOT/Cargo.toml" -CRATE_NAME=$(grep '^name' "$CARGO_TOML" | head -1 | sed 's/.*"\(.*\)".*/\1/') - -SKIP_BUMP=false -NO_TAG=false -while [[ "${1:-}" == --* ]]; do - case "${1}" in - --skip-bump) SKIP_BUMP=true ;; - --no-tag) NO_TAG=true ;; - *) echo "Unknown option: $1" >&2; exit 1 ;; - esac - shift -done - -LEVEL="${1:-}" -if [[ "$LEVEL" != "patch" && "$LEVEL" != "minor" && "$LEVEL" != "major" && "$LEVEL" != "release" ]]; then - echo "Usage: $0 [--skip-bump] [--no-tag] " >&2 - exit 1 -fi - -# Check required tools -for tool in cargo-release git-cliff; do - if ! command -v "$tool" &>/dev/null; then - echo "Error: '$tool' is not installed. Run: cargo install $tool" >&2 - exit 1 - fi -done - -# Ensure working tree is clean -if ! git -C "$REPO_ROOT" diff --quiet || ! git -C "$REPO_ROOT" diff --cached --quiet; then - echo "Error: working tree has uncommitted changes. Please commit or stash them first." >&2 - exit 1 -fi - -if [ "$SKIP_BUMP" = false ]; then - echo "Running cargo-release $LEVEL ..." - cargo release --manifest-path "$CARGO_TOML" --execute --no-confirm "$LEVEL" - echo "" -fi - -# Read version (current if --skip-bump, bumped if not) -VERSION=$(grep '^version' "$CARGO_TOML" | head -1 | sed 's/.*"\(.*\)".*/\1/') -TAG="v$VERSION" - -if [ -z "$VERSION" ]; then - echo "Error: could not read version from Cargo.toml" >&2 - exit 1 -fi - -if [ "$NO_TAG" = false ]; then - echo "Preparing tag notes for $TAG..." - - # Generate tag notes with git-cliff, open in editor for review - TMPFILE=$(mktemp /tmp/release_notes.XXXXXX) - git -C "$REPO_ROOT" cliff --latest --strip all > "$TMPFILE" - - EDITOR_CMD="${VISUAL:-${EDITOR:-}}" - if [ -z "$EDITOR_CMD" ]; then - for e in nano vim vi; do - if command -v "$e" &>/dev/null; then - EDITOR_CMD="$e" - break - fi - done - fi - if [ -z "$EDITOR_CMD" ]; then - echo "Error: no editor found. Set \$VISUAL or \$EDITOR." >&2 - rm -f "$TMPFILE" - exit 1 - fi - $EDITOR_CMD "$TMPFILE" - - TAG_MESSAGE=$(cat "$TMPFILE") - rm -f "$TMPFILE" - - if [ -z "$TAG_MESSAGE" ]; then - echo "Error: tag message is empty, aborting." >&2 - exit 1 - fi - - # Create annotated tag with cliff-generated notes - echo "Tagging $TAG ..." - git -C "$REPO_ROOT" tag -a "$TAG" -m "$TAG_MESSAGE" - - # Push commit and tag - echo "Pushing commit and tag..." - git -C "$REPO_ROOT" push origin HEAD "$TAG" -else - # Push commit only - echo "Pushing commit..." - git -C "$REPO_ROOT" push origin HEAD -fi - -echo "" - -# Optionally publish to crates.io -CRATES_IO_STATUS=$(curl -sf "https://crates.io/api/v1/crates/$CRATE_NAME/$VERSION" -o /dev/null -w "%{http_code}" || true) -if [ "$CRATES_IO_STATUS" = "200" ]; then - echo "Version $VERSION is already published to crates.io, skipping." -else - read -r -p "Publish $TAG to crates.io? [y/N] " CONFIRM - if [[ "$CONFIRM" =~ ^[Yy]$ ]]; then - cargo publish --manifest-path "$CARGO_TOML" - echo "Published $TAG to crates.io" - else - echo "Skipping crates.io publish." - fi -fi