-
Notifications
You must be signed in to change notification settings - Fork 61
/
publish.js
24 lines (16 loc) · 1.02 KB
/
publish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { execSync } from 'node:child_process';
import fs from 'node:fs';
const packageJson = fs.readFileSync('package.json', 'utf8');
const packageVersion = JSON.parse(packageJson).version;
const majorminor = packageVersion.split('.').slice(0, 2).join('.');
const patch = parseInt(packageVersion.split('.')[2].split(/[^0-9\-]/)[0]) + 1;
// const rev = fs.readFileSync('.git/refs/heads/main', 'utf8').trim().slice(0, 9);
// const version = `${majorminor}.${patch}+${rev}`;
const version = `${majorminor}.${patch}`;
fs.writeFileSync('package.json', packageJson.replace(`"${packageVersion}"`, `"${version}"`));
fs.writeFileSync('runner/index.js', fs.readFileSync('runner/index.js', 'utf8')
.replace(/globalThis\.version = '.*?';/, `globalThis.version = '${version}';`));
execSync(`git add package.json runner/index.js`, { stdio: 'inherit' });
// execSync(`git commit -m "version: ${version}"`, { stdio: 'inherit' });
execSync(`git commit --amend -C HEAD --no-verify`, { stdio: 'inherit' });
execSync(`npm publish`, { stdio: 'inherit' });