File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 - name : Prepare release
4444 run : npm version --no-git-tag-version --allow-same-version ${{env.RELEASE_VERSION}}
4545
46- - name : Update version file
47- run : |
48- echo "export const version = '${{env.RELEASE_VERSION}}'" > src/version.js
49- git add src/version.js
50-
5146 - name : Convert repository name to lower case
5247 run : echo "GITHUB_REPOSITORY_LOWER_CASE=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
5348
Original file line number Diff line number Diff line change 2525 "prepare" : " tsc && vite build" ,
2626 "prepack" : " tsc && vite build" ,
2727 "test" : " NODE_OPTIONS=\" $NODE_OPTIONS --experimental-vm-modules\" npx jest" ,
28+ "version" : " node scripts/version.js" ,
2829 "lint" : " standard" ,
2930 "lint-fix" : " standard --fix"
3031 },
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ /**
4+ * This script reads the version from package.json and writes it to src/version.js.
5+ * It also stages the changes to src/version.js in git.
6+ *
7+ * Should be used as an [`npm version` script](https://docs.npmjs.com/cli/v8/using-npm/scripts#npm-version)!
8+ */
9+ import { execFile } from 'node:child_process'
10+ import { readFile , writeFile } from 'node:fs/promises'
11+ import { promisify } from 'node:util'
12+
13+ async function main ( ) {
14+ const packageJson = JSON . parse ( await readFile ( 'package.json' , 'utf8' ) )
15+ const version = packageJson . version
16+
17+ await writeFile ( 'src/version.js' , `export const version = '${ version } '\n` )
18+ await promisify ( execFile ) ( 'git' , [ 'add' , 'src/version.js' ] )
19+ }
20+
21+ main ( ) . catch ( ( error ) => {
22+ console . error ( error )
23+ process . exit ( 1 )
24+ } )
You can’t perform that action at this time.
0 commit comments