Merge pull request #73 from privilegedescalation/fix/release-branch-re-trigger
fix(release): handle re-triggers — stale branch cleanup and duplicate PR guard
This commit is contained in:
@@ -215,11 +215,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VERSION="${{ inputs.version }}"
|
VERSION="${{ inputs.version }}"
|
||||||
BRANCH="release/v${VERSION}"
|
BRANCH="release/v${VERSION}"
|
||||||
|
# If the release branch already exists (e.g. from a failed prior run),
|
||||||
|
# delete it so the re-trigger can proceed cleanly. The check-tag job
|
||||||
|
# above already skips when the tag exists, so we only reach here when
|
||||||
|
# the tag does NOT exist yet — safe to remove a stale branch.
|
||||||
|
if git ls-remote --exit-code origin "refs/heads/$BRANCH" 2>/dev/null; then
|
||||||
|
echo "::notice::Branch $BRANCH already exists — deleting for clean re-trigger."
|
||||||
|
git push origin --delete "$BRANCH"
|
||||||
|
fi
|
||||||
git checkout -b "$BRANCH"
|
git checkout -b "$BRANCH"
|
||||||
git add package.json "${{ steps.pkg-manager.outputs.lockfile }}" artifacthub-pkg.yml
|
git add package.json "${{ steps.pkg-manager.outputs.lockfile }}" artifacthub-pkg.yml
|
||||||
git commit -m "release: v${VERSION}"
|
git commit -m "release: v${VERSION}"
|
||||||
git tag "v${VERSION}"
|
git tag "v${VERSION}"
|
||||||
git push origin "$BRANCH" --tags
|
git push origin "$BRANCH"
|
||||||
|
git push origin "refs/tags/v${VERSION}"
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
@@ -255,11 +264,16 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VERSION="${{ inputs.version }}"
|
VERSION="${{ inputs.version }}"
|
||||||
BODY=$(printf "Automated version bump and checksum update for v%s.\n\ncc @cpfarhood" "${VERSION}")
|
BODY=$(printf "Automated version bump and checksum update for v%s.\n\ncc @cpfarhood" "${VERSION}")
|
||||||
gh pr create \
|
# Create PR only if one doesn't already exist (idempotent re-trigger).
|
||||||
--title "release: v${VERSION}" \
|
if ! gh pr view "release/v${VERSION}" --json number 2>/dev/null; then
|
||||||
--body "$BODY" \
|
gh pr create \
|
||||||
--base main \
|
--title "release: v${VERSION}" \
|
||||||
--head "release/v${VERSION}"
|
--body "$BODY" \
|
||||||
|
--base main \
|
||||||
|
--head "release/v${VERSION}"
|
||||||
|
else
|
||||||
|
echo "::notice::PR for release/v${VERSION} already exists — skipping creation."
|
||||||
|
fi
|
||||||
# Try auto-merge first (works on repos with required status checks pending).
|
# Try auto-merge first (works on repos with required status checks pending).
|
||||||
# Fall back to direct squash merge on repos without required status checks
|
# Fall back to direct squash merge on repos without required status checks
|
||||||
# (auto-merge is rejected when there are no pending required checks to wait for).
|
# (auto-merge is rejected when there are no pending required checks to wait for).
|
||||||
|
|||||||
Reference in New Issue
Block a user