Skip to content

Commit 06c5f8f

Browse files
fix(release): run the deduper from a path that survives the checkout (#211)
The step failed on its first real run: Error: Cannot find module '.../scripts/dedupe-changelog.mjs' It checks out the release branch, and that branch is cut from whatever main was when release-please first opened the pull request - which predates the script. So it checked out a tree without its own script in it. Copy the script to $RUNNER_TEMP before touching the working tree, and run it from there. Rehearsing the step locally against the real release branch also turned up a second failure the first run never reached: `git checkout -` aborts with "Your local changes would be overwritten" when CHANGELOG.md is still dirty. It only switched back out of tidiness - step 2 works entirely through the API, with the script already copied out - so it no longer switches back at all. Verified by running the step verbatim against release-please--branches--main: 11 duplicates removed, commit created, exit 0. Co-authored-by: Claude <noreply@anthropic.com>
1 parent f431962 commit 06c5f8f

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎.github/workflows/release-please.yml‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,29 @@ jobs:
8686
run: |
8787
set -euo pipefail
8888
89+
# Copied out of the working tree before anything is checked out. The
90+
# release branch is cut from whatever main was when release-please
91+
# first opened the pull request, so it does not necessarily contain
92+
# this script - the first run failed with MODULE_NOT_FOUND on the
93+
# script's own path, immediately after checking out that branch.
94+
SCRIPT="$RUNNER_TEMP/dedupe-changelog.mjs"
95+
cp scripts/dedupe-changelog.mjs "$SCRIPT"
96+
8997
# 1. The rolling release pull request.
9098
if git ls-remote --exit-code --heads origin "$RELEASE_BRANCH" >/dev/null 2>&1; then
9199
git fetch --quiet origin "$RELEASE_BRANCH"
92100
git checkout --quiet "$RELEASE_BRANCH"
93-
node scripts/dedupe-changelog.mjs CHANGELOG.md
101+
node "$SCRIPT" CHANGELOG.md
94102
if ! git diff --quiet -- CHANGELOG.md; then
95103
git config user.name "github-actions[bot]"
96104
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
97105
git commit -q -m "chore: drop duplicate changelog entries" -- CHANGELOG.md
98106
git push origin "$RELEASE_BRANCH"
99107
fi
100-
git checkout --quiet -
108+
# Deliberately does not switch back. `git checkout -` aborts if
109+
# CHANGELOG.md is still dirty, and nothing below needs the working
110+
# tree - step 2 runs entirely through the API, with the script
111+
# already copied out to $RUNNER_TEMP.
101112
fi
102113
103114
# 2. Any draft release. Its notes are stored separately from
@@ -108,6 +119,6 @@ jobs:
108119
for tag in $(gh release list --limit 20 --json tagName,isDraft \
109120
--jq '.[] | select(.isDraft) | .tagName'); do
110121
gh release view "$tag" --json body --jq .body > "$notes"
111-
node scripts/dedupe-changelog.mjs "$notes"
122+
node "$SCRIPT" "$notes"
112123
gh release edit "$tag" --notes-file "$notes"
113124
done

0 commit comments

Comments
 (0)