From 6b5d5f62e9db6893b0731c08b7c9d47997211bef Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 7 Jul 2026 15:03:03 +0100 Subject: [PATCH] Fix release-gitflow not handling package.json conflicts correctly `version` must be kept from the master branch - all other fields should prefer develop. Without this, pnpm will be given a possibly corrupted pnpm-lock.yaml file to repair, which it will be loosening some dependencies and possibly breaking the develop branch post-merge --- .github/workflows/release-gitflow.yml | 5 +--- scripts/release/merge-master-develop.sh | 37 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100755 scripts/release/merge-master-develop.sh diff --git a/.github/workflows/release-gitflow.yml b/.github/workflows/release-gitflow.yml index 7f97b89a1e..80185db8e5 100644 --- a/.github/workflows/release-gitflow.yml +++ b/.github/workflows/release-gitflow.yml @@ -53,10 +53,7 @@ jobs: git config --global user.name "RiotRobot" - name: Merge to develop - run: | - git checkout develop - git merge -X ours master - pnpm install --lockfile-only --fix-lockfile --frozen-lockfile=false --ignore-scripts + run: .action-repo/scripts/release/merge-master-to-develop.sh - name: Reset dependencies if: inputs.dependencies diff --git a/scripts/release/merge-master-develop.sh b/scripts/release/merge-master-develop.sh new file mode 100755 index 0000000000..44dbbd75a5 --- /dev/null +++ b/scripts/release/merge-master-develop.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -ex + +git checkout develop +git merge origin/master --no-commit --no-ff || true + +CONFLICTS=$(git diff --name-only --diff-filter=U) + +if [ -n "$CONFLICTS" ]; then + if echo "$CONFLICTS" | grep -q 'package.json'; then + # Merge package.json in a way where we prefer all changes from `develop` + # except for the `version` field which we take from `master`. + git show HEAD:package.json > package.ours.json # develop + git show FETCH_HEAD:package.json > package.theirs.json # master + + jq -s '(.[0].version) as $masterVersion | (reduce .[] as $item ({}; . * $item)) | .version = $masterVersion' package.theirs.json package.ours.json > package.json + rm package.ours.json package.theirs.json + git add package.json + fi + + # Reset lockfile to ours (develop) to clear raw text syntax errors + if echo "$CONFLICTS" | grep -q 'pnpm-lock.yaml'; then + git checkout --ours pnpm-lock.yaml + fi + + # Fallback for any other files + git checkout --ours . 2>/dev/null || true +fi + +# Rebuild lockfile based on the unified package.json +pnpm install --lockfile-only --ignore-scripts --frozen-lockfile=false + +# Commit and push +git add . +git commit --no-edit +git push origin develop