Skip to content

Commit a7d05ef

Browse files
committed
fix: address second round of review feedback
- Clarify publish helper comment to describe re-run context - Add comment explaining force-push is intentional for re-runs - Improve PR existence check to distinguish "not found" from API errors - Improve PR body to mention rule docs and site data updates
1 parent 2a6e9bd commit a7d05ef

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ jobs:
262262
if cargo publish -p "$crate" 2>&1; then
263263
echo "$crate $version published successfully"
264264
else
265-
# Check crates.io API for the specific version (handles older tags, indexing lag)
265+
# Check if version already exists on crates.io (handles re-runs after partial failures)
266266
status=$(curl -s -o /dev/null -w "%{http_code}" "https://crates.io/api/v1/crates/$crate/$version")
267267
if [ "$status" = "200" ]; then
268268
echo "$crate $version already published, skipping"
@@ -485,16 +485,26 @@ jobs:
485485
BRANCH="docs/version-${{ steps.version.outputs.version }}"
486486
git checkout -B "$BRANCH"
487487
git commit -m "docs: version ${{ steps.version.outputs.version }} docs and update site data"
488+
# Force-push to update the auto-generated docs branch on workflow re-runs
488489
git push --force-with-lease origin "$BRANCH"
489490
# Create PR only if one doesn't already exist for this branch
490-
if gh pr view --head "$BRANCH" --json number --jq '.number' 2>/dev/null; then
491+
PR_CHECK_ERR="$(mktemp)"
492+
if gh pr view --head "$BRANCH" --json number --jq '.number' >/dev/null 2>"$PR_CHECK_ERR"; then
491493
echo "PR already exists for $BRANCH, updated with force push"
492494
else
493-
gh pr create \
494-
--base main \
495-
--head "$BRANCH" \
496-
--title "docs: version ${{ steps.version.outputs.version }} docs" \
497-
--body "Auto-generated versioned docs snapshot for v${{ steps.version.outputs.version }}." \
498-
--label "documentation"
495+
if grep -qiE 'not[[:space:]]+found|could not find pull request|no pull requests' "$PR_CHECK_ERR"; then
496+
gh pr create \
497+
--base main \
498+
--head "$BRANCH" \
499+
--title "docs: version ${{ steps.version.outputs.version }} docs" \
500+
--body "Auto-generated versioned docs snapshot for v${{ steps.version.outputs.version }}, including updated rule docs and site data." \
501+
--label "documentation"
502+
else
503+
echo "Error checking for existing PR:"
504+
cat "$PR_CHECK_ERR"
505+
rm -f "$PR_CHECK_ERR"
506+
exit 1
507+
fi
499508
fi
509+
rm -f "$PR_CHECK_ERR"
500510
fi

0 commit comments

Comments
 (0)