From 4430ee632b680d674acdeb6971e4ff202b1f6760 Mon Sep 17 00:00:00 2001 From: duglin <1944671+duglin@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:22:32 +0000 Subject: [PATCH] Initial plan Skip releases with existing version tags Signed-off-by: Doug Davis --- .github/workflows/pypi-release.yml | 14 ++++++++++++++ RELEASING.md | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index dee9f3f2..62dda2de 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -36,15 +36,28 @@ jobs: runs-on: ubuntu-24.04 if: github.event_name == 'push' needs: [ build_dist ] + outputs: + release_needed: ${{ steps.release_check.outputs.release_needed }} steps: - uses: actions/checkout@v6 with: fetch-depth: 0 + - name: Check release tag + id: release_check + run: | + version=$(grep -oP '__version__ = "\K[^"]+' src/cloudevents/__init__.py) + if git show-ref --verify --quiet "refs/tags/$version"; then + echo "release_needed=false" >> "$GITHUB_OUTPUT" + else + echo "release_needed=true" >> "$GITHUB_OUTPUT" + fi - uses: actions/download-artifact@v8.0.1 + if: steps.release_check.outputs.release_needed == 'true' with: name: artifact path: dist - name: Publish + if: steps.release_check.outputs.release_needed == 'true' uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ @@ -52,6 +65,7 @@ jobs: tag: runs-on: ubuntu-24.04 needs: [ publish ] + if: needs.publish.outputs.release_needed == 'true' steps: - uses: actions/checkout@v6 with: diff --git a/RELEASING.md b/RELEASING.md index 39c621e5..b8e90f49 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -6,13 +6,15 @@ package](https://pypi.org/project/cloudevents/) and GitHub Tag via GitHub Action To release a new CloudEvents SDK, contributors should bump `__version__` in `src/cloudevents/__init__.py` to reflect the new release version. On merge, the action will automatically build and release to PyPI. This action gets called on all pushes to main -(such as a version branch being merged into main), but only releases a new version when the -version number has changed. Note, this action assumes pushes to main are version updates. -Consequently, the release workflow will fail if you attempt to push to main without updating -`__version__` in `src/cloudevents/__init__.py` so don't forget to do so. +(such as a version branch being merged into main), but skips publishing and tagging when a +Git tag matching `__version__` already exists. Changes made after a release require a new +version number to be published. After a version update is merged, a GitHub tag for the new cloudevents version is created using `__version__`. +If publishing succeeds but tag creation fails, verify the published release and restore its +tag at the release commit before subsequent pushes; otherwise PyPI will reject the repeat +upload. View the GitHub workflow [pypi-release.yml](.github/workflows/pypi-release.yml) for more information.