semantic-release-pypi v4.1.1
📦🐍 semantic-release-pypi
semantic-release plugin to publish a python package to PyPI
CI environment
- Node.js >= 18.0.0
- Python >= 3.8
Build System Interfaces
semantic-release-pypi support two build 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.cfgversionmust not be set insidesetup.py
Steps
| Step | Description |
|---|---|
verifyConditions | verify the environment variable PYPI_TOKENverify PYPI_TOKEN is authorized to publish on the specified repositorycheck if the packages setuptools, wheel and twine are installed |
prepare | Update the version in pyproject.toml (legacy: setup.cfg) and create the distribution packages |
publish | Publish the python package to the specified repository (default: pypi) |
Environment variables
| 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 | See Options |
Usage
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 of pyproject.toml (legacy: setup.cfg).
Make sure to commit pyproject.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:
Options
| 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 to the directory of setup.py |
repoUrl | str | https://upload.pypi.org/legacy/ | The repository (package index) to upload the package to. |
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 | When gpgSign 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 to false no environment will be created |
installDeps | bool | true | wether to automatically install python dependencies |
versionCmd | string | undefined | Run a custom command to update the version (e.g. hatch version ${version}). srcDir is used as working directory. versionCmd is required if the version is set dynamically |
Development
Pre-requisites
- pyenv >= 2.1.0
source init.shContribute
- 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
Alternatives
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago