Skip to content

Commit 356ccc4

Browse files
authored
Merge pull request #2698 from ViewComponent/joelhawksley-redesigned-sniffle
Make script/release push and PR creation idempotent on retry
2 parents 690a9cf + 4a36ff7 commit 356ccc4

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

‎script/release‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,25 @@ commit() {
9595
}
9696

9797
push() {
98-
git push origin release-$1-$2-$3
99-
100-
# Open PR
101-
pr_url=$(gh pr create \
102-
--title "Release $1.$2.$3" \
103-
--body "Automated release PR for version $1.$2.$3." \
104-
--base main \
105-
--head release-$1-$2-$3 \
106-
--repo ViewComponent/view_component)
98+
# Force-push: the release-X-Y-Z branch is auto-generated and is safe
99+
# to overwrite. A previous failed run may have left the branch on the
100+
# remote, which would otherwise reject a non-fast-forward push.
101+
git push --force origin release-$1-$2-$3
102+
103+
# Open PR (or reuse an existing one from a previous failed run).
104+
pr_url=$(gh pr view "release-$1-$2-$3" \
105+
--repo ViewComponent/view_component \
106+
--json url --jq .url 2>/dev/null || true)
107+
if [ -z "$pr_url" ]; then
108+
pr_url=$(gh pr create \
109+
--title "Release $1.$2.$3" \
110+
--body "Automated release PR for version $1.$2.$3." \
111+
--base main \
112+
--head release-$1-$2-$3 \
113+
--repo ViewComponent/view_component)
114+
else
115+
echo "Reusing existing PR: $pr_url"
116+
fi
107117

108118
echo "####################################################"
109119
echo "PR opened: $pr_url"

0 commit comments

Comments
 (0)