prepare-release-merge.sh 1015 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. # Define merge branch name
  4. MERGE_BRANCH=merge/$GITHUB_REF_NAME
  5. # Create the branch and force to start from ref
  6. git checkout -B "$MERGE_BRANCH" "$GITHUB_REF_NAME"
  7. # Get deleted changesets in this branch that might conflict with master
  8. # --diff-filter=D - Only deleted files
  9. readarray -t DELETED_CHANGESETS < <(git diff origin/master --diff-filter=D --name-only -- '.changeset/*.md')
  10. # Merge master, which will take those files cherry-picked. Auto-resolve conflicts favoring master.
  11. # Ignore conflicts that can't be resolved.
  12. git merge origin/master -m "Merge master to $GITHUB_REF_NAME" -X theirs || true
  13. # Remove the originally deleted changesets to correctly sync with master
  14. rm -f "${DELETED_CHANGESETS[@]}"
  15. # Only git add deleted files
  16. git ls-files --deleted .changeset/ | xargs git add
  17. # Allow empty here since there may be no changes if `rm -f` failed for all changesets
  18. git commit --allow-empty -m "Sync changesets with master"
  19. git push -f origin "$MERGE_BRANCH"