Skip to content

Commit 7e36ecb

Browse files
committed
🐛 fix(duties.py): made the release duty more robust to errors
1 parent 5088fe6 commit 7e36ecb

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

template/duties.py.jinja

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)