releasecmd
is a release
subcommand for setup.py
(setuptools.setup
). The subcommand creates a git tag and pushes and uploads packages to PyPI
.
The subcommand class (releasecmd.ReleaseCommand
) is implemented as a subclass of setuptools.Command
class. The release
subcommand performs the following tasks:
- Detect the package version
- If specified with the
--version
option, use that version - Retrieve the package version from an installed package if the
--use-installed-version
option is specified - Find a file that defines the package version (
__version__
variable)
- If specified with the
- Creates a git tag using the package version information
- Optionally signs the git tag with GPG if the
--sign
option is specified
- Optionally signs the git tag with GPG if the
- Pushes the git tag
- Upload package files to PyPI using
twine
.
pip install releasecmd
- setup.py
import setuptools from releasecmd import ReleaseCommand setuptools.setup( ... cmdclass={"release": ReleaseCommand}, )
$ python3 setup.py release
running release
[get the version from ./releasecmd/__version__.py]
[pull git tags]
Already up to date.
[check existing git tags]
[create a git tag: v0.0.15]
[push git tags]
[upload the package to PyPI]
...
prerequisite: package binaries must be in the dist/
directory.
You can specify a version manually by --version
option:
$ python3 setup.py release --version 0.1.0
[create a git tag: v0.1.0]
[pull git tags]
Already up to date.
[check existing git tags]
[push git tags]
[upload packages to PyPI]
$ python3 setup.py release --sign
running release
[get the version from ./releasecmd/__version__.py]
[pull git tags]
Already up to date.
[check existing git tags]
[create a git tag with gpg signing: v0.1.0]
[push git tags]
[upload packages to PyPI]
...
$ python3 setup.py release --skip-tagging
running release
[get the version from ./releasecmd/__version__.py]
skip git tagging
[upload packages to PyPI]
...
Options for 'ReleaseCommand' command:
--skip-tagging skip a git tag creation
--skip-uploading skip uploading packages to PyPI
--dry-run don't actually do anything
--sign make a GPG-signed git tag
--verbose show verbose output
--search-dir specify a root directory path to search a version
file. defaults to the current directory.
--tag-template specify git tag format. defaults to 'v{version}'
--use-installed-version use an installed package version as a release
version
--version specify release version
- Python 3.8+
- Git