From 527ceb1c432b8c34246b83494cadff618118cdd0 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 22 Aug 2020 16:20:08 +0800 Subject: [PATCH] chore: expose package version (#479) * chore: expose package version * chore: version bumping timing and github release * chore: fix jest global --- .github/workflows/release.yml | 19 +++++++++++++++++++ package.json | 5 +++-- rollup.config.js | 2 ++ src/global.d.ts | 3 ++- src/index.ts | 2 ++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..cd0fe26f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,19 @@ +name: Github Release + +on: + push: + tags: + - v* + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - name: Create Release + run: npx conventional-github-releaser -p angular + env: + CI: true + CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/package.json b/package.json index 3b5d3f67..e918e4c7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "update-readme": "node ./scripts/update-readme.js", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "version": "yarn changelog && yarn update-readme && git add CHANGELOG.md README.*", - "release": "yarn test && yarn publish && git push && yarn release-gh", + "release": "yarn version && yarn test && yarn publish --non-interactive && git push --follow-tags", "release-gh": "conventional-github-releaser -p angular" }, "bugs": { @@ -91,7 +91,8 @@ "jest": { "verbose": true, "globals": { - "__DEV__": true + "__DEV__": true, + "__VERSION__": "0.0.0" }, "setupFiles": [ "/test/setupTest.js" diff --git a/rollup.config.js b/rollup.config.js index eb8486d6..755fe45a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,6 +4,7 @@ import resolve from '@rollup/plugin-node-resolve' import { terser } from 'rollup-plugin-terser' import replace from '@rollup/plugin-replace' import dts from 'rollup-plugin-dts' +import { version } from './package.json' const builds = { 'cjs-dev': { @@ -81,6 +82,7 @@ function genConfig({ outFile, format, mode }) { `(process.env.NODE_ENV !== 'production')` : // hard coded dev/prod builds !isProd, + __VERSION__: JSON.stringify(version), }), isProd && terser(), ].filter(Boolean), diff --git a/src/global.d.ts b/src/global.d.ts index ca93dc0d..9bc2c044 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -1,2 +1,3 @@ // Global compile-time constants -declare var __DEV__: boolean +declare const __DEV__: boolean +declare const __VERSION__: string diff --git a/src/index.ts b/src/index.ts index 61166594..87885b73 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,8 @@ import type Vue from 'vue' import { Data, SetupFunction } from './component' import { Plugin } from './install' +export const version = __VERSION__ + export * from './apis' export { getCurrentInstance } from './runtimeContext' export {