Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-bompart committed Oct 22, 2024
1 parent 45bffbb commit 15b98af
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions utils/release/promote-npm-tag-to-latest.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {describeNpmTag, npmSetTag} from '@coveo/semantic-monorepo-tools';
import {readFileSync} from 'node:fs';
import {gt} from 'semver';
import {NPM_LATEST_TAG} from './common/constants.mjs';

if (!process.env.INIT_CWD) {
throw new Error('Should be called using npm run-script');
}
process.chdir(process.env.INIT_CWD);

const {name, version} = JSON.parse(
readFileSync('package.json', {encoding: 'utf-8'})
);

const publishedVersion = await describeNpmTag(name, NPM_LATEST_TAG);

if (gt(publishedVersion, version)) {
console.log(
`skipping tag update for ${name} because version "${version}" is not greater than latest version "${publishedVersion}".`
);
process.exit(1);
}

await npmSetTag(name, version, NPM_LATEST_TAG);

0 comments on commit 15b98af

Please sign in to comment.