@@ -636,6 +636,7 @@ def release(ctx: Context, *cli_args: str) -> None:
636636 silent=True,
637637 capture=True,
638638 allow_overrides=False,
639+ nofail=True,
639640 )
640641
641642 dry_run = "--dry-run" in cli_args
@@ -655,16 +656,36 @@ def release(ctx: Context, *cli_args: str) -> None:
655656 )
656657 return
657658
658- ctx.run(["git", "push"], title="Pushing commits", pty=False)
659- ctx.run(["git", "push", "--tags"], title="Pushing tags", pty=False)
659+ output = ctx.run(
660+ ["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
661+ title="Checking if an upstream is configured for the current branch",
662+ nofail=True,
663+ capture=True,
664+ allow_overrides=False,
665+ )
666+ is_upstream_set = "fatal" not in output
667+ if is_upstream_set:
668+ ctx.run(["git", "push"], title="Pushing commits", pty=False)
669+ ctx.run(["git", "push", "--tags"], title="Pushing tags", pty=False)
670+ else:
671+ ctx.run(
672+ "false",
673+ title="git-push: skipped => no upstream is configured for the current branch",
674+ nofail=True,
675+ )
660676
661677 clean.run()
662678 build.run()
663679 {% - if publish_to_pypi %}
664680 publish.run()
665681 {% - endif %}
666682 {% - if repository_provider == 'github' %}
667- docs_deploy.run()
683+ if is_upstream_set:
684+ docs_deploy.run()
685+ else:
686+ ctx.run(
687+ "false", title="docs-deploy: skipped => the new release was not pushed", nofail=True
688+ )
668689 {% - endif %}
669690{% - endif %}
670691{% - if dockerfile %}
0 commit comments