Skip to content

Automate stable releases after version bumps on master - #673

Open
Aasav Badera (aasavbadera) wants to merge 3 commits into
masterfrom
aasavbadera/automate-version-bump-releases
Open

Aasav Badera (aasavbadera) wants to merge 3 commits into
masterfrom
aasavbadera/automate-version-bump-releases

Conversation

@aasavbadera

Copy link
Copy Markdown
Collaborator

Summary

Automate stable releases after synchronized version bumps land on protected master, without requiring maintainers to create a tag or publish a GitHub Release manually.

Follow-up to #670: that PR only changed release metadata, while release.yml only listened for tag pushes. The subsequent manual v6.0.5 release created a tag and automatically started the release run. Both SDKs were published to PyPI, but GitHub finalization failed with 422 tag_name already_exists.

Added

  • A prepare release workflow that compares the exact push before/after commits, validates synchronized stable project/lockfile versions and the changelog, creates an immutable version tag, and explicitly dispatches release.yml at that tag using GITHUB_TOKEN.
  • Read-only PR validation and 20 offline tests for release selection, shallow checkouts, tag conflicts, metadata validation, existing releases/assets, and interrupted finalization.
  • Release preparation and recovery documentation.

Changed

  • Separate release building, PyPI publishing, and GitHub finalization into dependent jobs using the same retained distribution artifact.
  • Preserve manual stable-tag pushes and add validated tag-based workflow_dispatch.
  • Scope write and OIDC permissions to the jobs that require them. Keep the release environment and existing PyPI trusted-publisher identity.
  • Use tooling-only Python 3.11 for standard-library TOML parsing and tests; retain the SDK/build Python compatibility.

Fixed

  • Version bumps on master now start the release flow automatically; ordinary pushes with unchanged versions do not publish.
  • Existing GitHub Releases no longer cause unconditional duplicate creation. Preserve their notes and unrelated assets, upload missing distributions, and reject conflicting asset content.
  • Failed GitHub finalization can be retried with Re-run failed jobs without rebuilding or republishing successful PyPI uploads.
  • Explicit dispatch avoids GitHub's suppression of push workflows for tags created with GITHUB_TOKEN.

Validation

Verified the exact six-file change locally:

  • 20 offline release tests passed, including temporary shallow Git repositories and mocked GitHub mutations.
  • actionlint passed for both changed workflows using the official checksum-verified validator.
  • poe check-format, poe lint, and poe types passed; the hidden release-tooling directory also passed an explicit type check.
  • uv lock --check --offline and git diff --check passed.
  • poe build produced both SDK wheels and source distributions; the new distribution gate verified their 6.0.5 names and metadata without publishing.
  • Replayed Bump version to 6.0.5 and update changelog #670's actual before/after Git snapshots and verified the expected tag/commit decision without mutations.
  • Read-only checks against GitHub verified existing tag/release responses and missing-tag HTTP 404 handling.

SDK source, project versions, dependency requirements, uv.lock, and the type-check baseline are unchanged. Full SDK/E2E suites were not run because SDK behavior is unchanged.

Rollout and safety

This PR does not bump versions, create production tags, dispatch a publishing workflow, alter v6.0.5, or publish packages. Its merge with unchanged versions must not trigger a release.

Repository/organization policy must allow the tag job's contents: write and actions: write permissions. The policy-inspection endpoint returned HTTP 403 for the current credentials, so policy verification and live end-to-end validation remain rollout prerequisites. No new PAT, GitHub App, or protection bypass is introduced.

Verify live automation at the next intentionally approved release version bump. Old tags and existing runs retain their original workflow definitions; this change does not repair the previous v6.0.5 run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The release flow misses existing drafts during retries, mishandles incomplete upload assets and successful empty dispatch responses, and lacks pre-merge release-metadata validation.

4 open issues
What changed in this PR

This PR extends #670’s release-preparation work by automating stable SDK releases after synchronized version bumps reach protected master, without requiring manual tag or GitHub Release creation.

