@@ -384,9 +384,8 @@ below describe the setup process for each supported Trusted Publisher.
384
384
[`id_tokens`](https://docs.gitlab.com/ee/ci/yaml/index.html#id_tokens) is used
385
385
to request an OIDC token from GitLab with name `PYPI_ID_TOKEN` and audience
386
386
`pypi`.
387
- - This OIDC token is extracted from the CI/CD environment using the
388
- [`id`](https://pypi.org/project/id/) package.
389
- - The OIDC token is then sent to PyPI in exchange for a PyPI API token, which
387
+ - Twine is called to upload the package with no token specified.
388
+ It sends the OIDC token to PyPI in exchange for a PyPI API token, which
390
389
is then used to publish the package using `twine`.
391
390
392
391
```yaml
@@ -411,16 +410,9 @@ below describe the setup process for each supported Trusted Publisher.
411
410
aud: pypi
412
411
script:
413
412
# Install dependencies
414
- - apt update && apt install -y jq
415
- - python -m pip install -U twine id
416
-
417
- # Retrieve the OIDC token from GitLab CI/CD, and exchange it for a PyPI API token
418
- - oidc_token=$(python -m id PYPI)
419
- # Replace "https://pypi.org/*" with "https://test.pypi.org/*" if uploading to TestPyPI
420
- - resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\":\"${oidc_token}\"}")
421
- - api_token=$(jq --raw-output '.token' <<< "${resp}")
422
-
423
- # Upload to PyPI authenticating via the newly-minted token
424
- # Add "--repository testpypi" if uploading to TestPyPI
425
- - twine upload -u __token__ -p "${api_token}" python_pkg/dist/*
413
+ - python -m pip install -U twine
414
+
415
+ # Upload to PyPI, add "--repository testpypi" if uploading to TestPyPI
416
+ # With no token specified, twine will use Trusted Publishing
417
+ - twine upload python_pkg/dist/*
426
418
```
0 commit comments