5454 with :
5555 python-version : " 3.12"
5656
57- - name : Validate plugin catalog
58- run : python3 tools/plugin_catalog.py validate .
59-
6057 - id : resolve
6158 shell : bash
6259 env :
@@ -79,12 +76,15 @@ jobs:
7976 tag_ref="${GITHUB_REF}"
8077 fi
8178
82- if git merge-base --is-ancestor "${tag_ref}" "refs/remotes/origin/main"; then
79+ tag_commit="$(git rev-list -n 1 "${tag_ref}")"
80+ if git merge-base --is-ancestor "${tag_commit}" "refs/remotes/origin/main"; then
8381 tag_on_main=true
8482 else
8583 tag_on_main=false
8684 fi
8785
86+ git checkout --detach "${checkout_ref}"
87+ python3 tools/plugin_catalog.py validate .
8888 release_info="$(python3 tools/plugin_catalog.py release-info . "${tag}")"
8989 plugin="$(printf '%s' "${release_info}" | python3 -c 'import json, sys; print(json.load(sys.stdin)["slug"])')"
9090 plugin_path="$(printf '%s' "${release_info}" | python3 -c 'import json, sys; print(json.load(sys.stdin)["path"])')"
@@ -255,7 +255,7 @@ jobs:
255255 fi
256256
257257 publish :
258- if : ${{ ( github.event_name != 'workflow_call' || inputs.publish_enabled) && (needs.resolve.outputs.publish_env != 'pypi' || needs.resolve.outputs.tag_on_main == 'true') }}
258+ if : ${{ github.event_name != 'workflow_call' || inputs.publish_enabled }}
259259 needs : [resolve, build-wheel, build-sdist]
260260 runs-on : ubuntu-latest
261261 environment : ${{ needs.resolve.outputs.publish_env }}
@@ -276,8 +276,14 @@ jobs:
276276 repository-url : https://test.pypi.org/legacy/
277277 skip-existing : true
278278
279+ - name : Verify PyPI tag is on main
280+ if : needs.resolve.outputs.publish_env == 'pypi' && needs.resolve.outputs.tag_on_main != 'true'
281+ run : |
282+ echo "Refusing to publish to PyPI because the release tag is not reachable from origin/main" >&2
283+ exit 1
284+
279285 - name : Publish distributions to PyPI
280- if : needs.resolve.outputs.publish_env == 'pypi'
286+ if : needs.resolve.outputs.publish_env == 'pypi' && needs.resolve.outputs.tag_on_main == 'true'
281287 uses : pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
282288 with :
283289 packages-dir : dist/
0 commit comments