Commands#

All commands accept a -h/--help option, which displays the help text for the command and exits immediately.

semantic-release does not allow interspersed arguments and options, which means that the options for semantic-release are not necessarily accepted one of the subcommands. In particular, the --noop and -v/--verbose flags must be given to the top-level semantic-release command, before the name of the subcommand.

For example:

Incorrect:

semantic-release version --print --noop -vv

Correct:

semantic-release -vv --noop version --print

With the exception of semantic-release and semantic-release generate-config, all commands require that you have set up your project’s configuration. To help with this step, semantic-release generate-config can create the default configuration for you, which will allow you to tweak it to your needs rather than write it from scratch.

semantic-release#

Options:#

--version#

Display the version of Python Semantic Release and exit

--noop#

Use this flag to see what semantic-release intends to do without making changes to your project. When using this option, semantic-release can be run as many times as you wish without any side-effects.

-v/--verbose#

Can be supplied more than once. Controls the verbosity of semantic-releases logging output (default level is WARNING, use -v for INFO and -vv for DEBUG).

-c/--config [FILE]#

Specify the configuration file which Python Semantic Release should use. This can be any of the supported formats valid for -f/--format [FORMAT]

Default: pyproject.toml

See also

--strict#

Enable Strict Mode. This will cause a number of conditions to produce a non-zero exit code when passed, where they would otherwise have produced an exit code of 0. Enabling this allows, for example, certain conditions to cause failure of a CI pipeline, while omitting this flag would allow the pipeline to continue to run.

See also

semantic-release version#

Detect the semantically correct next version that should be applied to your project.

By default:

  • Write this new version to the project metadata locations specified in the configuration file

  • Build the project using build_command (Optional[str]), if specified

  • Create a new commit with these locations and any other assets configured to be included in a release

  • Tag this commit according the configured format, with a tag that uniquely identifies the version being released

  • Push the new tag and commit to the remote for the repository

  • Create a release (if supported) in the remote VCS for this tag

Changelog generation is done identically to the way it is done in semantic-release changelog, but this command additionally ensures the updated changelog is included in the release commit that is made.

Options:#

--print#

Print the next version that will be applied, respecting the other command line options that are supplied, and exit. This flag is useful if you just want to see what the next version will be. Note that instead of printing nothing at all, if no release will be made, the current version is printed.

For example, you can experiment with which versions would be applied using the other command line options:

semantic-release version --print
semantic-release version --patch --print
semantic-release version --prerelease --print

--major/--minor/--patch#

Force the next version to increment the major, minor or patch digit, respectively. These flags are optional but mutually exclusive, so only one may be supplied, or none at all. Using these flags overrides the usual calculation for the next version; this can be useful, say, when a project wants to release its initial 1.0.0 version.

Warning

Using these flags will override the value of prerelease, regardless of your configuration or the current version. To produce a prerelease with the appropriate digit incremented you should also supply the --prerelease flag. If you do not, using these flags will force a full (non-prerelease) version to be created.

These options are forceful overrides, but there is no action required for subsequent releases performed using the usual calculation algorithm.

--prerelease#

Force the next version to be a prerelease. As with --major/--minor/--patch, this option is a forceful override, but no action is required to resume calculating versions as normal on the subsequent releases.

If not specified in --prerelease-token [VALUE], the prerelease token is idenitified using the Multibranch Release Configuration

--prerelease-token [VALUE]#

Force the next version to use the value as the prerelease token. This overrides the configured value if one is present. If not used during a release producing a prerelease version, this option has no effect.

--build-metadata [VALUE]#

If given, append the value to the newly calculated version. This can be used, for example, to attach a run number from a CI service or a date to the version and tag that are created.

This value can also be set using the environment variable PSR_BUILD_METADATA

For example, assuming a project is currently at version 1.2.3:

$ semantic-release version --minor --print
1.3.0

$ semantic-release version --minor --print --build-metadata "run.12345"
1.3.0+run.12345

--commit/--no-commit#

Whether or not to perform a git commit on modifications to source files made by semantic-release during this command invocation, and to run git tag on this new commit with a tag corresponding to the new version.

If --no-commit is supplied, it may disable other options derivatively; please see below.

Default: --commit

See also

--tag/--no-tag#

Whether or not to perform a git tag to apply a tag of the corresponding to the new version during this command invocation. This option manages the tag application separate from the commit handled by the --commit option.

If --no-tag is supplied, it may disable other options derivatively; please see below.

Default: --tag

--changelog/--no-changelog#

Whether or not to update the changelog file with changes introduced as part of the new version released.

Default: --changelog

--push/--no-push#

Whether or not to push new commits and/or tags to the remote repository.

Default: --no-push if –no-commit and –no-tag is also supplied, otherwise push is the default.

--vcs-release/--no-vcs-release#

Whether or not to create a “release” in the remote VCS service, if supported. Currently releases in GitHub and Gitea remotes are supported. If releases aren’t supported in a remote VCS, this option will not cause a command failure, but will produce a warning.

Default: --no-vcs-release if --no-push is supplied (including where this is implied by supplying only --no-commit), otherwise --vcs-release

--skip-build#

If passed, skip building the current project using build_command.

semantic-release publish#

Publish a distribution to a VCS release. Uploads using [tool.semantic_release.publish]

Options:#

--tag#

The tag associated with the release to publish to. If not given or set to “latest”, then Python Semantic Release will examine the Git tags in your repository to identify the latest version, and attempt to publish to a Release corresponding to this version.

Default: “latest”

semantic-release generate-config#

Generate default configuration for semantic-release, to help you get started quickly. You can inspect the defaults, write to a file and then edit according to your needs. For example, to append the default configuration to your pyproject.toml file, you can use the following command:

$ semantic-release generate-config -f toml --pyproject >> pyproject.toml

If your project doesn’t already leverage TOML files for configuration, it might better suit your project to use JSON instead:

$ semantic-release generate-config -f json

If you would like to add JSON configuration to a shared file, e.g. package.json, you can then simply add the output from this command as a top-level key to the file.

Note: Because there is no “null” or “nil” concept in TOML (see the relevant GitHub issue), configuration settings which are None by default are omitted from the default configuration.

See also

Options:#

-f/--format [FORMAT]#

The format that the default configuration should be generated in. Valid choices are toml and json (case-insensitive).

Default: toml

--pyproject#

If used alongside --format json, this option has no effect. When using --format=toml, if specified the configuration will sit under a top-level key of tool.semantic_release to comply with PEP 518; otherwise, the configuration will sit under a top-level key of semantic_release.

semantic-release changelog#

Generate and optionally publish a changelog for your project. The changelog is generated based on a template which can be customized.

Python Semantic Release uses Jinja as its templating engine; as a result templates need to be written according to the Template Designer Documentation.

Options:#

--post-to-release-tag [TAG]#

If supplied, attempt to find a release in the remote VCS corresponding to the Git tag TAG, and post the generated changelog to that release. If the tag exists but no corresponding release is found in the remote VCS, then Python Semantic Release will attempt to create one.

If using this option, the relevant authentication token must be supplied via the relevant environment variable. For more information, see Creating VCS Releases.