Skip to content

Commit 4e14ad1

Browse files
committed
chore: add postversion script to ensure correct tag prefix
1 parent f04c017 commit 4e14ad1

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"typecheck": "tsc --noEmit",
3030
"test": "vitest run",
3131
"bump": "node scripts/bump-version.cjs",
32-
"version": "node scripts/bump-version.cjs"
32+
"version": "node scripts/bump-version.cjs",
33+
"postversion": "node scripts/postversion.cjs"
3334
},
3435
"dependencies": {
3536
"@radix-ui/react-dropdown-menu": "^2.1.16",

scripts/postversion.cjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { execSync } = require('child_process');
2+
const path = require('path');
3+
const pkg = require(path.join(__dirname, '../package.json'));
4+
const version = pkg.version;
5+
6+
const wrongTag = `v${version}`;
7+
const correctTag = `app-v${version}`;
8+
9+
try {
10+
// Check if wrong tag exists
11+
const tags = execSync(`git tag -l ${wrongTag}`).toString().trim();
12+
if (tags === wrongTag) {
13+
console.log(`Found incorrect tag ${wrongTag}, fixing it to ${correctTag}...`);
14+
// Delete wrong tag
15+
execSync(`git tag -d ${wrongTag}`);
16+
// Create correct tag
17+
execSync(`git tag -a ${correctTag} -m "${correctTag}"`);
18+
console.log(`Successfully replaced ${wrongTag} with ${correctTag}`);
19+
} else {
20+
// Check if correct tag exists
21+
const correctTags = execSync(`git tag -l ${correctTag}`).toString().trim();
22+
if (correctTags !== correctTag) {
23+
execSync(`git tag -a ${correctTag} -m "${correctTag}"`);
24+
console.log(`Created missing tag ${correctTag}`);
25+
} else {
26+
console.log(`Tag ${correctTag} already exists and is correct.`);
27+
}
28+
}
29+
} catch (e) {
30+
console.error('Error in postversion script:', e.message);
31+
}

0 commit comments

Comments
 (0)