@@ -109,6 +109,14 @@ jobs:
109109
110110 pkg.version = `${baseVersion}-${channel}.${timestamp}`;
111111 fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
112+
113+ const changelogPath = "CHANGELOG.md";
114+ const changelog = fs.readFileSync(changelogPath, "utf8");
115+ fs.writeFileSync(
116+ changelogPath,
117+ changelog.replace(`## ${baseVersion}`, `## ${pkg.version}`),
118+ );
119+
112120 console.log(`Prepared ${pkg.name}@${pkg.version}`);
113121 NODE
114122
@@ -131,6 +139,33 @@ jobs:
131139 echo "Publishing prerelease version $NEXT."
132140 fi
133141
142+ - name : Prepare GitHub release notes
143+ if : steps.publishable.outputs.ready == 'true'
144+ env :
145+ VERSION : ${{ steps.pkg.outputs.version }}
146+ CHANNEL : ${{ env.CHANNEL }}
147+ run : |
148+ node <<'NODE'
149+ const fs = require("node:fs");
150+
151+ const version = process.env.VERSION;
152+ const channel = process.env.CHANNEL;
153+ const changelog = fs.readFileSync("CHANGELOG.md", "utf8");
154+ const heading = `## ${version}`;
155+ const start = changelog.indexOf(heading);
156+ const next =
157+ start === -1 ? -1 : changelog.indexOf("\n## ", start + heading.length);
158+
159+ let notes =
160+ start === -1
161+ ? `## ${version}\n\nPrerelease published from branch ${process.env.GITHUB_REF_NAME}.`
162+ : changelog.slice(start, next === -1 ? undefined : next).trim();
163+
164+ notes += `\n\nInstall with:\n\n\`\`\`sh\nnpm i drizzle-cursor@${channel}\n\`\`\`\n`;
165+
166+ fs.writeFileSync("release-notes.md", `${notes}\n`);
167+ NODE
168+
134169 - name : Publish prerelease
135170 if : steps.publishable.outputs.ready == 'true'
136171 run : |
@@ -155,11 +190,10 @@ jobs:
155190 VERSION : ${{ steps.pkg.outputs.version }}
156191 CHANNEL : ${{ env.CHANNEL }}
157192 run : |
158- NOTES="Prerelease published from branch $GITHUB_REF_NAME on channel '$CHANNEL'. Install with: npm i drizzle-cursor@$CHANNEL"
159193 if gh release view "v$VERSION" >/dev/null 2>&1; then
160- gh release edit "v$VERSION" --prerelease --title "v$VERSION" --notes "$NOTES"
194+ gh release edit "v$VERSION" --prerelease --title "v$VERSION" --notes-file release-notes.md
161195 else
162- gh release create "v$VERSION" --target "$GITHUB_SHA" --prerelease --title "v$VERSION" --notes "$NOTES"
196+ gh release create "v$VERSION" --target "$GITHUB_SHA" --prerelease --title "v$VERSION" --notes-file release-notes.md
163197 fi
164198
165199 - name : Fail when no changeset is present
0 commit comments