Repository navigation
ci: prepare release PRs with the semver version and check tags against Cargo.toml - #23
jonas-dfns wants to merge 11 commits into
Conversation
…toml Semver Check runs cargo-semver-checks on monorepo sync PRs against the published crate and picks the smallest version it accepts (in 0.x a breaking change bumps the minor). Version Bump, triggered by workflow_run so it always runs from main, validates that result and commits it to the sync PR through the GitHub API, labels the release level, and disables auto-merge on breaking changes. Merging the sync PR now carries its version, with no separate release PR. publish.yaml gains a check-tag job that fails before the crates-io environment when the tag does not match the Cargo.toml version or is not on main.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution Review the following alerts detected in dependencies. According to your organization's Security Policy, you must resolve all "Block" alerts before proceeding. It is recommended to resolve "Warn" alerts too. Learn more about Socket for GitHub.
|
cargo-semver-checks reports the bump it requires but not the version, so run it once against the published crate and derive the number, instead of rerunning it for each candidate version. In 0.y.z its "major" means a y bump.
Semver Check now runs on all PRs, so hand-written changes (dependencies, Cargo.toml) also show their release impact through the release labels and, when breaking, a comment. The version is still only committed to monorepo sync PRs. The bump keeps the higher of the computed version and Cargo.toml, so an unreleased bump already on main (for example a merged breaking sync) is not lowered by a later patch-level sync. The breaking-change comment is updated in place instead of repeated.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
=======================================
Coverage 96.46% 96.46%
=======================================
Files 1 1
Lines 283 283
=======================================
Hits 273 273
Misses 10 10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The workflow now holds the branching: the validated result feeds a commit step that only runs on sync PRs whose version must change, and a label step that runs on every PR. Each script does one thing.
A sync PR must be opened by dfnsco-dfns-sdk-sync[bot] (by user ID) and contain only Verified web-flow commits authored by that app or by github-actions[bot] (the version commit). Anyone with write access can name a branch sdk-sync/, and a commit author can be set by email, but a pushed commit is never a Verified web-flow commit attributed to the app. Other PRs are labeled but never committed to.
commit-version.sh now checks the PR comes from the sync app before committing, so validation stays shared and each flow is self-contained. The label step suggests a version whenever this run did not set one. Clarify how 0.x versions bump and how to move to 1.0.0.
Version Bump is split into three jobs: validate (read-only), commit-version (sync PRs, release app token from the main-restricted sdk-release environment) and label (GITHUB_TOKEN, pull-requests only). GITHUB_TOKEN no longer needs contents: write. Version commits are now authored by the release app, which triggers the PR's CI, and the sync-PR check accepts commits from the sync app and the release app only. github-actions[bot] commits are no longer accepted, so a PR workflow with a write token cannot pass as a sync commit.
Environment sdk-semver, variable SEMVER_APP_CLIENT_ID and secret SEMVER_APP_PRIVATE_KEY.
Replace the version commit on sync PRs with a Prepare Release workflow (workflow_dispatch). It opens a chore(release) PR, as the dfns-sdk-semver app, that sets the version in Cargo.toml and Cargo.lock: the version cargo-semver-checks requires against the published crate, or the one given as input. A forced version is never blocked; the PR shows what cargo-semver-checks requires for reference. Semver Check on PRs becomes a read-only report. Removes the workflow_run job, the sync-PR identity checks and the labels.
The per-PR Semver Check only reported; Prepare Release computes and shows the required version when it opens the release PR.
Release tags are the Cargo.toml version without a v prefix (0.3.3), like the TS SDK. The release branch is release/X.Y.Z. The crates-io environment's tag rule (v*) must be changed to match.
Adds a release flow that sets the version for you (or takes yours) through a bot-made PR, and makes publishing refuse a tag that doesn't match
Cargo.toml.How it works
workflow_dispatch, optionalversioninput) opens the release PRchore(release): X.Y.Z:cargo-semver-checksrequires against the published crate (one run; the tool reports the bump level,next-version.shderives the number), and never lower thanCargo.tomlonmain(an unreleased bump is kept).X.Y.Z. It is never blocked; when it differs from whatcargo-semver-checksrequires, the PR says so for reference.release/X.Y.Zfrommainand commits only the version lines ofCargo.tomlandCargo.lock.dfns-sdk-semverapp, so the PR's CI runs. The PR body lists the breaking changes, if any.main.X.Y.Z(signed, bare version without av, like the TS SDK) to publish.publish.yamlnow triggers onX.Y.Ztags and gets acheck-tagjob that runs before thecrates-ioenvironment and fails if the tag is not theCargo.tomlversion or not onmain(the v0.3.1 failure mode).Later, step 3 can be automated (tag and publish when a
chore(release)PR from the app merges) without changing steps 1 and 2.Security
main. It has a job-levelif, and thesdk-semverenvironment that holds the app's credentials is restricted tomain. A copy of the workflow dispatched from another branch can't reach the key.GITHUB_TOKENstayscontents: readeverywhere.env:and is validated asX.Y.Zbefore use.cargo-semver-checksis pinned to 0.51.0 (cargo install --locked).Without it, Prepare Release fails at the token step. Publishing works without it.
Create the GitHub App
dfns-sdk-semver(owned bydfns):dfns/dfns-sdk-rustonly for now.Create the
sdk-semverenvironment indfns-sdk-rust:mainonly.SEMVER_APP_CLIENT_ID, secretSEMVER_APP_PRIVATE_KEY.Change the
crates-ioenvironment's deployment tag rule fromv*to[0-9]*.[0-9]*.[0-9]*, since release tags no longer start withv. Without it, publishing a new tag is refused.No ruleset is needed: the automation only writes to the release branches it creates.
Validation (Docker)
next-version.sh: against published 0.3.2 it gives0.3.3 patch; against 0.3.0 it gives0.4.0 minor breaking("8 major checks failed"). One run each.open-release-pr.shwith a stubbedgh:release/0.4.0branch, commitschore(release): 0.4.0(Cargo.toml →0.4.0), and opens the PR with the breaking-change list.cargo-semver-checksrequires, gets the same flow, with "For reference,cargo-semver-checksrequires0.4.0".actionlint1.7.12 andshellcheck0.10.0 are clean.🤖 Generated with Claude Code