Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/pr-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ jobs:
- name: Enable auto-merge
if: ${{github.actor == 'otto-the-bot' || (github.actor == 'dependabot[bot]' && steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major') || (github.event.pull_request.labels && contains(github.event.pull_request.labels.*.name, 'publish-to-npm')) }}
run: |
if [[ "${{ github.event.pull_request.labels }}" == *publish-to-npm* ]]; then
gh pr merge --auto --merge "$PR_URL"
else
gh pr merge --auto --squash "$PR_URL"
fi
gh pr merge --auto --squash "$PR_URL"
env:
GITHUB_TOKEN: ${{secrets.OTTO_THE_BOT_GH_TOKEN}}
PR_URL: ${{github.event.pull_request.html_url}}
48 changes: 48 additions & 0 deletions .github/workflows/publish-libraries-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,54 @@ jobs:
# if other PRs merge between trigger and job start
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Retarget release tags to squash merge commit
if: github.event_name == 'pull_request'
Comment thread
thisisamir98 marked this conversation as resolved.
env:
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail

echo "🔧 Retargeting release tags from PR head to merge commit"
echo "PR_HEAD_SHA=$PR_HEAD_SHA"
echo "MERGE_SHA=$MERGE_SHA"
Comment thread
thisisamir98 marked this conversation as resolved.

git fetch --force --tags origin

Comment thread
thisisamir98 marked this conversation as resolved.
# Tags are created on the PR branch commit. After squash-merge, that commit is no longer on dev,
# so we force-move those tags to the squash merge commit.
ALL_POINTS_AT="$(git tag --points-at "$PR_HEAD_SHA" || true)"
if [ -z "$ALL_POINTS_AT" ]; then
echo "❌ No git tags found pointing at PR head commit ($PR_HEAD_SHA)."
echo "This likely means the release workflow didn't create/push tags for this PR. Aborting publish."
exit 1
fi
Comment thread
thisisamir98 marked this conversation as resolved.

# Only retarget tags matching the expected {lib}@{version} shape.
TAGS_TO_MOVE="$(printf '%s\n' "$ALL_POINTS_AT" | grep -E '^[A-Za-z0-9._-]+@[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$' || true)"
Comment thread
thisisamir98 marked this conversation as resolved.
if [ -z "$TAGS_TO_MOVE" ]; then
echo "❌ Tags pointing at PR head exist, but none match the {lib}@{version} pattern. Aborting publish."
echo "Tags found:"
printf '%s\n' "$ALL_POINTS_AT"
exit 1
fi

echo "📌 Tags to retarget:"
printf '%s\n' "$TAGS_TO_MOVE"

while IFS= read -r tag; do
[ -n "$tag" ] || continue

old_sha="$(git rev-parse "$tag^{commit}")"
git tag -f "$tag" "$MERGE_SHA"
new_sha="$(git rev-parse "$tag^{commit}")"

echo "🔁 $tag: $old_sha -> $new_sha"

# Force-push the updated tag ref.
git push origin -f "refs/tags/$tag"
done <<< "$TAGS_TO_MOVE"
Comment thread
thisisamir98 marked this conversation as resolved.
Comment thread
thisisamir98 marked this conversation as resolved.

- name: Setup Node.js
uses: actions/setup-node@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ jobs:
--head "$RELEASE_BRANCH" \
--title "chore(release): publish libraries [WPB-22420]" \
--label "publish-to-npm" \
--body "Automated release PR created by nx release. ⚠️ **Important:** Do NOT squash merge this PR. Use 'Merge commit' to preserve git tags."
--body "Automated release PR created by nx release. ⚠️ **Important:** Squash-merge this PR (do not use 'Merge commit')."
env:
GITHUB_TOKEN: ${{ secrets.OTTO_THE_BOT_GH_TOKEN }}