- Notifications
You must be signed in to change notification settings - Fork13
semantic-release plugin to publish a python package to PyPI
License
abichinger/semantic-release-pypi
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
semantic-release plugin to publish a python package to PyPI
- Node.js >= 18.0.0
- Python >= 3.9
semantic-release-pypi support twobuild system interfaces
pyproject.tomlbased (Recommended)
setup.pybased (Legacy interface)setuptoolsis required, other packaging tools like Poetry or Hatch are not supported when using this interfaceversionwill be set insidesetup.cfgversionmustnot be set insidesetup.py
| Step | Description |
|---|---|
verifyConditions |
|
prepare | Update the version inpyproject.toml (legacy:setup.cfg) and create the distribution packages |
publish | Publish the python package to the specified repository (default: pypi) |
| Variable | Description | Required | Default |
|---|---|---|---|
PYPI_TOKEN | API token for PyPI | true | |
PYPI_USERNAME | Username for PyPI | false | __token__ |
PYPI_REPO_URL | Repo URL for PyPI | false | SeeOptions |
The plugin can be configured in the**semantic-release** configuration file.Here is a minimal example:
{"plugins": ["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator","semantic-release-pypi" ]}Note that this plugin modifies the version inside ofpyproject.toml (legacy:setup.cfg).Make sure to commitpyproject.toml using the@semantic-release/git plugin, if you want to save the changes:
{"plugins": ["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator","semantic-release-pypi", ["@semantic-release/git", {"message":"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}","assets": ["pyproject.toml" ] } ] ]}Working examples using Github Actions can be found here:
| Option | Type | Default | Description |
|---|---|---|---|
srcDir | str | . | source directory (defaults to current directory) |
distDir | str | dist | directory to put the source distribution archive(s) in, relative tosrcDir |
repoUrl | str | https://upload.pypi.org/legacy/ | The repository (package index) to upload the package to. |
repoUsername | str | __token__ | The repository username. |
repoToken | str | The repository token. It's safer to set via PYPI_TOKEN environment variable. | |
pypiPublish | bool | true | Whether to publish the python package to the pypi registry. If false the package version will still be updated. |
gpgSign | bool | false | Whether to sign the package using GPG. A valid PGP key must already be installed and configured on the host. |
gpgIdentity | str | null | WhengpgSign is true, set the GPG identify to use when signing files. Leave empty to use the default identity. |
envDir | string |false | .venv | directory to create the virtual environment in, if set tofalse no environment will be created |
installDeps | bool | true | wether to automatically install python dependencies |
versionCmd | string | array | undefined |
Usingrelease.config.js you can read repository credentials from environment variables and publish to multiplerepositories.
module.exports={"plugins":[["semantic-release-pypi",{"repoUrl":process.env['REPOSITORY_1_URL'],"repoUsername":process.env['REPOSITORY_1_USERNAME'],"repoToken":process.env['REPOSITORY_1_TOKEN']}],["semantic-release-pypi",{"repoUrl":process.env['REPOSITORY_2_URL'],"repoUsername":process.env['REPOSITORY_2_USERNAME'],"repoToken":process.env['REPOSITORY_2_TOKEN']}]]}
- pyenv >= 2.1.0
source init.sh- Fork from this repository
- Run
source init.sh - Add your changes
- Make sure your code passes all unit tests by running
yarn test - Run
yarn lintto ensure your code adheres to the linting rules - Issue a PR
About
semantic-release plugin to publish a python package to PyPI
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors10
Uh oh!
There was an error while loading.Please reload this page.