declapract-typescript-ehmpathy 0.47.28 → 0.47.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -362,37 +362,80 @@ runs:
362
362
  MAIN_SHA=$(gh api "repos/${REPO}/git/ref/heads/main" --jq '.object.sha')
363
363
 
364
364
  if [ -n "$FOUND_PR" ] && [ "$FOUND_PR" != "null" ]; then
365
- PR_NUMBER=$(echo "$FOUND_PR" | jq -r '.number')
366
- BRANCH=$(echo "$FOUND_PR" | jq -r '.headRefName')
367
- echo " ├── found-pr: #$PR_NUMBER ($BRANCH)"
368
-
369
- # upsert rebased commit
370
- echo " ├── upserting rebased commit..."
371
- COMMIT_SHA=$(upsert_rebased_commit "$BRANCH" "$MAIN_SHA" "chore(release): ${NEXT_VERSION} 🎉")
372
- echo " ├── commit: ${COMMIT_SHA:0:7}"
373
-
374
- # update pr metadata
375
- echo " ├── updating pr metadata..."
376
- gh pr edit "$PR_NUMBER" \
377
- --title "chore(release): ${NEXT_VERSION} 🎉" \
378
- --body "$PR_BODY"
379
-
380
- echo " ├── pr updated: #$PR_NUMBER"
381
- echo " └── 🌊 action: updated"
382
- echo "action=updated" >> $GITHUB_OUTPUT
383
- echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT
365
+ FOUND_PR_NUMBER=$(echo "$FOUND_PR" | jq -r '.number')
366
+ FOUND_PR_BRANCH=$(echo "$FOUND_PR" | jq -r '.headRefName')
367
+ IDEAL_PR_BRANCH="release/${NEXT_VERSION}"
368
+ echo " ├── found-pr: #$FOUND_PR_NUMBER ($FOUND_PR_BRANCH)"
369
+
370
+ # check if branch name matches expected version
371
+ if [ "$FOUND_PR_BRANCH" != "$IDEAL_PR_BRANCH" ]; then
372
+ echo " ├── branch mismatch: $FOUND_PR_BRANCH != $IDEAL_PR_BRANCH"
373
+ echo " ├── recreate pr with correct branch..."
374
+
375
+ # close found pr (with comment explaining why)
376
+ gh pr comment "$FOUND_PR_NUMBER" --body "🫧 closed: version bumped to ${NEXT_VERSION}, recreated pr with branch \`${IDEAL_PR_BRANCH}\`"
377
+ gh pr close "$FOUND_PR_NUMBER"
378
+ echo " ├── closed: #$FOUND_PR_NUMBER"
379
+
380
+ # delete found branch (fail fast unless already gone)
381
+ DELETE_OUTPUT=$(gh api "repos/${REPO}/git/refs/heads/${FOUND_PR_BRANCH}" -X DELETE 2>&1) || {
382
+ if echo "$DELETE_OUTPUT" | grep -q "Reference does not exist"; then
383
+ echo " ├── branch already deleted: $FOUND_PR_BRANCH"
384
+ else
385
+ echo " ├── ⛈️ failed to delete branch: $FOUND_PR_BRANCH"
386
+ echo "$DELETE_OUTPUT"
387
+ exit 1
388
+ fi
389
+ }
390
+ echo " ├── deleted branch: $FOUND_PR_BRANCH"
391
+
392
+ # create new branch with correct name
393
+ echo " ├── create branch: $IDEAL_PR_BRANCH"
394
+ COMMIT_SHA=$(upsert_rebased_commit "$IDEAL_PR_BRANCH" "$MAIN_SHA" "chore(release): ${NEXT_VERSION} 🎉")
395
+ echo " ├── commit: ${COMMIT_SHA:0:7}"
396
+
397
+ # create new pr
398
+ echo " ├── create pr..."
399
+ PR_URL=$(gh pr create \
400
+ --title "chore(release): ${NEXT_VERSION} 🎉" \
401
+ --body "$PR_BODY" \
402
+ --base main \
403
+ --head "$IDEAL_PR_BRANCH")
404
+
405
+ PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$')
406
+ echo " ├── ✨ pr recreated: #$PR_NUMBER (was #$FOUND_PR_NUMBER)"
407
+ echo " └── 🌊 action: recreated"
408
+ echo "action=recreated" >> $GITHUB_OUTPUT
409
+ echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT
410
+ else
411
+ # branch name matches, update in place
412
+ echo " ├── upsert rebased commit..."
413
+ COMMIT_SHA=$(upsert_rebased_commit "$FOUND_PR_BRANCH" "$MAIN_SHA" "chore(release): ${NEXT_VERSION} 🎉")
414
+ echo " ├── commit: ${COMMIT_SHA:0:7}"
415
+
416
+ # update pr metadata
417
+ echo " ├── update pr metadata..."
418
+ gh pr edit "$FOUND_PR_NUMBER" \
419
+ --title "chore(release): ${NEXT_VERSION} 🎉" \
420
+ --body "$PR_BODY"
421
+
422
+ echo " ├── ✨ pr updated: #$FOUND_PR_NUMBER"
423
+ echo " └── 🌊 action: updated"
424
+ echo "action=updated" >> $GITHUB_OUTPUT
425
+ echo "pr-number=$FOUND_PR_NUMBER" >> $GITHUB_OUTPUT
426
+ fi
384
427
  else
385
428
  BRANCH="release/${NEXT_VERSION}"
386
429
  echo " ├── found-pr: (none)"
387
430
  echo " ├── branch: $BRANCH"
388
431
 
389
432
  # upsert rebased commit (creates branch if missing)
390
- echo " ├── upserting rebased commit..."
433
+ echo " ├── upsert rebased commit..."
391
434
  COMMIT_SHA=$(upsert_rebased_commit "$BRANCH" "$MAIN_SHA" "chore(release): ${NEXT_VERSION} 🎉")
392
435
  echo " ├── commit: ${COMMIT_SHA:0:7}"
393
436
 
394
437
  # create pr
395
- echo " ├── creating pr..."
438
+ echo " ├── create pr..."
396
439
  PR_URL=$(gh pr create \
397
440
  --title "chore(release): ${NEXT_VERSION} 🎉" \
398
441
  --body "$PR_BODY" \
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.47.28",
5
+ "version": "0.47.29",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",