From d1bda6390ea1ef7a175eb3680dbb147250399f16 Mon Sep 17 00:00:00 2001 From: Michel Albert Date: Tue, 27 Oct 2026 15:35:39 +0000 Subject: [PATCH] ci: Publish to PyPI with Trusted Publishing The v5.2.0 tag run failed to publish: the job still expected a pypi_token secret, which no longer exists, so the publish action fell back to Trusted Publishing without the id-token permission it needs. Publish the way x690 does: run in the "pypi" environment with id-token: write and no token, and only for v* tags. Before uploading, check that the tag matches config_resolver/version.txt (uv version cannot read a dynamic version). The job now also waits for the docs build. Co-Authored-By: Claude --- .github/workflows/pythonpackage.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 2164ec7..696e981 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -196,17 +196,34 @@ jobs: publish: runs-on: ubuntu-latest - needs: [test, build] - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + needs: [test, docs, build] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + environment: pypi + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v7 + + # The version is dynamic (read from version.txt by setuptools), so + # `uv version` cannot report it; read the same file instead. + - name: Check that the tag matches the package version + env: + TAG: ${{ github.ref_name }} + run: | + version="$(cat config_resolver/version.txt)" + if [ "${TAG#v}" != "$version" ]; then + echo "::error::Tag $TAG does not match version.txt $version" + exit 1 + fi + - name: Download the built packages uses: actions/download-artifact@v8 with: name: Packages path: dist + # Trusted Publishing (OIDC); also uploads PEP 740 attestations. - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.pypi_token }}