File size: 1,181 Bytes
e65cda1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
/**
 * Bump, stage, and commit a release in one command:
 * `pnpm release:commit <major|minor|patch|x.y.z>`. The namespaced tag stays
 * manual — create it from the merged release commit.
 */

import path from 'node:path';
import { spawnSync } from 'node:child_process';
import { packageDirs, readJson, root } from './repo.mjs';

const bump = process.argv[2];

function run(command, args) {
  const result = spawnSync(command, args, {
    cwd: root,
    stdio: 'inherit',
    env: { ...process.env, CI: 'true' },
  });
  if (result.error) throw result.error;
  if (result.status !== 0) {
    process.exit(result.status ?? 1);
  }
}

if (!bump) {
  console.error('Usage: pnpm release:commit <major|minor|patch|x.y.z>');
  process.exit(1);
}

run('node', ['./scripts/bump-release.mjs', bump]);

const version = readJson(path.join(root, packageDirs()[0], 'package.json')).version;
run('git', [
  'add',
  'package.json',
  'packages/*/package.json',
  '../../pnpm-lock.yaml',
]);
run('git', ['commit', '-m', `release(node-addon-system): ${version}`]);

console.log(`Committed release ${version}. Create the tag manually: git tag node-addon-system-v${version}`);