How to release Python package
PyPI/GitHub release
Important
Make sure you have your project is standarlized with scikit-package. Otherwise, please start from the Getting started page here.
Instructions for Project Owner for release
Review the checklist prepared by the contributor in the issue.
Ensure
PYPI_TOKEN
andPAT_TOKEN
are configured at the org level. See Appendix 1, 2, respectively.Check the
github_admin_username
section in.github/workflows/build-wheel-release-upload.yml
is that of the project owner.In your terminal, run
git checkout main && git pull upstream main
to sync with the main branch.Run the following:
# For pre-release, use *.*.*rc* e.g., 1.0.0rc0 # For release, use *.*.* e.g., 1.0.0 git tag <version-number> git push upstream <version-number>
Done! Once the tag is pushed, visit the
Actions
tab in the repository to monitor the CI progress.Comment
GitHub/PyPI release done!
orGitHub/PyPI pre-release done!
in the release GitHub issue.The contributor will make a PR into the conda-forge feedstock. Review and approve the PR.
Wait for the contributor to test the released package. The issue will be closed by the contributor.
Appendix 1. Setup PYPI_TOKEN
Generate a PyPI API token from pypi.org
:
Visit https://pypi.org/manage/account/ and log in.
Scroll down to the
API tokens
section and clickAdd API token
.Set the
Token name
toPYPI_TOKEN
.Choose the appropriate
Scope
for the token.Click
Create token
and copy the generated token.
Add the generated token to GitHub:
Navigate to the
Settings
page of the org (or repository).Click the
Actions
tab underSecrets and variables
.Click
New org secret
, name itPYPI_TOKEN
, and paste the token value.Done!
Appendix 2. Setup PAT_TOKEN
The GitHub workflow needs to link with this privilege through a personal access token (PAT) of the project owner.
Click
Generate new token
and choose the classic option.Under
Note
, write, “GitHub CI release”Set the Expiration date of the token.
Under
Select scopes
, checkrepo
anduser
.Scroll down, click
Generate token
.Done!
Copy and paste the PAT_TOKEN
to your GitHub organization:
Visit
Settings
in the organization.Click the
Actions
tab underSecrets and variables
.Click
New organization secret
and add a new secret and name it asPAT_TOKEN
.Done!
Appendix 3. How to host your package documentation online
You have API doc built and tested locally. Now you want to deploy your doc via i.e., https://diffpy.github.io/diffpy.utils
using GitHub Pages.
Go to your
Settings
page in your repository and and clickpages
underCode and automation
.Click
Deploy from a branch
underSource
. Below, choosegh-pages
branch and/(root)
and clickSave
.
Done! Wait a few minutes and visit your GitHub Pages URL!