diff --git a/docs/commands.rst b/docs/commands.rst index cda93f43b..0ec13b2e4 100644 --- a/docs/commands.rst +++ b/docs/commands.rst @@ -309,7 +309,7 @@ For example, assuming a project is currently at version 1.2.3:: ************************ 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. +command invocation. If ``--no-commit`` is supplied, it may disable other options derivatively; please see below. @@ -324,8 +324,7 @@ If ``--no-commit`` is supplied, it may disable other options derivatively; pleas ************************ 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. +command invocation. If ``--no-tag`` is supplied, it may disable other options derivatively; please see below. @@ -353,7 +352,7 @@ version released. Whether or not to push new commits and/or tags to the remote repository. **Default:** ``--no-push`` if :ref:`--no-commit ` and -:ref:`--no-tag ` is also supplied, otherwise ``push`` is the default. +:ref:`--no-tag ` is supplied, otherwise ``push`` is the default. .. _cmd-version-option-vcs-release: @@ -365,7 +364,7 @@ releases in GitHub and Gitea remotes are supported. If releases aren't supported 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`` +implied by supplying ``--no-commit`` or ``--no-tag``), otherwise ``--vcs-release`` ``--skip-build`` **************** diff --git a/semantic_release/cli/commands/version.py b/semantic_release/cli/commands/version.py index 721ddfc62..941704043 100644 --- a/semantic_release/cli/commands/version.py +++ b/semantic_release/cli/commands/version.py @@ -446,20 +446,24 @@ def version( # noqa: C901 log.info("Forcing use of %s as the prerelease token", prerelease_token) translator.prerelease_token = prerelease_token - # Only push if we're committing changes + # Only push if changes are committed or tagged if push_changes and not commit_changes and not create_tag: - log.info("changes will not be pushed because --no-commit disables pushing") + log.info( + "changes will not be pushed because --no-commit --no-tag disables pushing" + ) push_changes &= commit_changes - - # Only push if we're creating a tag - if push_changes and not create_tag and not commit_changes: - log.info("new tag will not be pushed because --no-tag disables pushing") - push_changes &= create_tag - - # Only make a release if we're pushing the changes + # Only make a release if changes are pushed if make_vcs_release and not push_changes: log.info("No vcs release will be created because pushing changes is disabled") make_vcs_release &= push_changes + # Only make a release if changes are committed + if make_vcs_release and not commit_changes: + log.info("No vcs release will be created because --no-commit disables release") + make_vcs_release &= commit_changes + # Only make a release if tagged + if make_vcs_release and not create_tag: + log.info("No vcs release will be created because --no-tag disables release") + make_vcs_release &= create_tag if not forced_level_bump: with Repo(str(runtime.repo_dir)) as git_repo: @@ -648,7 +652,7 @@ def version( # noqa: C901 # are disabled, and the changelog generation is disabled or it's not # modified, then the HEAD commit will be tagged as a release commit # despite not being made by PSR - if commit_changes or create_tag: + if create_tag: project.git_tag( tag_name=new_version.as_tag(), message=new_version.as_tag(),