Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

semantic-release plugin to publish a python package to PyPI

License

NotificationsYou must be signed in to change notification settings

abichinger/semantic-release-pypi

Repository files navigation

semantic-release plugin to publish a python package to PyPI

npm latest versionBuild states

CI environment

Build System Interfaces

semantic-release-pypi support twobuild system interfaces

  • pyproject.toml based (Recommended)
    • version will be set insidepyproject.toml -PEP 621
    • The build backend can be specified insidepyproject.toml (defaultstosetuptools) -PEP 518

  • setup.py based (Legacy interface)
    • setuptools is required, other packaging tools like Poetry or Hatch are not supported when using this interface
    • version will be set insidesetup.cfg
    • version mustnot be set insidesetup.py

Steps

StepDescription
verifyConditions
  • verify the environment variablePYPI_TOKEN
  • verifyPYPI_TOKEN is authorized to publish on the specified repository
  • check if the packagessetuptools,wheel andtwine are installed
prepareUpdate the version inpyproject.toml (legacy:setup.cfg) and create the distribution packages
publishPublish the python package to the specified repository (default: pypi)

Environment variables

VariableDescriptionRequiredDefault
PYPI_TOKENAPI token for PyPItrue
PYPI_USERNAMEUsername for PyPIfalse__token__
PYPI_REPO_URLRepo URL for PyPIfalseSeeOptions

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 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:

Options

OptionTypeDefaultDescription
srcDirstr.source directory (defaults to current directory)
distDirstrdistdirectory to put the source distribution archive(s) in, relative tosrcDir
repoUrlstrhttps://upload.pypi.org/legacy/The repository (package index) to upload the package to.
repoUsernamestr__token__The repository username.
repoTokenstrThe repository token. It's safer to set via PYPI_TOKEN environment variable.
pypiPublishbooltrueWhether to publish the python package to the pypi registry. If false the package version will still be updated.
gpgSignboolfalseWhether to sign the package using GPG. A valid PGP key must already be installed and configured on the host.
gpgIdentitystrnullWhengpgSign is true, set the GPG identify to use when signing files. Leave empty to use the default identity.
envDirstring |false.venvdirectory to create the virtual environment in, if set tofalse no environment will be created
installDepsbooltruewether to automatically install python dependencies
versionCmdstringarrayundefined

Publishing to multiple repositories

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']}]]}

Development

Pre-requisites

  • pyenv >= 2.1.0
source init.sh

Contribute

  • Fork from this repository
  • Runsource init.sh
  • Add your changes
  • Make sure your code passes all unit tests by runningyarn test
  • Runyarn lint to ensure your code adheres to the linting rules
  • Issue a PR

Alternatives

Python Semantic Release

About

semantic-release plugin to publish a python package to PyPI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors10


[8]ページ先頭

©2009-2025 Movatter.jp