Skip to content

Commit 087b797

Browse files
ryanhill1TheGupta2012claude
authored
ci: publish to PyPI via trusted publishing instead of an API token (#411)
* ci: publish release.yml via trusted publishing instead of an API token * ci: publish pre-release.yml via trusted publishing instead of an API token * ci: move id-token permission to the publishing job The permissions block landed on build_sdist, which only builds an sdist. The pypi-publish job runs gh-action-pypi-publish and had no permissions at all, so ACTIONS_ID_TOKEN_REQUEST_TOKEN was unset and the OIDC exchange failed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: add changelog entry for trusted publishing Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Bump version to 1.2.0-alpha The -alpha suffix is what lets repeat pre-releases bump to a1, a2 and so on. A plain 1.2.0 works for the first pre-release, then the stamper raises InvalidVersionError because there is no prerelease segment to increment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: TheGupta2012 <harshit@qbraid.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 5313d03 commit 087b797

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

.github/workflows/pre-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ jobs:
157157
needs: [build_wheels, build_sdist]
158158
runs-on: ubuntu-latest
159159
environment: release
160+
permissions:
161+
id-token: write # mint the OIDC token PyPI trusted publishing verifies
162+
contents: read # actions/checkout
160163

161164
steps:
162165
- name: Checkout Pyqasm
@@ -174,6 +177,3 @@ jobs:
174177

175178
- name: Publish package to PyPI
176179
uses: pypa/gh-action-pypi-publish@release/v1
177-
with:
178-
user: __token__
179-
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ jobs:
148148
needs: [build_wheels, build_sdist]
149149
runs-on: ubuntu-latest
150150
environment: release
151+
permissions:
152+
id-token: write # mint the OIDC token PyPI trusted publishing verifies
153+
contents: read # actions/checkout
151154

152155
steps:
153156
- name: Checkout PyQASM
@@ -165,6 +168,3 @@ jobs:
165168

166169
- name: Publish package to PyPI
167170
uses: pypa/gh-action-pypi-publish@release/v1
168-
with:
169-
user: __token__
170-
password: ${{ secrets.PYPI_API_TOKEN }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Types of changes:
3030
### Dependencies
3131

3232
### Other
33+
- Switched PyPI publishing from a long-lived `PYPI_API_TOKEN` repository secret to trusted publishing. The publish job now mints a short-lived OIDC credential scoped to that one workflow, and the action attaches PEP 740 attestations recording the repository, workflow and commit SHA behind each uploaded file. Attestations apply to releases published after this merges, not retroactively. ([#411](https://github.com/qBraid/pyqasm/pull/411))
3334
- Fixed the pre-release build stamping a version that `pyqasm.__version__` and the package metadata spelled differently. `pre_build.sh` wrote `1.1.0-a.0` into `pyproject.toml`, setuptools normalized that to `1.1.0a0` for the metadata, and `_version.py` kept the raw string, so `pip show pyqasm` and `pyqasm.__version__` disagreed and `test_sdist.sh` failed its version check. The stamped version is now normalized to PEP 440 before it is written. ([#414](https://github.com/qBraid/pyqasm/pull/414))
3435
- Fixed the pre-release workflow publishing its source distribution under the released version instead of the pre-release one. `build_sdist.sh` ran `git reset --hard` and `git clean -xdf`, which discarded the `pyproject.toml` version that the preceding step had just stamped, so a run that built `1.1.0a0` wheels built a `1.1.0` sdist and PyPI rejected it as a duplicate. `pre_build.sh` already resets the tree, so the second reset is gone. It also no longer destroys uncommitted work when the script is run locally. ([#413](https://github.com/qBraid/pyqasm/pull/413))
3536
- Added a `SECURITY.md` with a private vulnerability disclosure path. There was no documented way to report one, leaving a public issue or a guessed email address as the only options. Reports now go through this repository's GitHub security advisory form. ([#383](https://github.com/qBraid/pyqasm/pull/383))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pyqasm"
7-
version = "1.1.0"
7+
version = "1.2.0-alpha"
88
description = "Python toolkit providing an OpenQASM 3 semantic analyzer and utilities for program analysis and compilation."
99
authors = [{name = "qBraid Development Team"}, {email = "contact@qbraid.com"}]
1010
readme = "README.md"

0 commit comments

Comments
 (0)