Changes:

  • Select the exact pushed commit, validate release metadata, create an immutable version tag, and explicitly dispatch publishing.
  • Separate building, PyPI publishing, and GitHub finalization, retaining distributions for failed-job recovery.
  • Add offline release-tooling tests, read-only PR test execution, and release/recovery documentation while preserving SDK Python compatibility.
File Description
pyproject.toml Assigns Python 3.11 to release-tooling type checks while retaining the SDK baseline.
CONTRIBUTING.md Documents automatic releases, permissions, manual dispatch, and recovery procedures.
.github/​workflows/​tag-release.yml Adds tooling tests and master-push release selection, tagging, and dispatch.
.github/​workflows/​release.yml Splits release stages, retains artifacts, and scopes job permissions.
.github/​scripts/​test_release_tools.py Adds 20 offline tests covering release selection, validation, and recovery.
.github/​scripts/​release_tools.py Implements release planning, tag validation, dispatch, distribution checks, and GitHub finalization.

Review effort: Max

Comment thread .github/scripts/release_tools.py Resolved
Comment thread .github/scripts/release_tools.py Resolved
Comment thread .github/scripts/release_tools.py Resolved
Comment thread .github/workflows/tag-release.yml Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Finalization can leave an existing release for a stable tag marked as a prerelease, preventing it from qualifying as GitHub’s latest stable release.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Clear prerelease flag when finalizing recovered releases

.github/​scripts/​release_tools.py:370

If an existing release or draft for this stable tag has prerelease: true, finalization succeeds but leaves it marked as a prerelease: drafts only get draft: false, and published releases aren't patched at all. Unlike newly created releases, the recovered release cannot qualify as GitHub's latest stable release. Clear the prerelease flag when finalizing existing prereleases, while preserving their notes and assets.

4 resolved since last review

Review effort: Max

@aasavbadera

Copy link
Copy Markdown
Collaborator Author

Addressed the Clear prerelease flag when finalizing recovered releases finding from Copilot's follow-up review in 6450be8.

Finalization now clears prerelease: true on both recovered drafts and already-published releases for stable tags, after asset reconciliation succeeds. It publishes drafts as before and patches only the required flags, preserving authored notes and existing assets. Already-stable published releases receive no metadata update.

Validation: the new regression failed for both recovery states before the fix. All 28 offline release tests now pass, along with repository formatting/lint and explicit release-tooling Ruff/type checks. The recovery behavior is documented. No production tags, releases, publishing dispatches, or packages were changed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The version check rejects corrective PRs that unify mixed project versions after a partial administrator bump, blocking the documented recovery path even when the lockfile and changelog are valid.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Allow corrective PRs to restore consistent project versions

.github/​scripts/​release_tools.py:148

After a partial administrator bump leaves master with mixed project versions, this check also rejects a PR that repairs all projects to one valid version. That blocks the documented recovery path in CONTRIBUTING.md:249–251, even when the corrected lockfile and changelog are valid. Validate corrective PR snapshots separately while keeping automatic release selection disabled for inconsistent bases, and add a regression test for this case.

Review effort: Max

Validate synchronized release metadata, create immutable tags, and explicitly dispatch tagged publishing. Separate GitHub release finalization from PyPI publication for safe recovery and preserve existing releases and assets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 31ae2ff7-b8f6-406d-b492-10d598bb9070
Resume matching draft releases, request dispatch run details and accept successful empty responses, and safely replace only empty starter upload placeholders. Validate changed release metadata on read-only PR events using the same checks as master pushes and document recovery after failed preparation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 31ae2ff7-b8f6-406d-b492-10d598bb9070
Normalize recovered draft and published releases after asset reconciliation.
Patch only the required flags and preserve authored notes and assets.
Cover both recovery states with a focused regression and document behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 31ae2ff7-b8f6-406d-b492-10d598bb9070

This branch has not been deployed

No deployments
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