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: Create workflow that builds and deploys wheels to PyPI #4

Merged
merged 2 commits into from
Oct 28, 2023

Conversation

EwoutH
Copy link
Contributor

@EwoutH EwoutH commented Oct 27, 2023

Add a CI workflow that automatically builds mesa-interactive and deploys a wheel to PyPI. If runs on each push and pull request to test wheel building, but only deploys to PyPI when a tag is created.

To deploy to PyPI is uses the PyPI publish GitHub Action. It uses the API token feature of PyPI, which is recommended to restrict the access the action has.

The secret used in ${{ secrets.PYPI_API_TOKEN }} needs to be created on the settings page. See Creating & using secrets.

After uploading the API token, any maintainer can just create a new tag, after which this action will upload the wheel and dist to PyPI.

Add a CI workflow that automatically builds mesa-interactive and deploys a wheel to PyPI. If runs on each push and pull request to test wheel building, but only deploys to PyPI when a tag is created.
@Corvince
Copy link
Owner

Thank you very much for setting this up!

@Corvince Corvince merged commit 3a8b666 into Corvince:main Oct 28, 2023
@EwoutH
Copy link
Contributor Author

EwoutH commented Oct 28, 2023

Good catch on the repo name, and thanks for merging!

@Corvince
Copy link
Owner

Corvince commented Oct 28, 2023

I can't manage to create a commit tag on mobile. Do you want to create a PR where you bump the version in __about__.py and tag the commit? Would be great to test if it is working

@EwoutH
Copy link
Contributor Author

EwoutH commented Oct 28, 2023

Should be quite easy, only I can't do it. You just first bump the version number in a regular commit, and then create a tag though the GitHub interface.

For reference, here's the full workflow I personally use in my projects (ignore the parts about the release notes, you can start at step 7):

Releases

The release process has been updated starting at the 2.2.0 release. To create a new release, follow the following steps:

  1. Make sure all PRs have a clear title and are labeled with at least one label. These will be used when drafting the changelog using the .github/release.yml configuration.
  2. Go to Releases in the GitHub UI and press the Draft a new release button
  3. Set the upcoming tag in the Choose a tag and Release title (i.e. 2.3.0) fields
  4. Use the Generate release notes button to auotmatically create release notes. Review them carefully.
  5. Write a Highlights section with the most important features or changes in this release.
  6. Copy the release notes and save them with the grey Save draft button.
  7. Open a new PR in which the version number in ema_workbench/init.py is updated and the copied release notes are added to the CHANGELOG.md.
  8. Once this PR is merged, go back to the Releases section and Publish the draft release.
  9. The release.yml CI workflow should now automatically create and upload the package to PyPI. Check if this happened on PyPI.org.
  10. Finally, open a new PR in which the version number in ema_workbench/init.py is updated towards the next release (i.e. "2.4.0-dev").

@Corvince
Copy link
Owner

Yay it works!

I somehow thought this works on commit tags and then creates a release on github. But going through GitHub releases is even easier, in my opinion.

Oh and in the log I saw that PyPi now supports trusted publishing for GitHub. We might want to update the workflow here and on mesa.
https://docs.pypi.org/trusted-publishers/

@EwoutH
Copy link
Contributor Author

EwoutH commented Oct 29, 2023

Glad it functions satisfactory!

Oh and in the log I saw that PyPi now supports trusted publishing for GitHub. We might want to update the workflow here and on mesa.
https://docs.pypi.org/trusted-publishers/

This looks quite interesting, and I hadn't see it yet, so thanks for sharing! I will try to look into it next week and propose an updated workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants