From f02e3eb27f19474ad1546b528ac22ca259b98b22 Mon Sep 17 00:00:00 2001 From: imshubham22apr-gif Date: Wed, 11 Nov 2026 00:16:45 +0530 Subject: [PATCH] feat(ci): automate label-based release versioning with Release Drafter (Resolves #23) Signed-off-by: imshubham22apr-gif --- .github/release-drafter.yml | 92 +++++++++++++++ .github/workflows/prepare-release.yml | 72 ++++++++++++ .github/workflows/release.yml | 101 +++++++++++----- CONTRIBUTING.md | 51 +++++++- tests/tools/test_release_version.py | 145 +++++++++++++++++++++++ tools/validate_release_version.py | 161 ++++++++++++++++++++++++++ 6 files changed, 588 insertions(+), 34 deletions(-) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/prepare-release.yml create mode 100644 tests/tools/test_release_version.py create mode 100644 tools/validate_release_version.py diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..88fd640 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,92 @@ +--- +name-template: "v$RESOLVED_VERSION" +tag-template: "v$RESOLVED_VERSION" +include-pre-releases: true +template: | + # Changelog + $CHANGES + + See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release + +exclude-labels: + - "skip-changelog" + +categories: + - title: "💥 Breaking Changes" + labels: + - "breaking" + - "major" + - "release:major" + - title: "🚀 Features" + labels: + - "feature" + - "enhancement" + - "minor" + - "release:minor" + - title: "🐛 Bug Fixes" + labels: + - "fix" + - "bugfix" + - "bug" + - "patch" + - "release:patch" + - title: "🧰 Maintenance" + labels: + - "infrastructure" + - "automation" + - "documentation" + - "dependencies" + - "maintenance" + - "revert" + - title: "🏎 Performance" + labels: + - "performance" + +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" + +version-resolver: + major: + labels: + - "breaking" + - "major" + - "release:major" + minor: + labels: + - "feature" + - "enhancement" + - "minor" + - "release:minor" + patch: + labels: + - "fix" + - "documentation" + - "maintenance" + - "patch" + - "release:patch" + default: patch + +autolabeler: + - label: "automation" + title: + - "/^(build|ci|perf|refactor|test).*/i" + - label: "enhancement" + title: + - "/^(style).*/i" + - label: "documentation" + title: + - "/^(docs).*/i" + - label: "feature" + title: + - "/^(feat).*/i" + - label: "fix" + title: + - "/^(fix).*/i" + - label: "infrastructure" + title: + - "/^(infrastructure).*/i" + - label: "maintenance" + title: + - "/^(chore|maintenance).*/i" + - label: "revert" + title: + - "/^(revert).*/i" diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..1392d05 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,72 @@ +name: Prepare Release + +on: + workflow_dispatch: + inputs: + version: + description: "Release version to prepare (X.Y.Z without v prefix)" + required: true + type: string + +permissions: + contents: read + +jobs: + prepare: + name: Prepare Release PR + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + with: + enable-cache: false + + - name: Validate target version and active draft + env: + TARGET_VERSION: ${{ inputs.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPOSITORY: ${{ github.repository }} + run: | + uv run python tools/validate_release_version.py \ + --version "$TARGET_VERSION" \ + --repo "$REPOSITORY" + + - name: Update version and lockfile + env: + TARGET_VERSION: ${{ inputs.version }} + run: | + uv version "$TARGET_VERSION" + uv lock --check + + - name: Verify build and test suite + run: | + uv run poe test + uv run poe lint + uv run ruff format --check . + uv run poe typecheck + uv build + + - name: Create or update release preparation pull request + uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.8 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: release-prep/v${{ inputs.version }} + delete-branch: false + title: "chore: prepare release v${{ inputs.version }}" + body: | + Release preparation for version `${{ inputs.version }}`. + + This PR updates the package version in `pyproject.toml` and ensures `uv.lock` remains synchronized. + + - Tag: `v${{ inputs.version }}` + - Excluded from release notes and version calculation via `skip-changelog`. + commit-message: "chore: prepare release v${{ inputs.version }}" + labels: | + release + skip-changelog diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17d1898..b27ab84 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,77 @@ -name: Release +--- +name: "Release" on: + workflow_dispatch: push: - tags: ["v*"] + branches: + - main -permissions: - contents: read +concurrency: + group: release + cancel-in-progress: false + queue: max jobs: - build: - name: Build and verify + release: + permissions: + contents: write # Create release and push tags + pull-requests: read # Read PR labels for release-drafter + packages: write # Push container image to ghcr.io + id-token: write # Federate for artifact attestation + attestations: write # Generate build provenance attestations + discussions: write # Create release announcement discussion + uses: github-community-projects/ospo-reusable-workflows/.github/workflows/release.yaml@ee8277bd76ef808b3a6e0bdd1f5a46a520a12c5d # v2.3.1 + with: + publish: true + release-config-name: release-drafter.yml + release-only-with-label: true + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + + publish-pypi: + name: Build and publish to PyPI + needs: release + if: needs.release.outputs.full-tag != '' runs-on: ubuntu-latest + environment: pypi + permissions: + contents: read + id-token: write # For PyPI trusted publishing steps: + - name: Validate release tag format + env: + TAG: ${{ needs.release.outputs.full-tag }} + run: | + uv run python -c ' + import os, re, sys + tag = os.environ.get("TAG", "") + if not re.match(r"^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$", tag): + print(f"::error::Release tag \"{tag}\" must follow stable semver format vX.Y.Z", file=sys.stderr) + sys.exit(1) + ' + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + ref: ${{ needs.release.outputs.full-tag }} persist-credentials: false + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: - # The release path builds the artifacts that get published, so it must - # not restore a cache that a pull request workflow could have poisoned. enable-cache: false + - run: uv sync --frozen + - name: Verify the tag matches the static version + env: + TAG: ${{ needs.release.outputs.full-tag }} run: | - # Artifacts must never ship as 0.0.0, and the tag is the only thing - # that should ever disagree with pyproject.toml. declared="$(uv run python -c 'import tomllib,pathlib; print(tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]["version"])')" - tagged="${GITHUB_REF_NAME#v}" + tagged="${TAG#v}" test "$declared" != "0.0.0" || { echo "::error::version is 0.0.0"; exit 1; } test "$declared" = "$tagged" || { echo "::error::tag $tagged does not match pyproject version $declared"; exit 1; } + - run: uv run pytest -q - name: Regenerate models from the vendored schema run: uv run poe generate @@ -38,38 +80,37 @@ jobs: - run: uv run ruff format --check . - run: uv run poe typecheck - run: uv build - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: dist - path: dist/ - publish-pypi: - name: Publish to PyPI - needs: build - runs-on: ubuntu-latest - environment: pypi - permissions: - # Trusted publishing: mint a short-lived OIDC token instead of holding a - # long-lived PyPI API token in repository secrets. - id-token: write - steps: - - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - name: dist - path: dist/ + - name: Verify built artifact version matches pyproject.toml + env: + TAG: ${{ needs.release.outputs.full-tag }} + run: | + version="${TAG#v}" + test -f "dist/gemara_python-${version}.tar.gz" || { + echo "::error::Source archive dist/gemara_python-${version}.tar.gz missing"; exit 1; } + test -f "dist/gemara_python-${version}-py3-none-any.whl" || { + echo "::error::Wheel dist/gemara_python-${version}-py3-none-any.whl missing"; exit 1; } + - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 verify-published: name: Test the PyPI package - needs: publish-pypi + needs: [release, publish-pypi] + if: needs.release.outputs.full-tag != '' runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + ref: ${{ needs.release.outputs.full-tag }} persist-credentials: false + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: enable-cache: false + - name: Wait for PyPI index propagation run: sleep 60 + - uses: $/.github/actions/verify-published-package diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5a87f1..5dc1ae1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,7 +64,50 @@ Publishing uses Trusted Publishing (OIDC); no API tokens are stored. The publisher registered on each index. - **Rehearse:** run the *Publish to TestPyPI* workflow manually - (`workflow_dispatch`) against any ref or push a test tag matching `test-vX.Y.X`. -- **Release:** set `version` in `pyproject.toml`, then push a matching `vX.Y.Z` - tag. The release workflow refuses a tag that disagrees with that version, and - refuses `0.0.0` outright. + (`workflow_dispatch`) against any ref or push a test tag matching `test-vX.Y.Z`. + +### Release Versioning Policy + +Release Drafter automatically maintains a draft release on GitHub as pull requests are merged into `main`. The next version is resolved from PR labels using SemVer: + +- `release:major` / `major` / `breaking`: increments major version (`X+1.0.0`, e.g. `0.1.0` -> `1.0.0` or `1.2.3` -> `2.0.0`). +- `release:minor` / `minor` / `feature` / `enhancement`: increments minor version (`X.Y+1.0`, e.g. `0.1.0` -> `0.2.0`). +- `release:patch` / `patch` / `fix`: increments patch version (`X.Y.Z+1`, e.g. `0.1.0` -> `0.1.1`). + +**Rules & Precedence:** +- **Baseline and pre-releases:** `include-pre-releases: true` is configured so that the existing `v0.1.0` pre-release acts as the baseline for change aggregation and next-version resolution. +- **Highest increment wins:** When multiple merged PRs carry different release labels, the highest bump applies (`major` > `minor` > `patch`). +- **Unlabeled PR fallback:** Pull requests merged without a release label default to a `patch` increment. +- **Exclusion of release preparation PRs:** Pull requests labeled `skip-changelog` (such as automated release-preparation PRs) are excluded from both changelog notes and version calculation. + +### Maintainer Release Process + +This repository uses the shared organization release workflow from [`github-community-projects/ospo-reusable-workflows`](https://github.com/github-community-projects/ospo-reusable-workflows) (pinned at `v2.3.1`). + +1. **Check the Draft Release:** + Inspect the active draft release under GitHub Releases. Verify the draft release notes and resolved tag (e.g., `v0.2.0`). + +2. **Run the Version-Preparation Workflow:** + Trigger the *Prepare Release* workflow (`.github/workflows/prepare-release.yml`) via `workflow_dispatch`, passing the target version without the `v` prefix (e.g. `0.2.0`). + The workflow: + - Validates that the target version is a stable `X.Y.Z` semver, is strictly newer than the latest published release, and matches the active draft tag. + - Updates `pyproject.toml` with `uv version ""` and verifies `uv.lock` with `uv lock --check`. + - Runs test, lint, formatting, typechecking, and package build checks. + - Opens or updates a release-preparation pull request targeting `main` with the `release` and `skip-changelog` labels on branch `release-prep/v`. Re-running for the same version updates the existing PR without creating duplicates. + + *Note on workflow permissions:* If the PR is created using GitHub Actions default `GITHUB_TOKEN`, GitHub branch protection or actions policies may require a maintainer approval before CI runs on the PR. + +3. **Review and Merge the Version PR:** + Review and merge the release-preparation PR into `main` with the `release` label. + +4. **Automated Release and PyPI Publishing:** + When the version PR carrying the `release` label is merged to `main`, `.github/workflows/release.yml` executes: + - Runs `github-community-projects/ospo-reusable-workflows/.github/workflows/release.yaml` to finalize and publish the GitHub release with tags `vX.Y.Z` and `vX`. + - Directly executes the chained `publish-pypi` job in the same run to verify and publish the package to PyPI via Trusted Publishing (`id-token: write`). + - Runs `verify-published` to test the published package on the live PyPI index. + +### Troubleshooting & Mismatch Resolution + +- **Draft / Tag / Package version mismatch:** If `pyproject.toml` does not match the published release tag `vX.Y.Z`, the release workflow fails immediately before building or publishing. Re-run *Prepare Release* for the matching version and ensure the PR is merged into `main` before publishing the release. +- **Lockfile mismatch:** If `uv.lock` is out of sync, `uv lock --check` fails during the preparation workflow. Run `uv lock` locally or re-sync dependencies. +- **Already published:** The validation script and PyPI trusted publishing prevent re-publishing an existing version. diff --git a/tests/tools/test_release_version.py b/tests/tools/test_release_version.py new file mode 100644 index 0000000..58edea2 --- /dev/null +++ b/tests/tools/test_release_version.py @@ -0,0 +1,145 @@ +"""Tests for release version validation logic, label policy simulation, and YAML schema checking.""" + +from __future__ import annotations + +import pathlib +from typing import Any + +import pytest +import validate_release_version +import yaml +from validate_release_version import parse_semver + + +def test_parse_semver_valid() -> None: + assert parse_semver("0.1.0") == (0, 1, 0) + assert parse_semver("0.1.1") == (0, 1, 1) + assert parse_semver("0.2.0") == (0, 2, 0) + assert parse_semver("1.0.0") == (1, 0, 0) + assert parse_semver("10.20.30") == (10, 20, 30) + + +@pytest.mark.parametrize( + "invalid", + [ + "v1.0.0", + "1.0", + "1.0.0-rc.1", + "1.0.0+build123", + "01.1.0", + "1.0.0b1", + "random", + "", + ], +) +def test_parse_semver_invalid(invalid: str) -> None: + with pytest.raises(ValueError, match="Invalid version"): + parse_semver(invalid) + + +def resolve_version_from_config( + current_version: str, + merged_pr_labels: list[list[str]], + config: dict[str, Any], +) -> str: + """Resolves the next version directly based on the parsed Release Drafter YAML config.""" + major, minor, patch = parse_semver(current_version) + + exclude_labels: set[str] = set(config.get("exclude-labels", [])) + resolver: dict[str, Any] = config.get("version-resolver", {}) + + major_labels: set[str] = set(resolver.get("major", {}).get("labels", [])) + minor_labels: set[str] = set(resolver.get("minor", {}).get("labels", [])) + patch_labels: set[str] = set(resolver.get("patch", {}).get("labels", [])) + default_bump: str = resolver.get("default", "patch") + + bump_major = False + bump_minor = False + bump_patch = False + + for labels in merged_pr_labels: + # Pre-exclusion: if PR has any excluded label, it is skipped + if any(lbl in exclude_labels for lbl in labels): + continue + + matched = False + if any(lbl in major_labels for lbl in labels): + bump_major = True + matched = True + elif any(lbl in minor_labels for lbl in labels): + bump_minor = True + matched = True + elif any(lbl in patch_labels for lbl in labels): + bump_patch = True + matched = True + + if not matched: + if default_bump == "patch": + bump_patch = True + elif default_bump == "minor": + bump_minor = True + elif default_bump == "major": + bump_major = True + + if bump_major: + return f"{major + 1}.0.0" + elif bump_minor: + return f"{major}.{minor + 1}.0" + elif bump_patch: + return f"{major}.{minor}.{patch + 1}" + else: + return current_version + + +def test_release_drafter_yaml_configuration() -> None: + config_path = pathlib.Path(".github/release-drafter.yml") + assert config_path.exists(), ".github/release-drafter.yml must exist" + + with open(config_path, encoding="utf-8") as f: + config: dict[str, Any] = yaml.safe_load(f) + + assert config.get("include-pre-releases") is True + assert "skip-changelog" in config.get("exclude-labels", []) + assert config.get("name-template") == "v$RESOLVED_VERSION" + assert config.get("tag-template") == "v$RESOLVED_VERSION" + + resolver = config.get("version-resolver", {}) + assert "release:major" in resolver.get("major", {}).get("labels", []) + assert "release:minor" in resolver.get("minor", {}).get("labels", []) + assert "release:patch" in resolver.get("patch", {}).get("labels", []) + assert resolver.get("default") == "patch" + + # Test all scenarios directly against the loaded YAML config + baseline = "0.1.0" + + # 1. Patch label: 0.1.0 -> 0.1.1 + assert resolve_version_from_config(baseline, [["release:patch"]], config) == "0.1.1" + + # 2. Minor label: 0.1.0 -> 0.2.0 + assert resolve_version_from_config(baseline, [["release:minor"]], config) == "0.2.0" + + # 3. Major label: 0.1.0 -> 1.0.0 + assert resolve_version_from_config(baseline, [["release:major"]], config) == "1.0.0" + + # 4. Minor and patch labels across merged PRs: Minor wins + assert resolve_version_from_config(baseline, [["release:patch"], ["release:minor"]], config) == "0.2.0" + assert resolve_version_from_config(baseline, [["release:patch", "release:minor"]], config) == "0.2.0" + + # 5. Major and minor labels across merged PRs: Major wins + assert resolve_version_from_config(baseline, [["release:minor"], ["release:major"]], config) == "1.0.0" + assert resolve_version_from_config(baseline, [["release:major", "release:minor"]], config) == "1.0.0" + + # 6. No release label on a merged PR: Patch fallback applies + assert resolve_version_from_config(baseline, [[]], config) == "0.1.1" + assert resolve_version_from_config(baseline, [["dependencies", "python:uv"]], config) == "0.1.1" + + # 7. Release-preparation PR labeled skip-changelog: Excluded from notes and version resolution + assert resolve_version_from_config(baseline, [["skip-changelog"]], config) == "0.1.0" + assert resolve_version_from_config(baseline, [["skip-changelog", "release:major"]], config) == "0.1.0" + + # 8. skip-changelog along with a normal unlabeled PR + assert resolve_version_from_config(baseline, [["skip-changelog"], ["dependencies"]], config) == "0.1.1" + + +def test_gh_api_helpers_presence() -> None: + assert callable(validate_release_version.gh_api_request) diff --git a/tools/validate_release_version.py b/tools/validate_release_version.py new file mode 100644 index 0000000..445a545 --- /dev/null +++ b/tools/validate_release_version.py @@ -0,0 +1,161 @@ +"""Validation helper for release preparation. + +Validates that an input version is a stable semantic version (X.Y.Z), +is strictly newer than the latest published release, matches the active +Release Drafter draft tag, and does not collide with an existing tag or release. +""" + +from __future__ import annotations + +import argparse +import json +import os +import pathlib +import re +import sys +import tomllib +import urllib.error +import urllib.request +from typing import Any + +SEMVER_REGEX = re.compile(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$") + + +def parse_semver(version: str) -> tuple[int, int, int]: + match = SEMVER_REGEX.match(version) + if not match: + raise ValueError( + f"Invalid version '{version}'. Expected a stable semver in X.Y.Z format " + "without prefixes or prerelease tags." + ) + return int(match.group(1)), int(match.group(2)), int(match.group(3)) + + +def gh_api_request(endpoint: str, token: str) -> Any: + url = f"https://api.github.com{endpoint}" + req = urllib.request.Request( + url, + headers={ + "Authorization": f"Bearer {token}", + "Accept": "application/vnd.github+json", + "User-Agent": "gemara-python-release-validation", + "X-GitHub-Api-Version": "2022-11-28", + }, + ) + with urllib.request.urlopen(req) as resp: + return json.loads(resp.read().decode("utf-8")) + + +def main() -> None: + parser = argparse.ArgumentParser(description="Validate release version preparation.") + parser.add_argument("--version", required=True, help="Target release version (X.Y.Z)") + parser.add_argument("--repo", required=True, help="GitHub repository (owner/name)") + args = parser.parse_args() + + target_version = args.version.strip() + repo = args.repo.strip() + + try: + target_tuple = parse_semver(target_version) + except ValueError as e: + print(f"::error::{e}", file=sys.stderr) + sys.exit(1) + + # Check against currently declared pyproject.toml version + pyproject_path = pathlib.Path("pyproject.toml") + if pyproject_path.exists(): + pyproject_data = tomllib.loads(pyproject_path.read_text(encoding="utf-8")) + declared_version = pyproject_data.get("project", {}).get("version") + if declared_version == target_version: + print( + f"::error::Target version '{target_version}' is already the declared version in pyproject.toml.", + file=sys.stderr, + ) + sys.exit(1) + + token = os.environ.get("GITHUB_TOKEN") + if not token: + print("::error::GITHUB_TOKEN environment variable is required", file=sys.stderr) + sys.exit(1) + + # 1. Fetch all releases from GitHub to find the latest published release and check for drafts + releases = gh_api_request(f"/repos/{repo}/releases?per_page=100", token) + + draft_releases = [r for r in releases if r.get("draft") is True] + published_releases = [r for r in releases if not r.get("draft") and not r.get("prerelease")] + # If no non-prerelease published releases exist, include prereleases as published baseline + if not published_releases: + published_releases = [r for r in releases if not r.get("draft")] + + # Check if target tag/release already exists + target_tag = f"v{target_version}" + for r in releases: + if not r.get("draft") and r.get("tag_name") == target_tag: + print( + f"::error::A published release with tag '{target_tag}' already exists in {repo}.", + file=sys.stderr, + ) + sys.exit(1) + + # Check git tags directly in the repo + try: + tag_check = gh_api_request(f"/repos/{repo}/git/ref/tags/{target_tag}", token) + if tag_check: + print( + f"::error::A git tag '{target_tag}' already exists in {repo}.", + file=sys.stderr, + ) + sys.exit(1) + except urllib.error.HTTPError as e: + if e.code != 404: + raise + + # 2. Validate that target version is newer than the latest published release + latest_published_tag: str | None = None + latest_published_tuple: tuple[int, int, int] = (0, 0, 0) + for r in published_releases: + tag_name = r.get("tag_name", "") + clean_tag = tag_name[1:] if tag_name.startswith("v") else tag_name + try: + parsed = parse_semver(clean_tag) + if parsed > latest_published_tuple: + latest_published_tuple = parsed + latest_published_tag = tag_name + except ValueError: + continue + + if latest_published_tag and target_tuple <= latest_published_tuple: + latest_v = ".".join(map(str, latest_published_tuple)) + print( + f"::error::Target version '{target_version}' must be strictly newer than " + f"the latest published release {latest_published_tag} ({latest_v}).", + file=sys.stderr, + ) + sys.exit(1) + + # 3. Check against Release Drafter draft + if not draft_releases: + print( + "::error::No draft release found. Release Drafter should have created a draft release on PR merge.", + file=sys.stderr, + ) + sys.exit(1) + + matching_draft = next((d for d in draft_releases if d.get("tag_name") == target_tag), None) + if not matching_draft: + draft_tags = [d.get("tag_name") for d in draft_releases] + print( + f"::error::Target version '{target_version}' (expected tag '{target_tag}') " + f"does not match any current draft release tag: {draft_tags}.", + file=sys.stderr, + ) + sys.exit(1) + + print( + f"Validation successful: target version {target_version} matches draft {target_tag} " + f"and is newer than {latest_published_tag}." + ) + + +if __name__ == "__main__": + main()