Skip to content

ci: add manually invoked version-bump workflow - #160

Merged
webern merged 2 commits into
mainfrom
chore/version-bump-workflow
Oct 8, 2026
Merged

webern merged 2 commits into
mainfrom
chore/version-bump-workflow

Conversation

@webern

@webern webern commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Human Summary

Adds an actions program that can take the version number as an input, bump the version and open a PR. Optionally, it can run cargo update as well.

AI Summary

Adds .github/workflows/bump-version.yml, a workflow_dispatch workflow that:

  • takes a version input (no leading v, e.g. 3.4.1, format-validated) and an update_crates boolean
  • bumps the crate version in Cargo.toml (and Cargo.lock via cargo check)
  • optionally runs cargo update when update_crates is true
  • runs cargo check and only opens the PR chore: bump version to v<version> if it passes

Security posture follows release.yml: top-level contents: read, with the job scoped to contents: write + pull-requests: write, actions pinned by SHA, inputs validated before checkout, serialized via concurrency, and only runnable from main by users with write access (workflow_dispatch). Note that PRs created with GITHUB_TOKEN do not trigger other workflows, so the in-workspace cargo check is the verification gate.

@webern
webern requested a review from sshine September 26, 2026 15:32
@sshine

sshine commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

I have some thoughts, I will provide them tomorrow, 2026-09-28.

@sshine sshine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Using sed is a little brittle. Technically, the Cargo.toml format allows for multiple ^version.
    sed -i -E '0,/^version = "[^"]*"/s//version = "'"$VERSION"'"/' Cargo.toml.
    
    at least terminates at the first one.
  • cargo check seems like not enough: How about make ci?
  • If version is the current one and update_crates is false, git diff --quiet could short-circuit the CI and save quite a few minutes.
  • There is no "greater than the previous version" bounds check.
  • While release.yml has an unprivileged verify job, bump-version.yml does not.
  • # Nothing at the top level sits above permissions: contents: read, which is not nothing.

Split bump-version into an unprivileged verify job and a privileged
open-pr job that applies verify's patch. Verify now runs make ci, rejects
versions lower than the current one, rewrites only the first version
line of Cargo.toml, and skips the PR when nothing changed.
@webern

webern commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author
  • Using sed is a little brittle. Technically, the Cargo.toml format allows for multiple ^version.

    sed -i -E '0,/^version = "[^"]*"/s//version = "'"$VERSION"'"/' Cargo.toml.
    

    at least terminates at the first one.

  • cargo check seems like not enough: How about make ci?

  • If version is the current one and update_crates is false, git diff --quiet could short-circuit the CI and save quite a few minutes.

  • There is no "greater than the previous version" bounds check.

  • While release.yml has an unprivileged verify job, bump-version.yml does not.

  • # Nothing at the top level sits above permissions: contents: read, which is not nothing.

Looks like it fixed everything (see quote below). It decided to go with allowing a same version (i.e. no bump) which would then be able to update all deps without bumping the crate version. Seems fine to me. Good call on the permission splitting; fixed. Thank you.

How each comment was handled in .github/workflows/bump-version.yml:

  1. sed is brittle: I used his first-match form, so only the first version = line is rewritten. cargo metadata still confirms the new version, and cargo update --workspace updates our own entry in Cargo.lock without touching dependencies.
  2. cargo check isn't enough: it now runs make ci.
  3. Skip work when nothing changes: if Cargo.toml and Cargo.lock are unchanged, the run logs a notice and skips make ci and the PR.
  4. No "greater than the previous version" check: a version lower than the one in Cargo.toml is now rejected. The comparison follows semver rules, so 3.4.1-rc1 counts as lower than 3.4.1.
  5. No unprivileged verify job: it's now split like release.yml.
    • A read-only verify job makes the change, runs make ci, and uploads it as a patch.
    • An open-pr job is the only one with write access. It applies that patch to the same commit, pushes the branch and opens the PR. It runs only if verify passed and something changed.
  6. Misleading "Nothing at the top level" comment: it now says "Read-only by default; only the open-pr job is granted write access."

@webern
webern merged commit f6a3994 into main Oct 8, 2026
4 checks passed
@webern
webern deleted the chore/version-bump-workflow branch October 8, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants