Skip to content

Commit 7edf15c

Browse files
authored
fix(release): use Node.js instead of Bun for release scripts (#113)
## Summary The Craft Docker container (used for publish/post-publish) doesn't have Bun installed, causing release script failures. This PR converts the release scripts to use Node.js instead. ## Changes - Convert `script/bump-version.ts` to use Node.js APIs (`child_process`, `fs`) instead of Bun-specific APIs - Update `.craft.yml` to use `node --experimental-strip-types` for pre/post release commands - Remove the `setup-bun` action from the release workflow (no longer needed) The script remains TypeScript, leveraging Node.js 22's built-in type stripping feature.
1 parent 2341c14 commit 7edf15c

3 files changed

Lines changed: 44 additions & 32 deletions

File tree

.craft.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ changelog:
33
policy: auto
44
versioning:
55
policy: auto
6-
preReleaseCommand: bun run script/bump-version.ts --pre
7-
postReleaseCommand: bun run script/bump-version.ts --post
6+
preReleaseCommand: node --experimental-strip-types script/bump-version.ts --pre
7+
postReleaseCommand: node --experimental-strip-types script/bump-version.ts --post
88
requireNames:
99
- /^sentry-.+$/
1010
- /^sentry-.*\.tgz$/

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ jobs:
3030
with:
3131
token: ${{ steps.token.outputs.token }}
3232
fetch-depth: 0
33-
- name: Setup Bun
34-
uses: oven-sh/setup-bun@v2
3533
- name: Prepare release
3634
uses: getsentry/craft@v2
3735
env:

script/bump-version.ts

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#!/usr/bin/env bun
1+
#!/usr/bin/env node
22
/**
33
* Version Bump Script
44
*
55
* Handles version bumping for releases, keeping package.json and plugin.json in sync.
66
* Extracted from .craft.yml inline scripts for maintainability.
77
*
88
* Usage:
9-
* bun run script/bump-version.ts --pre # Pre-release: set CRAFT_NEW_VERSION
10-
* bun run script/bump-version.ts --post # Post-release: bump to next dev version
9+
* node --experimental-strip-types script/bump-version.ts --pre # Pre-release: set CRAFT_NEW_VERSION
10+
* node --experimental-strip-types script/bump-version.ts --post # Post-release: bump to next dev version
1111
*
1212
* Pre-release (--pre):
1313
* - Sets package.json version to CRAFT_NEW_VERSION
@@ -19,7 +19,8 @@
1919
* - Commits and pushes if there are changes
2020
*/
2121

22-
import { $ } from "bun";
22+
import { execSync, spawnSync } from "node:child_process";
23+
import { readFileSync, writeFileSync } from "node:fs";
2324

2425
const PLUGIN_PATH = "plugins/sentry-cli/.claude-plugin/plugin.json";
2526

@@ -34,16 +35,15 @@ type PluginJson = {
3435
/**
3536
* Read and parse plugin.json
3637
*/
37-
async function readPluginJson(): Promise<PluginJson> {
38-
const file = Bun.file(PLUGIN_PATH);
39-
return (await file.json()) as PluginJson;
38+
function readPluginJson(): PluginJson {
39+
return JSON.parse(readFileSync(PLUGIN_PATH, "utf-8")) as PluginJson;
4040
}
4141

4242
/**
4343
* Write plugin.json with consistent formatting
4444
*/
45-
async function writePluginJson(plugin: PluginJson): Promise<void> {
46-
await Bun.write(PLUGIN_PATH, `${JSON.stringify(plugin, null, 2)}\n`);
45+
function writePluginJson(plugin: PluginJson): void {
46+
writeFileSync(PLUGIN_PATH, `${JSON.stringify(plugin, null, 2)}\n`);
4747
}
4848

4949
/**
@@ -55,10 +55,17 @@ function stripPrerelease(version: string): string {
5555
return version.replace(PRERELEASE_SUFFIX_REGEX, "");
5656
}
5757

58+
/**
59+
* Execute a shell command with output inherited to stdout/stderr
60+
*/
61+
function exec(command: string): void {
62+
execSync(command, { stdio: "inherit" });
63+
}
64+
5865
/**
5966
* Pre-release: Set version from CRAFT_NEW_VERSION environment variable
6067
*/
61-
async function preRelease(): Promise<void> {
68+
function preRelease(): void {
6269
const version = process.env.CRAFT_NEW_VERSION;
6370
if (!version) {
6471
console.error("Error: CRAFT_NEW_VERSION environment variable is required");
@@ -68,42 +75,49 @@ async function preRelease(): Promise<void> {
6875
console.log(`Setting version to ${version}`);
6976

7077
// Update package.json via npm (handles formatting consistently)
71-
await $`npm --no-git-tag-version version ${version}`;
78+
exec(`npm --no-git-tag-version version ${version}`);
7279

7380
// Update plugin.json (strip prerelease suffix for cleaner version)
74-
const plugin = await readPluginJson();
81+
const plugin = readPluginJson();
7582
plugin.version = stripPrerelease(version);
76-
await writePluginJson(plugin);
83+
writePluginJson(plugin);
7784

7885
console.log(`Updated plugin.json to ${plugin.version}`);
7986
}
8087

8188
/**
8289
* Post-release: Bump to next dev version, commit and push
8390
*/
84-
async function postRelease(): Promise<void> {
91+
function postRelease(): void {
8592
console.log("Bumping to next development version");
8693

8794
// Bump package.json to next preminor with -dev prerelease
88-
await $`npm --no-git-tag-version version preminor --preid=dev`;
95+
exec("npm --no-git-tag-version version preminor --preid=dev");
8996

9097
// Read the new version from package.json
91-
const pkg = (await Bun.file("package.json").json()) as { version: string };
98+
const pkg = JSON.parse(readFileSync("package.json", "utf-8")) as {
99+
version: string;
100+
};
92101
console.log(`package.json bumped to ${pkg.version}`);
93102

94103
// Update plugin.json
95-
const plugin = await readPluginJson();
104+
const plugin = readPluginJson();
96105
plugin.version = stripPrerelease(pkg.version);
97-
await writePluginJson(plugin);
106+
writePluginJson(plugin);
98107
console.log(`Updated plugin.json to ${plugin.version}`);
99108

100109
// Commit and push if there are changes
101-
const diffResult = await $`git diff --quiet`.nothrow();
102-
if (diffResult.exitCode !== 0) {
110+
// Use spawnSync to check exit code without throwing
111+
const diffResult = spawnSync("git", ["diff", "--quiet"], {
112+
stdio: "inherit",
113+
});
114+
if (diffResult.status !== 0) {
103115
console.log("Committing version bump");
104-
await $`git commit -anm ${"meta: Bump new development version\n\n#skip-changelog"}`;
105-
await $`git pull --rebase`;
106-
await $`git push`;
116+
exec(
117+
'git commit -anm "meta: Bump new development version\n\n#skip-changelog"'
118+
);
119+
exec("git pull --rebase");
120+
exec("git push");
107121
console.log("Pushed version bump");
108122
} else {
109123
console.log("No changes to commit");
@@ -115,15 +129,15 @@ async function postRelease(): Promise<void> {
115129
*/
116130
function printUsage(): void {
117131
console.log(`
118-
Usage: bun run script/bump-version.ts <mode>
132+
Usage: node --experimental-strip-types script/bump-version.ts <mode>
119133
120134
Modes:
121135
--pre Pre-release: set version from CRAFT_NEW_VERSION env var
122136
--post Post-release: bump to next dev version, commit and push
123137
124138
Examples:
125-
CRAFT_NEW_VERSION=1.0.0 bun run script/bump-version.ts --pre
126-
bun run script/bump-version.ts --post
139+
CRAFT_NEW_VERSION=1.0.0 node --experimental-strip-types script/bump-version.ts --pre
140+
node --experimental-strip-types script/bump-version.ts --post
127141
`);
128142
}
129143

@@ -148,7 +162,7 @@ if (!mode) {
148162
}
149163

150164
if (mode === "pre") {
151-
await preRelease();
165+
preRelease();
152166
} else {
153-
await postRelease();
167+
postRelease();
154168
}

0 commit comments

Comments
 (0)