Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add prerelease process #2561

Merged
merged 10 commits into from
Nov 28, 2022
3 changes: 2 additions & 1 deletion .deployment.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@
"no_endpoint": true
},
"package_rollout": {
"only_consider_changesets_after": "b244fe702d8e96d016a52715e92c8131acfde3ba"
"only_consider_changesets_after": "b244fe702d8e96d016a52715e92c8131acfde3ba",
"disabled": $[STOP_AT_DEV]
},
"deployment_config_version": 7
}
1 change: 1 addition & 0 deletions .github/workflows/masterbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
- 'prerelease/**'
jobs:
build:
name: 'Build'
Expand Down
32 changes: 21 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
def parseSemanticVersion(String version) {
def semanticVersionRegex = /^(((([0-9]+)\.[0-9]+)\.[0-9]+)(?:\-.+)?)$/
def (_, prerelease, patch, minor, major) = (version =~ semanticVersionRegex)[0]
return [major, minor, patch, prerelease]
}

node('heavy && linux && docker') {
checkout scm
def tag = sh(script: "git tag --contains", returnStdout: true).trim()
def isBump = !!tag
def isMaster = env.BRANCH_NAME == 'master'
def isOnReleaseBranch = env.BRANCH_NAME == 'master'
def isOnPrereleaseBranch = env.BRANCH_NAME.startsWith('prerelease/')

if (!isMaster) {
if (!isOnReleaseBranch && !isOnPrereleaseBranch) {
return
}

Expand Down Expand Up @@ -37,7 +44,11 @@ node('heavy && linux && docker') {
withCredentials([
string(credentialsId: 'NPM_TOKEN', variable: 'NPM_TOKEN')]) {
sh "echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > ~/.npmrc"
sh 'npm run npm:publish:alpha || true'
if (isOnReleaseBranch) {
sh 'npm run npm:publish:alpha || true'
} else {
sh 'npm run npm:publish || true'
}
}
}
}
Expand All @@ -48,23 +59,22 @@ node('heavy && linux && docker') {
headless = readJSON file: 'packages/headless/package.json'
atomic = readJSON file: 'packages/atomic/package.json'
atomicReact = readJSON file: 'packages/atomic-react/package.json'
semanticVersionRegex = /^([^\.]*)\.[^\.]*/

(headlessMinor, headlessMajor) = (headless.version =~ semanticVersionRegex)[0]
(atomicMinor, atomicMajor) = (atomic.version =~ semanticVersionRegex)[0]
(atomicReactMinor, atomicReactMajor) = (atomicReact.version =~ semanticVersionRegex)[0]

(headlessMajor, headlessMinor, headlessPatch) = parseSemanticVersion(headless.version)
(atomicMajor, atomicMinor, atomicPatch) = parseSemanticVersion(atomic.version)
(atomicReactMajor, atomicReactMinor, atomicReactPatch) = parseSemanticVersion(atomicReact.version)

sh "deployment-package package create --with-deploy \
--resolve HEADLESS_MAJOR_VERSION=${headlessMajor} \
--resolve HEADLESS_MINOR_VERSION=${headlessMinor} \
--resolve HEADLESS_PATCH_VERSION=${headless.version} \
--resolve HEADLESS_PATCH_VERSION=${headlessPatch} \
--resolve ATOMIC_MAJOR_VERSION=${atomicMajor} \
--resolve ATOMIC_MINOR_VERSION=${atomicMinor} \
--resolve ATOMIC_PATCH_VERSION=${atomic.version} \
--resolve ATOMIC_PATCH_VERSION=${atomicPatch} \
--resolve ATOMIC_REACT_MAJOR_VERSION=${atomicReactMajor} \
--resolve ATOMIC_REACT_MINOR_VERSION=${atomicReactMinor} \
--resolve ATOMIC_REACT_PATCH_VERSION=${atomicReact.version} \
--resolve ATOMIC_REACT_PATCH_VERSION=${atomicReactPatch} \
--resolve STOP_AT_DEV=${!isOnReleaseBranch} \
|| true"
}
}
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,29 @@ The following Visual Studio Code extensions are recommended:

- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

## Prerelease
### To start a major prerelease (e.g., `1.2.3` → `2.0.0-pre.0`)
1. Make sure that `HEAD` refers to a version bump on `master`.
2. Create a new branch prefixed with `prerelease/` (e.g., `prerelease/headless_atomic_v2`).
3. Run `npm run bump:version:major-prerelease -- @coveo/package1 @coveo/package2 @coveo/package3`.
4. Push the new commit and its tags to the branch.

### Adding a new package to an already started prerelease
1. Checkout the prerelease branch.
2. Run `npm run bump:version:major-prerelease -- @coveo/package1` where `@coveo/package1` is the new package.
3. Push the new commit and its tags to the branch.

