ci(release): migrate PyPI publish to Trusted Publishing + attestations (#4249)
* ci(release): migrate PyPI publish to Trusted Publishing + attestations
Switch the `publish-pypi` and `publish-hf-cli` jobs from long-lived API
tokens (`PYPI_TOKEN_DIST_*` + `twine upload`) to PyPI Trusted Publishing
via `pypa/gh-action-pypi-publish` (pinned by SHA, v1.14.0).
Benefits:
- No PyPI secret stored in the repo (OIDC exchange at publish time).
- Each artifact is signed with Sigstore and gets a PEP 740 attestation
(`attestations: true`), giving downstream consumers a cryptographic
link back to this workflow run.
- The publish jobs now run in a `pypi` GitHub Environment, which gates
the actual upload behind required reviewers.
- Build switched from the deprecated `python setup.py sdist bdist_wheel`
to PEP 517 `python -m build`.
Follow-up steps required before this can run:
1. Configure a Trusted Publisher on PyPI for both `huggingface-hub` and
`hf`, matching repo `huggingface/huggingface_hub`, workflow
`release.yml`, and environment `pypi`.
2. Create a `pypi` Environment in the repo settings with required
reviewers.
3. Once green, delete the now-unused `PYPI_TOKEN_DIST_HUGGINGFACE_HUB`
and `PYPI_TOKEN_DIST_HF` secrets, and remove or disable the
tag-triggered fallback workflows (`python-release.yml`,
`python-release-hf.yml`) which still rely on those tokens.
* ci(release): remove legacy tag-triggered PyPI publish workflows
Delete `python-release.yml` and `python-release-hf.yml`. They were the
pre-`release.yml` publish path, triggered by `push: tags: v*` and using
`PYPI_TOKEN_DIST_*` to upload via twine.
Since the unified `release.yml` took over, these workflows have only
been documented as a "manual fallback" — but the same recovery is
already available by re-running the failed publish job from the Actions
UI.
Keeping them around means anyone with write access can bypass the new
`pypi` environment gate (and the OIDC / attestations flow) by pushing a
tag with a PAT that cascades events. Removing them closes that bypass.
The `PYPI_TOKEN_DIST_HUGGINGFACE_HUB` and `PYPI_TOKEN_DIST_HF` secrets
become fully unused after this PR and the first successful Trusted
Publishing run; they should be deleted from the repo settings then.