Skip to content

Commit

Permalink
chore: specify version when invoking deployment pipeline (#4637)
Browse files Browse the repository at this point in the history
https://coveord.atlassian.net/browse/KIT-3692

This PR specifies _a version_ when invoking the deployment pipeline.
This is necessary since we deploy from two separate branches. The
pipeline needs a better way to differentiate those two. This version
will be the root pjson.version starting from 3.0.0 for v3 and 2.0.0 for
v2.

- [x] tested the script locally

---------

Co-authored-by: Louis Bompart <lbompart@coveo.com>
  • Loading branch information
alexprudhomme and louis-bompart authored Nov 6, 2024
1 parent 2eefb48 commit 700aed2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "ui-kit",
"private": true,
"version": "3.0.0",
"scripts": {
"postinstall": "husky install && patch-package && npx playwright install",
"reset:install": "git checkout origin/master package-lock.json && npm i",
Expand All @@ -21,7 +22,7 @@
"release": "npm run nx:graph && npm run release:phase0 && npm run release:phase1 && npm run release:phase2 && npm run release:phase3",
"nx:graph": "nx graph --file=topology.json",
"release:phase0": "npm run-script -w=@coveo/release git-lock",
"release:phase1": "nx run-many --targets=release:phase1 --all --parallel=false --output-style=stream",
"release:phase1": "nx run-many --targets=release:phase1 --all --parallel=false --output-style=stream; npm run-script -w=@coveo/release bump:root",
"release:phase2": "npm run-script -w=@coveo/release reify",
"release:phase3": "npm run-script -w=@coveo/release git-publish-all",
"release:phase4": "nx run-many --targets=release:phase4 --all"
Expand Down Expand Up @@ -140,6 +141,5 @@
"dependencies": {
"upgrade": "1.1.0"
},
"version": "0.0.0",
"packageManager": "npm@10.8.2"
}
14 changes: 8 additions & 6 deletions scripts/deploy/execute-deployment-pipeline.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {execSync} from 'node:child_process';
import {parse} from 'semver';
import atomicHostedPageJson from '../../packages/atomic-hosted-page/package.json' assert {type: 'json'};
import atomicReactJson from '../../packages/atomic-react/package.json' assert {type: 'json'};
import atomicJson from '../../packages/atomic/package.json' assert {type: 'json'};
import headlessJson from '../../packages/headless/package.json' assert {type: 'json'};
import buenoJson from '../../packages/bueno/package.json' assert {type: 'json'};
import atomicHostedPageJson from '../../packages/atomic-hosted-page/package.json' with {type: 'json'};
import atomicReactJson from '../../packages/atomic-react/package.json' with {type: 'json'};
import atomicJson from '../../packages/atomic/package.json' with {type: 'json'};
import headlessJson from '../../packages/headless/package.json' with {type: 'json'};
import buenoJson from '../../packages/bueno/package.json' with {type: 'json'};
import rootJson from '../../package.json' with {type: 'json'};

const releaseCommit = execSync('git rev-parse HEAD').toString().trim();

Expand All @@ -16,14 +17,15 @@ function getVersionComposants(version) {
patch: parsedVersion?.patch,
};
}

const root = getVersionComposants(rootJson.version);
const bueno = getVersionComposants(buenoJson.version);
const headless = getVersionComposants(headlessJson.version);
const atomic = getVersionComposants(atomicJson.version);
const atomicReact = getVersionComposants(atomicReactJson.version);
const atomicHostedPage = getVersionComposants(atomicHostedPageJson.version);
console.log(execSync(`
deployment-package package create --with-deploy \
--version ${root.major}.${root.minor}.${root.patch} \
--resolve BUENO_MAJOR_VERSION=${bueno.major} \
--resolve BUENO_MINOR_VERSION=${bueno.major}.${bueno.minor} \
--resolve BUENO_PATCH_VERSION=${bueno.major}.${bueno.minor}.${bueno.patch} \
Expand Down
29 changes: 29 additions & 0 deletions utils/release/bump-root.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node
import {
getCurrentVersion,
getNextVersion,
} from '@coveo/semantic-monorepo-tools';
import {readFileSync, writeFileSync} from 'node:fs';
import {resolve} from 'node:path';

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

(async () => {
const PATH = '.';

console.log('Bumping root package.json version');
const currentVersion = getCurrentVersion(PATH);
const nextVersion = getNextVersion(currentVersion, {type: 'patch'});

const packageJsonPath = resolve(PATH, 'package.json');
const packageJson = JSON.parse(
readFileSync(packageJsonPath, {encoding: 'utf-8'})
);
packageJson.version = nextVersion;

writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log(`Updated root package version to ${nextVersion}`);
})();
1 change: 1 addition & 0 deletions utils/release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"promote-npm-prod": "./promote-npm-tag-to-latest.mjs",
"git-lock": "./git-lock.mjs",
"bump": "./bump-package.mjs",
"bump:root": "./bump-root.mjs",
"npm-publish": "./npm-publish-package.mjs",
"git-publish-all": "./git-publish-all.mjs",
"reify": "./reify.mjs",
Expand Down

0 comments on commit 700aed2

Please sign in to comment.