/ utils / bump.js
bump.js
 1  /**
 2   * @file bumps version and creates git commit and tag
 3   *
 4   * Usage:
 5   *
 6   * pnpm bump
 7   */
 8  
 9  import { execa } from 'execa';
10  import { runGitCliff } from 'git-cliff';
11  
12  import pkg from '../package.json' with { type: 'json' };
13  
14  const newVersionTag = (
15  	await runGitCliff({ bumpedVersion: true }, { stdio: ['ignore', 'pipe', 'inherit'] })
16  ).stdout;
17  const newVersion = newVersionTag.slice(1); // remove `v` prefix
18  
19  if (pkg.version === newVersion) {
20  	console.info(`version ${pkg.version} is already actual`);
21  } else {
22  	console.info(`bumping from ${pkg.version} to ${newVersion}`);
23  
24  	const msg = `chore(release): ${newVersionTag}`;
25  
26  	await execa({
27  		stdout: 'inherit',
28  		stderr: 'inherit',
29  	})`pnpm version --sign-git-tag -m ${msg} ${newVersion}`;
30  }