diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e3cc3746a..3114f912d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -154,16 +154,14 @@ jobs: - test-distribution - test-source-distribution runs-on: ubuntu-latest - # This environment stores the TWINE_USERNAME and TWINE_PASSWORD - # see https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment + # Publishes with PyPI Trusted Publishing, configured for this workflow and environment. + # See https://docs.pypi.org/trusted-publishers/ environment: name: PyPI url: https://pypi.org/project/icalendar/ - # after using the environment, we need to make the secrets available - # see https://docs.github.com/en/actions/security-guides/encrypted-secrets#example-using-bash - env: - TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + permissions: + contents: read + id-token: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - name: Set up Python @@ -178,22 +176,10 @@ jobs: run: rm -rf dist/* - name: build distribution files run: python -m build # same as in test-distribution + - name: check distribution files + run: twine check dist/* - name: deploy to pypi - run: | - # You will have to set the variables TWINE_USERNAME and TWINE_PASSWORD - # You can use a token specific to your project by setting the user name to - # __token__ and the password to the token given to you by the PyPI project. - # sources: - # - https://shambu2k.hashnode.dev/gitlab-to-pypi - # - http://blog.octomy.org/2020/11/deploying-python-pacakges-to-pypi-using.html?m=1 - if [ -z "$TWINE_USERNAME" ]; then - echo "WARNING: TWINE_USERNAME not set!" - fi - if [ -z "$TWINE_PASSWORD" ]; then - echo "WARNING: TWINE_PASSWORD not set!" - fi - twine check dist/* - twine upload dist/* + uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 deploy-github-release: # only deploy on tags, see https://stackoverflow.com/a/58478262/1320237 diff --git a/docs/conf.py b/docs/conf.py index 4efd0dc8a..6b0698b38 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -134,6 +134,7 @@ r"https://github.com/PyCalendar/icalendar/settings/", r"https://groups.google.com/g/icalendar-coc/", r"https://pypi.org/manage/project/icalendar/collaboration/", + r"https://pypi.org/manage/project/icalendar/settings/publishing/", # Ignore specific anchors r"https://github.com/actions/python-versions#support-policy", r"https://github.com/PyCalendar/icalendar/blob/7ca9db18c0847d1530520e01baf75f8ab8f4fa06/pyproject.toml#L32", diff --git a/docs/contribute/maintenance.rst b/docs/contribute/maintenance.rst index d2f03d607..f01bd1c7c 100644 --- a/docs/contribute/maintenance.rst +++ b/docs/contribute/maintenance.rst @@ -19,6 +19,7 @@ Maintainers need the following permissions. Each owner and maintainer needs a PyPI account. All PyPI accounts require two-factor authentication (2FA) enabled. Owners can invite either new owners or maintainers in the `collaboration Section `_ on PyPI. + Releases publish through `Trusted Publishing `_, which owners manage on the project's `Publishing `_ page. ``Maintainer`` access to the `Read the Docs project `_. Existing maintainers can invite another maintainer through the `Maintainers `_ page. ``Environments/Configure PyPI`` access for GitHub Workflows to grant new releases from tags. diff --git a/news/+trusted-publishing.internal b/news/+trusted-publishing.internal new file mode 100644 index 000000000..6ab0a0b16 --- /dev/null +++ b/news/+trusted-publishing.internal @@ -0,0 +1 @@ +Releases now publish to PyPI with Trusted Publishing instead of a stored API token. @SashankBhamidi diff --git a/src/icalendar/tests/test_version_directives.py b/src/icalendar/tests/test_version_directives.py index 5c4c4e14c..226e3e16c 100644 --- a/src/icalendar/tests/test_version_directives.py +++ b/src/icalendar/tests/test_version_directives.py @@ -1,7 +1,7 @@ """Check that Sphinx version directives use released versions. ``0.0.0`` is allowed until a release replaces it with the release version. -See https://github.com/collective/icalendar/issues/2026 +See https://github.com/PyCalendar/icalendar/issues/2026 """ import os