Skip to content

Commit 4b4de01

Browse files
Simplify release command flow
1 parent 0f3553d commit 4b4de01

3 files changed

Lines changed: 10 additions & 43 deletions

File tree

docs/releases.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,4 @@ bun run release 0.2.0
4646

4747
`release` updates `package.json`, runs the package checks, commits the version bump, creates the matching tag, pushes `main` and the tag, creates the GitHub Release, waits for the publish workflow, and verifies that npm has the new package version.
4848

49-
The lower-level commands are still available when you need to split the release into two steps:
50-
51-
```sh
52-
bun run release:prepare patch
53-
bun run release:push
54-
```
55-
56-
`release:prepare` updates `package.json`, runs the package checks, commits the version bump, and creates the matching tag locally. `release:push` pushes `main` and that exact tag, creates or updates the GitHub Release, waits for the publish workflow, and verifies that npm has the new package version.
57-
5849
The workflow checks that the tag matches `package.json` before publishing, so a mismatched tag cannot publish accidentally.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@
5050
"lint:fix": "biome lint src scripts .github/scripts rolldown.config.ts --write --skip=lint/performance/noBarrelFile --skip=lint/style/useConsistentTypeDefinitions --skip=lint/suspicious/noConsole",
5151
"check": "bun run lint && bun run typecheck && bun run build && bun run pack:dry-run",
5252
"pack:dry-run": "npm pack --dry-run",
53-
"release": "node scripts/release.mjs release",
54-
"release:prepare": "node scripts/release.mjs prepare",
55-
"release:push": "node scripts/release.mjs push",
53+
"release": "node scripts/release.mjs",
5654
"prepack": "bun run build",
5755
"prepublishOnly": "bun run lint && bun run typecheck"
5856
},

scripts/release.mjs

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ const publishRunLookupIntervalMs = 5000;
1515
const npmVersionLookupAttempts = 24;
1616
const npmVersionLookupIntervalMs = 5000;
1717
const sharedBufferBytes = 4;
18-
const command = process.argv[2];
19-
20-
if (command === "release") {
21-
releaseVersion(process.argv[3]);
22-
} else if (command === "prepare") {
23-
prepareRelease(process.argv[3]);
24-
} else if (command === "push") {
25-
pushRelease();
26-
} else {
18+
const requestedVersion = process.argv[2];
19+
20+
if (!requestedVersion) {
2721
printUsage();
2822
process.exit(1);
2923
}
3024

25+
releaseVersion(requestedVersion);
26+
3127
function releaseVersion(versionSpec) {
3228
const release = prepareRelease(versionSpec);
3329
pushRelease(release);
@@ -58,7 +54,7 @@ function prepareRelease(versionSpec) {
5854
run("git", ["commit", "-m", `Release ${tagName}`]);
5955
run("git", ["tag", tagName]);
6056

61-
console.log(`Prepared ${tagName}. Run "bun run release:push" to publish.`);
57+
console.log(`Prepared ${tagName}. Publishing release.`);
6258

6359
return {
6460
packageName: packageJson.name,
@@ -67,16 +63,14 @@ function prepareRelease(versionSpec) {
6763
};
6864
}
6965

70-
function pushRelease(release = readCurrentRelease()) {
66+
function pushRelease(release) {
7167
ensureMainBranch();
7268
ensureCleanTree();
7369

7470
const { packageName, tagName, version } = release;
7571

7672
if (!tagExists(tagName)) {
77-
fail(
78-
`${tagName} does not exist locally. Run "bun run release:prepare patch" first.`
79-
);
73+
fail(`${tagName} does not exist locally.`);
8074
}
8175

8276
const headCommit = read("git", ["rev-parse", "HEAD"]);
@@ -159,17 +153,6 @@ function readPackageJson() {
159153
return JSON.parse(readFileSync("package.json", "utf8"));
160154
}
161155

162-
function readCurrentRelease() {
163-
const packageJson = readPackageJson();
164-
const version = packageJson.version;
165-
166-
return {
167-
packageName: packageJson.name,
168-
tagName: `v${version}`,
169-
version,
170-
};
171-
}
172-
173156
function writePackageJson(packageJson) {
174157
writeFileSync("package.json", `${JSON.stringify(packageJson, null, 2)}\n`);
175158
}
@@ -348,10 +331,5 @@ function printUsage() {
348331
bun run release patch
349332
bun run release minor
350333
bun run release major
351-
bun run release 0.2.0
352-
bun run release:prepare patch
353-
bun run release:prepare minor
354-
bun run release:prepare major
355-
bun run release:prepare 0.2.0
356-
bun run release:push`);
334+
bun run release 0.2.0`);
357335
}

0 commit comments

Comments
 (0)