Skip to content

Commit 84ff1ee

Browse files
committed
build: improve release script
1 parent 0f49478 commit 84ff1ee

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/release.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { $ } from "execa";
2+
import { readFile } from "node:fs/promises";
23
import newGithubReleaseUrl from "new-github-release-url";
34
import open from "open";
5+
import { SemVer } from "semver";
46

57
const $$ = $({ stdio: "inherit" });
68

@@ -13,18 +15,27 @@ if (await hasChanges()) {
1315

1416
await $$`npm run build`;
1517
await $$`npm run version`;
18+
const pkg = JSON.parse(await readFile("package.json", "utf8"));
1619
await $$`npm install`;
1720
await $$`git commit -a -m ${"chore: update versions"}`;
21+
await $$`git tag v${pkg.version}`;
1822
await $$`git push`;
1923
await $$`npm publish`;
2024

2125
const url = newGithubReleaseUrl({
2226
user: "tscpp",
2327
repo: "conventional-versioning",
28+
tag: `v${pkg.version}`,
29+
isPrerelease: isPreRelease(pkg.version),
2430
});
2531
await open(url);
2632

2733
async function hasChanges() {
2834
const { stdout } = await $`git status --porcelain`;
2935
return stdout.trim() !== "";
3036
}
37+
38+
function isPreRelease(version) {
39+
version = new SemVer(version);
40+
return version.prerelease.length > 0;
41+
}

0 commit comments

Comments
 (0)