Skip to content

Commit

Permalink
build(version): added 'publish' script to be called by merge-release …
Browse files Browse the repository at this point in the history
…action.
  • Loading branch information
MrCoder committed Dec 17, 2024
1 parent cf69cf8 commit 5f5e05b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"git:branch:safe-delete": "echo '> git log --graph --left-right --cherry --oneline another-branch...main'",
"git:forget": "git rm -r --cached . && git add . && git commit -m \"Forget all ignored files\"",
"test:specs": "echo \"Error: test:specs is not supported\"",
"prepare": "husky install"
"prepare": "husky install",
"publish": "pnpm build && npm publish"
},
"main": "./dist/zenuml.js",
"module": "./dist/zenuml.esm.mjs",
Expand Down
8 changes: 7 additions & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export const VERSION = import.meta.env.PACKAGE_VERSION;
/**
* The version is managed by merge-release during npm publish:
* - Git repository shows 3.0.0 in package.json
* - npm package shows the actual released version (e.g. 3.27.0)
* - Git tags track the released versions (v3.27.0)
*/
export const VERSION = process.env.VITE_VERSION || "";
4 changes: 3 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export default defineConfig(({ mode }) => ({
svgLoader(),
],
define: {
"import.meta.env.PACKAGE_VERSION": JSON.stringify(packageJson.version),
"process.env.NODE_ENV": JSON.stringify(mode),
"process.env.VITE_BUILD_TIME": JSON.stringify(new Date().toISOString()),
"process.env.VITE_VERSION": JSON.stringify(packageJson.version),
},
test: {
// used by vitest: https://vitest.dev/guide/#configuring-vitest
Expand Down
3 changes: 1 addition & 2 deletions vite.config.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default defineConfig({
],
define: {
"process.env.NODE_ENV": '"production"',
// Replace version placeholder during build
"import.meta.env.PACKAGE_VERSION": JSON.stringify(packageJson.version),
"process.env.VITE_VERSION": JSON.stringify(packageJson.version),
},
});

0 comments on commit 5f5e05b

Please sign in to comment.