Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Separate jobs for publishing to TestPyPI and PyPI #3742

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Jan 3, 2025

Description of proposed changes

Have a dedicated build distribution job, and split the publish to TestPyPI and PyPI jobs, to workaround attestation file issue. Xref pypa/gh-action-pypi-publish#283

References:

Fixes #3736

Preview:

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

Have a dedicated build distribution job, and split the publish to TestPyPI and PyPI jobs, to workaround attestation file issue. Xref pypa/gh-action-pypi-publish#283
@weiji14 weiji14 added the maintenance Boring but important stuff for the core devs label Jan 3, 2025
@weiji14 weiji14 added this to the 0.15.0 milestone Jan 3, 2025
@weiji14 weiji14 self-assigned this Jan 3, 2025

steps:
- name: Checkout
uses: actions/[email protected]
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
persist-credentials: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to add the persist-credentials: false line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was from the template at https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#checking-out-the-project-and-building-distributions, so I just added it in. The default is persist-credentials: true according to https://github.com/actions/checkout/tree/v4.2.2?tab=readme-ov-file#checkout-v4, which would mean the credentials do not persist between jobs (e.g. from the build job to the publish-to-testpypi and publish-pypi jobs and is supposed to be less secure if I'm reading actions/checkout#485 correctly. Setting to persist-credentials: false should be more secure, though unsure if it really matters.

.github/workflows/publish-to-pypi.yml Outdated Show resolved Hide resolved
.github/workflows/publish-to-pypi.yml Outdated Show resolved Hide resolved
.github/workflows/publish-to-pypi.yml Outdated Show resolved Hide resolved
.github/workflows/publish-to-pypi.yml Outdated Show resolved Hide resolved
.github/workflows/publish-to-pypi.yml Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix the "Publish to PyPI" workflow
2 participants