prepare-release-merge.sh 849 B

123456789101112131415161718192021222324
  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. readarray -t DELETED_CHANGESETS < <(git diff origin/master --name-only -- '.changeset/*.md')
  9. # Merge master, which will take those files cherry-picked. Auto-resolve conflicts favoring master.
  10. git merge origin/master -m "Merge master to $GITHUB_REF_NAME" -X theirs
  11. # Remove the originally deleted changesets to correctly sync with master
  12. rm -f "${DELETED_CHANGESETS[@]}"
  13. git add .changeset/
  14. # Allow empty here since there may be no changes if `rm -f` failed for all changesets
  15. git commit --allow-empty -m "Sync changesets with master"
  16. git push -f origin "$MERGE_BRANCH"