### Updating a prerelease branch
1. Wait for `master` to reference a version bump.
2. Pull changes from `master` into the prerelease branch.

### Officially releasing (e.g., `2.0.0-pre.15` → `2.0.0`)
1. Create a pull request from the prerelease branch to “master”.
* Associate with a Jira issue which QA will use to validate.
* Update the changelogs manually, adding all the changes from the last release to the new release.
* Update all dependents to use the prerelease version (include the `-pre.` suffix).
2. Wait for `master` to reference a version bump.
3. Squash as a version bump.
* You can copy the title & description of the last version bump commit on the prerelease branch.
* You must add the link to the Jira issue at the beginning of the description.
117 changes: 110 additions & 7 deletions package-lock.json

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

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"commit": "git-cz",
"setup:snyk": "node ./scripts/snyk/remove-samples-workspace.mjs",
"bump:version": "node ./scripts/deploy/bump-version.mjs",
"bump:version:major-prerelease": "node ./scripts/deploy/manual-major-prerelease.mjs",
"npm:publish": "lerna run --stream npm:publish",
"npm:publish:alpha": "lerna run --stream npm:publish:alpha",
"npm:tag": "node ./scripts/deploy/update-npm-tag.mjs",
"npm:tag:beta": "npm run npm:tag -- beta",
Expand Down Expand Up @@ -58,7 +60,9 @@
"rimraf": "3.0.2",
"semver": "7.3.7",
"ts-jest": "27.1.5",
"typescript": "4.6.4"
"typescript": "4.6.4",
"@coveo/semantic-monorepo-tools": "1.5.5",
"detect-indent": "7.0.1"
},
"workspaces": [
"packages/bueno",
Expand Down
2 changes: 2 additions & 0 deletions packages/atomic-angular/modify-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const packageJSON = JSON.parse(readFileSync(packageJSONPath));
if (!packageJSON.scripts) {
packageJSON.scripts = {};
}
packageJSON.scripts['npm:publish'] =
'node ../../../../../scripts/deploy/publish.mjs';
packageJSON.scripts['npm:publish:alpha'] =
'node ../../../../../scripts/deploy/publish.mjs alpha';

Expand Down
1 change: 1 addition & 0 deletions packages/atomic-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"start": "ng serve",
"build": "ng build && npm run copy:assets && npm run npm:modify:dist",
"copy:assets": "ncp ../atomic/dist/atomic/assets projects/atomic-angular/dist/assets && ncp ../atomic/dist/atomic/lang projects/atomic-angular/dist/lang",
"npm:publish": "npm --prefix projects/atomic-angular/dist run npm:publish",
"npm:publish:alpha": "npm --prefix projects/atomic-angular/dist run npm:publish:alpha",
"npm:modify:dist": "node modify-package-json.js"
},
Expand Down
1 change: 1 addition & 0 deletions packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"compile:cjs": "tsc -p tsconfig.cjs.json",
"compile:iife": "rollup --config rollup.config.js",
"compile": "concurrently \"npm run compile:esm\" \"npm run compile:cjs\" \"npm run compile:iife\"",
"npm:publish": "node ../../scripts/deploy/publish.mjs",
"npm:publish:alpha": "node ../../scripts/deploy/publish.mjs alpha",
"copy:assets": "ncp ../atomic/dist/atomic/assets dist/assets && ncp ../atomic/dist/atomic/lang dist/lang "
},
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/scripts/copy-dayjs-locales.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import fs from 'node:fs';
import {promisify} from 'util';

const readFile = promisify(fs.readFile);
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/scripts/copy-headless.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import _ncp from 'ncp';
import fs from 'node:fs';
import {promisify} from 'util';

const ncp = promisify(_ncp);
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/scripts/create-generated-folder.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import fs from 'node:fs';
import {promisify} from 'util';

const rm = promisify(fs.rm);
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/scripts/list-assets.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {readdirSync, writeFileSync} from 'fs';
import {readdirSync, writeFileSync} from 'node:fs';

const files = readdirSync('dist/atomic/assets');
writeFileSync('docs/assets.json', JSON.stringify({assets: files}));
2 changes: 1 addition & 1 deletion packages/atomic/scripts/split-locales.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import fs from 'node:fs';
import {promisify} from 'util';

const mkdir = promisify(fs.mkdir);
Expand Down
1 change: 1 addition & 0 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"test:watch": "jest --watch --colors --no-cache --silent=false",
"typedefinitions": "tsc -p src/tsconfig.build.json -d --emitDeclarationOnly --declarationDir dist/definitions",
"clean": "rimraf -rf dist/*",
"npm:publish": "node ../../scripts/deploy/publish.mjs",
"npm:publish:alpha": "node ../../scripts/deploy/publish.mjs alpha",
"e2e:saml": "vite manual-e2e/saml/"
},
Expand Down
Loading