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

Update release action #2172

Merged
merged 4 commits into from
May 17, 2023
Merged

Conversation

dopplershift
Copy link
Contributor

@dopplershift dopplershift commented Apr 24, 2023

A few changes to update the GitHub release workflow

  • Swap the event from "pushing a tag" to "release publication". This restricts what events trigger it and more directly tie the generation of PyPI products to the process we follow
  • Pin to the 1.8.5 version of the PyPA PyPI publication action; it's always better not to just be blindly using GitHub HEAD.
  • Separate the workflow into two separate jobs: build and publish. This reduces the code that has access to the private tokens/permissions needed to publish. It also is a small (needed) step towards having a build matrix (for e.g. wheels) that then get uploaded together in one single step to PyPI.
  • Use PyPI "trusted publisher" instead of an API token (see below)

The last one is a new feature just released to general availability by PyPI. Instead of using a fixed API token (which is tied to one user's account--currently mine), you configure the project on PyPI to accept publication from a particular GitHub workflow and (optionally) environment. Transparently (using the PyPA GitHub Action we're already using) GitHub and PyPI exchange the needed tokens to allow publication to PyPI. The use of an environment additionally allows some gatekeeping like wait timers, restrict certain branches for "deployment", and manual approval for "deployment", if we were so inclined.

Assuming we want to go this way, the additional items that need to take place outside the PR merger:

Replaces running on tag push, since this new way is more focused and
dependent on actually making the release.
This restricts access to the PyPI token to ony the publish stage, rather
than all code installed and executed during the setup and build parts.
We can also restrict this to the PyPI environment.
This is better security practice than using master/main.
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks good to me. I think this is a good direction to head for releases.

.github/workflows/release.yml Show resolved Hide resolved
- '*'
release:
types:
- published
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add a release guide to explain what we need to do to trigger this? I assume it is "go to GitHub and publish a release" because tagging via command line and pushing a tag is not good enough here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean, we can stick with "tag and push" if we want, I just looked and saw we were already using the GitHub releases feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm good with this, I've been making releases through the web interface.

@greglucas
Copy link
Contributor

@dopplershift, this looks good to me. Feel free to merge this when you have some time to do the other tasks you've listed as well. I don't want to merge this and be in limbo when we haven't added the other pieces necessary yet to make a release and forget to update.

@dopplershift dopplershift merged commit 2b36407 into SciTools:main May 17, 2023
@dopplershift dopplershift deleted the update-release-action branch May 17, 2023 23:52
@dopplershift
Copy link
Contributor Author

All done. This workflow worked flawlessly on the most recent MetPy release.

@QuLogic QuLogic added this to the 0.22 milestone Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants