Skip to content

Add workflow: auto-release on PR merge to main#185

Open
Ankur-singh wants to merge 3 commits into
NVIDIA:mainfrom
Ankur-singh:feat/auto-release-on-merge
Open

Add workflow: auto-release on PR merge to main#185
Ankur-singh wants to merge 3 commits into
NVIDIA:mainfrom
Ankur-singh:feat/auto-release-on-merge

Conversation

@Ankur-singh
Copy link
Copy Markdown
Collaborator

@Ankur-singh Ankur-singh commented May 29, 2026

What

Adds .github/workflows/release.yaml — a GitHub Release is created automatically every time a PR is merged into main.

How it works

  • Trigger: pull_request closed on main, gated by merged == true (fires only on real merges, not closed-without-merge or direct pushes).
  • Versioning: bumps the patch of the highest existing GitHub Release (selected via sort -V), so release versions are independent of the in-code version. On the first run only (no release exists yet) it seeds the start at v1.0.0. Then v1.0.1, v1.0.2, …
    • Only the patch is auto-incremented, so you can publish a higher major/minor by hand (e.g. release v1.1.0) and the next merge continues from there → v1.1.1.
    • Basing on releases (not git tags) means the existing orphan v0.5.5.post2 tag is ignored with no special-casing.
  • Release: gh release create <tag> --target <merge_commit_sha> --generate-notes — tags the merge commit and generates notes from the merged PRs.
  • No write-back: never commits to main (so no trigger loop); pyproject.toml/__init__.py are untouched. Needs only contents: write.
  • Concurrency: a release group serializes near-simultaneous merges so they don't race on the same version.

Version logic (verified locally)

Existing releases Highest Next
none (first run) v1.0.0
v1.0.0 v1.0.0 v1.0.1
v1.0.9, v1.0.10 v1.0.10 v1.0.11
v1.0.3, v1.1.0 (manual minor bump) v1.1.0 v1.1.1

Validation

  • yaml.safe_load parses the workflow cleanly.
  • bash -n passes on the version-compute step.
  • Bump arithmetic + sort -V selection dry-run under bash across the scenarios above (incl. numeric ordering v1.0.10 > v1.0.9 and manual minor bumps).
  • Full end-to-end (tag + release creation) can only run in Actions — it will exercise on the first PR merged after this lands, producing v1.0.0.

Note: actionlint/shellcheck weren't available locally, so those static checks were skipped.

Creates a GitHub Release every time a PR is merged into main. The version
bumps the patch of the latest GitHub Release; on the first run (no release
yet) it seeds the starting point from pyproject.toml (v0.3.0). Release
versioning is independent of the in-code version after the seed, and the
workflow never commits back to main (no trigger loop).

Each release is tagged at the merge commit with auto-generated notes from
the merged PRs.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@20f6cde). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #185   +/-   ##
=======================================
  Coverage        ?   65.37%           
=======================================
  Files           ?       67           
  Lines           ?     8255           
  Branches        ?        0           
=======================================
  Hits            ?     5397           
  Misses          ?     2858           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Start the release series at v1.0.0 instead of seeding from pyproject.toml;
subsequent merges bump the patch (v1.0.1, v1.0.2, ...).
Select the highest existing release with 'sort -V' instead of the most
recently created one. Only the patch is incremented, so publishing a higher
major/minor by hand (e.g. v1.1.0) makes the next merge continue from there
(v1.1.1). Also fixes numeric ordering (v1.0.10 > v1.0.9).
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