You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The template will have created a GitHub Action which runs your library's test suite against every commit.
75
77
76
78
## Publishing your library as a package to PyPI
77
79
78
-
The template also includes an Action for publishing packages to [PyPI](https://pypi.org/).
80
+
The template also includes a `publish.yml` GitHub Actions workflow for publishing packages to [PyPI](https://pypi.org/), using [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish).
79
81
80
-
To use this action, you need to create a PyPI account and an API token against that account.
82
+
To use this action, you need to create a PyPI account and [configure a Trusted Publisher](https://til.simonwillison.net/pypi/pypi-releases-from-github) for this package.
81
83
82
-
Once you have created your account, navigate to https://pypi.org/manage/account/token/ and create an API token. For initial publication of the package you will need to set the scope of the token to "Entire account (all projects)".
84
+
Once you have created your account, navigate to https://pypi.org/manage/account/publishing/ and create a "pending publisher" for the package. Use the following values:
83
85
84
-
Add that token to your repository as a GitHub secret called `PYPI_TOKEN`. You can find this in the "Settings -> Secrets -> New Secret" area of the repository. The token should begin with the string `pypi-`.
86
+
-**PyPI Project Name:** The name of your package
87
+
-**Owner:** Your GitHub username or organization - the "foo" in `github.com/foo/bar`
88
+
-**Repsitory name:** The name of your repository - the "bar" in `github.com/foo/bar`
89
+
-**Workflow name:**`publish.yml`
90
+
-**Environment name:**`release`
85
91
86
-
Now, any time you create a new "Release" on GitHub the Action will build your package and push it to PyPI. The tag for the new release needs to match the `VERSION` string at the top of your `setup.py` file.
92
+
Now, any time you create a new "Release" on GitHub the Action will build your package and push it to PyPI.
87
93
88
-
After the first release has gone out you can create a new PyPI API token that is scoped just to that project and use that to replace the `PYPI_TOKEN` secret in your GitHub repository settings.
94
+
The tag for your release needs to match the `VERSION` string at the top of your `pyproject.toml` file. You should bump this version any time you release a new version of your package.
0 commit comments