Skip to content

Commit

Permalink
chore: promote the v3 branch when publishing on v3 (#4585)
Browse files Browse the repository at this point in the history
Sames as #4584 for v3

Technically, we could "just fix" the script.
However, I think it's best to make it "fit" with the rest of our release
scripts in its code architecture while keeping the same functionality

https://coveord.atlassian.net/browse/KIT-3668
  • Loading branch information
louis-bompart authored Oct 23, 2024
1 parent 1dbd9a9 commit 7b9144d
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 73 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"outputs": [],
"executor": "nx:run-commands",
"options": {
"command": "node ../../../../scripts/deploy/update-npm-tag.mjs latest",
"command": "npm run-script -w=@coveo/release promote-npm-prod",
"cwd": "packages/atomic-angular/projects/atomic-angular"
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-hosted-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"validate:definitions": "tsc --noEmit --esModuleInterop --skipLibCheck ./dist/types/components.d.ts",
"publish:npm": "npm run-script -w=@coveo/release npm-publish",
"publish:bump": "npm run-script -w=@coveo/release bump",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest"
"promote:npm:latest": "npm run-script -w=@coveo/release promote-npm-prod"
},
"dependencies": {
"@coveo/bueno": "1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build:bundles": "concurrently \"npm run build:bundles:esm\" \"npm run build:bundles:iife-cjs\"",
"publish:npm": "npm run-script -w=@coveo/release npm-publish",
"publish:bump": "npm run-script -w=@coveo/release bump",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"promote:npm:latest": "npm run-script -w=@coveo/release promote-npm-prod",
"build:assets": "ncp ../atomic/dist/atomic/assets dist/assets && ncp ../atomic/dist/atomic/lang dist/lang "
},
"main": "./dist/cjs/atomic-react.cjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"e2e:insight:watch": "cypress open --config-file cypress-insight-panel.config.mjs --browser chrome",
"publish:npm": "npm run-script -w=@coveo/release npm-publish",
"publish:bump": "npm run-script -w=@coveo/release bump",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"promote:npm:latest": "npm run-script -w=@coveo/release promote-npm-prod",
"validate:definitions": "tsc --noEmit --esModuleInterop --skipLibCheck ./dist/types/components.d.ts"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/bueno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"test:watch": "jest --watch --colors --no-cache",
"publish:npm": "npm run-script -w=@coveo/release npm-publish",
"publish:bump": "npm run-script -w=@coveo/release bump",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest"
"promote:npm:latest": "npm run-script -w=@coveo/release promote-npm-prod"
},
"devDependencies": {
"@coveo/release": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/headless-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"lint": "eslint .; publint",
"publish:npm": "npm run-script -w=@coveo/release npm-publish",
"publish:bump": "npm run-script -w=@coveo/release bump",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest"
"promote:npm:latest": "npm run-script -w=@coveo/release promote-npm-prod"
},
"dependencies": {
"@coveo/headless": "3.4.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"integration-test:watch": "vitest --poolOptions.threads.singleThread src/integration-tests/**",
"publish:npm": "npm run-script -w=@coveo/release npm-publish",
"publish:bump": "npm run-script -w=@coveo/release bump",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"promote:npm:latest": "npm run-script -w=@coveo/release promote-npm-prod",
"build:doc": "npm run build:doc:extract && npm run build:doc:parse",
"build:doc:extract": "node ./scripts/extract-documentation.mjs",
"build:doc:parse": "ts-node --project ./doc-parser/tsconfig.build.json ./doc-parser/doc-parser.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/quantic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"promote:sfdx:ci": "npm run publish:sfdx -- --promote --ci",
"publish:npm": "npm run-script -w=@coveo/release npm-publish",
"publish:bump": "npm run-script -w=@coveo/release bump",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"promote:npm:latest": "npm run-script -w=@coveo/release promote-npm-prod",
"preinstall": "node scripts/npm/check-sfdx-project.js",
"postinstall": "node scripts/npm/setup-quantic.js"
},
Expand Down
49 changes: 0 additions & 49 deletions scripts/deploy/update-npm-tag.mjs

This file was deleted.

4 changes: 4 additions & 0 deletions utils/release/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ export const RELEASER_AUTH_SECRETS = {
clientSecret: process.env.RELEASER_CLIENT_SECRET,
installationId: process.env.RELEASER_INSTALLATION_ID,
};

export const NPM_LATEST_TAG = 'latest';
export const NPM_BETA_TAG = 'beta';
export const NPM_ALPHA_TAG = 'alpha';
3 changes: 2 additions & 1 deletion utils/release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "1.0.0",
"type": "module",
"dependencies": {
"@coveo/semantic-monorepo-tools": "2.4.61",
"@coveo/semantic-monorepo-tools": "2.5.0",
"@npmcli/arborist": "7.5.4",
"@octokit/auth-app": "6.1.1",
"async-retry": "1.3.3",
Expand All @@ -22,6 +22,7 @@
"typescript": "5.4.5"
},
"scripts": {
"promote-npm-prod": "./promote-npm-tag-to-latest.mjs",
"git-lock": "./git-lock.mjs",
"bump": "./bump-package.mjs",
"npm-publish": "./npm-publish-package.mjs",
Expand Down
25 changes: 25 additions & 0 deletions utils/release/promote-npm-tag-to-latest.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env node
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 7b9144d

Please sign in to comment.