Skip to content

Commit 095d22a

Browse files
committed
chore: add version.ts and master will always be 0.0.0-dev
1 parent eaaf4d6 commit 095d22a

File tree

4 files changed

+47
-20
lines changed

4 files changed

+47
-20
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- run : bun run prepare
1717
- name: Publish to npm
1818
run : |
19+
bun run version.ts
1920
bun publish --ignore-scripts --access=public
2021
env :
2122
NPM_CONFIG_TOKEN: ${{ secrets.NPM_CONFIG_TOKEN }}

bun.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
2-
"name": "w",
3-
"version": "2.0.0",
4-
"description": "Extremely tiny debug logging utility for all JavaScript runtimes.",
5-
"license": "MIT",
6-
"author": "Muthu Kumar <[email protected]> (https://mkr.pw)",
7-
"main": "./lib/w.js",
8-
"types": "./lib/w.d.ts",
9-
"files": [
10-
"lib/"
11-
],
12-
"private": false,
13-
"scripts": {
14-
"check": "tsc --noEmit",
15-
"build": "tsc",
16-
"prepare": "npm run build"
17-
},
18-
"devDependencies": {
19-
"typescript": "^5.0.0"
20-
}
21-
}
2+
"name": "w",
3+
"version": "0.0.0-dev",
4+
"description": "Extremely tiny debug logging utility for all JavaScript runtimes.",
5+
"license": "MIT",
6+
"author": "Muthu Kumar <[email protected]> (https://mkr.pw)",
7+
"main": "./lib/w.js",
8+
"types": "./lib/w.d.ts",
9+
"files": [
10+
"w.png",
11+
"lib/"
12+
],
13+
"private": false,
14+
"scripts": {
15+
"check": "tsc --noEmit",
16+
"build": "tsc",
17+
"prepare": "npm run build"
18+
},
19+
"devDependencies": {
20+
"@types/bun": "^1.2.8",
21+
"typescript": "^5.0.0"
22+
}
23+
}

version.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export {};
2+
3+
const tag = process.env.GITHUB_REF;
4+
const version = tag ? tag.slice(11) : process.env.VERSION;
5+
6+
if (!version)
7+
throw new Error("VERSION environment variable not found. Use similar to `VERSION=0.1.0 bun run version.ts`");
8+
9+
const pkg = JSON.parse(await Bun.file("./package.json").text());
10+
11+
pkg.version = version;
12+
13+
await Bun.write("./package.json", JSON.stringify(pkg, null, 2));

0 commit comments

Comments
 (0)