Skip to content

Commit

Permalink
chore(scripts): Add postversion-commit.js
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Oct 2, 2024
1 parent 033ba6e commit 31a49ec
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/postversion-commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {execSync} from 'node:child_process';
import assert from 'node:assert/strict';

/**
* Utility for committing and tagging a release commit in
* git, called as part of the `yarn postversion` script.
*/

const version = process.env.VERSION;

assert.match(
version,
/^v\d+\.\d+\.\d+[a-zA-Z0-9\._-]*$/,
'Missing or invalid process.env.VERSION'
);

const currentBranch = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim();

if (currentBranch === 'main') {
execSync(`git checkout -b 'release/${version}'`);
}

execSync('git add -u');
execSync(`git commit -m 'chore(release): ${version}'`);
execSync(`git tag -a ${version} -m ${version}`);

0 comments on commit 31a49ec

Please sign in to comment.