Skip to content

Commit f82bd48

Browse files
aseureeunjae-leeEunjae Lee
authored
chore: migrate release process to Ship.js (#1210)
* chore: migrate release process to Ship.js This commit introduces a new release process by: - removing the need for the scripts/release.sh bash script in favor of https://github.com/algolia/shipjs. - automating the release in CircleCI Notable changes are: - `version` attribute added to the `package.json` file: this is a bit redundant with the `version` attribute available in the `lerna.json` but it is required by `conventional-changelog-cli`, which is used by Ship.js, to generate new Changelog entries, and can only identify versions based on the `package.json` file. - `CHANGELOG.md` text header has been removed because `conventional-changelog-ci` is not aware of headers in Changelog files. - `GITHUB_TOKEN` environment variable is now added to the CircleCI configuration. It grants CircleCI with the appropriate rights to run `shipjs trigger`, effectively publishing to NPM. The value is set to the Github account `algolia-api-client-bot` which can be retrieved from our Vault cluster, like other credentials. - `CONTRIBUTING.md` file updated to reflect the updated release process. * chore: update circleci to run shipjs trigger only on master branch * chore: remove .npmrc file * chore: remove unnecessary step in circleci * chore: remove empty filters Co-authored-by: eunjae-lee <[email protected]> Co-authored-by: Eunjae Lee <[email protected]>
1 parent 50b78a3 commit f82bd48

File tree

9 files changed

+922
-150
lines changed

9 files changed

+922
-150
lines changed

.circleci/config.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
aliases:
2-
- &removes_npmrc
3-
name: Removes npmrc
4-
command: |
5-
rm .npmrc
6-
72
- &install_yarn_version
83
name: Install specific Yarn version
94
command: |
@@ -45,7 +40,6 @@ jobs:
4540
<<: *defaults
4641
steps:
4742
- checkout
48-
- run: *removes_npmrc
4943
- run: *install_yarn_version
5044
- restore_cache: *restore_yarn_cache
5145
- run: *run_yarn_install
@@ -65,7 +59,6 @@ jobs:
6559
<<: *defaults
6660
steps:
6761
- checkout
68-
- run: *removes_npmrc
6962
- run: *install_yarn_version
7063
- restore_cache: *restore_yarn_cache
7164
- run: *run_yarn_install
@@ -79,7 +72,6 @@ jobs:
7972
<<: *defaults
8073
steps:
8174
- checkout
82-
- run: *removes_npmrc
8375
- run: *install_yarn_version
8476
- restore_cache: *restore_yarn_cache
8577
- run: *run_yarn_install
@@ -93,7 +85,6 @@ jobs:
9385
<<: *defaults
9486
steps:
9587
- checkout
96-
- run: *removes_npmrc
9788
- run: *install_yarn_version
9889
- restore_cache: *restore_yarn_cache
9990
- run: *run_yarn_install
@@ -107,7 +98,6 @@ jobs:
10798
<<: *defaults
10899
steps:
109100
- checkout
110-
- run: *removes_npmrc
111101
- run: *install_yarn_version
112102
- restore_cache: *restore_yarn_cache
113103
- run: *run_yarn_install
@@ -119,22 +109,42 @@ jobs:
119109
name: Browser tests
120110
command: yarn test:browser-ci
121111

112+
release:
113+
working_directory: ~/algoliasearch-client-javascript
114+
description: Perform a new release of the JavaScript client
115+
docker:
116+
- image: circleci/node:14
117+
steps:
118+
- checkout
119+
- run:
120+
command: yarn install
121+
- run:
122+
command: |
123+
if [[ -z "$GITHUB_TOKEN" ]]; then echo '$GITHUB_TOKEN is not set'; exit 1; fi
124+
yarn shipjs trigger
125+
122126
workflows:
123127
version: 2
124128
ci:
125129
jobs:
126130
- test_unit:
127131
version: '8'
132+
name: 'test_unit_8'
128133
- test_unit:
129134
version: '10'
135+
name: 'test_unit_10'
130136
- test_unit:
131137
version: '11'
138+
name: 'test_unit_11'
132139
- test_unit:
133140
version: '12'
141+
name: 'test_unit_12'
134142
- test_unit:
135143
version: '13'
144+
name: 'test_unit_13'
136145
- test_unit:
137146
version: '14'
147+
name: 'test_unit_14'
138148
- test_lint:
139149
version: '12'
140150
- test_types:
@@ -143,3 +153,19 @@ workflows:
143153
version: '12.16.2'
144154
- test_browser:
145155
version: '12.16.2'
156+
- release:
157+
requires:
158+
- test_unit_8
159+
- test_unit_10
160+
- test_unit_11
161+
- test_unit_12
162+
- test_unit_13
163+
- test_unit_14
164+
- test_lint
165+
- test_types
166+
- test_build
167+
- test_browser
168+
filters:
169+
branches:
170+
only:
171+
- master

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# Changelog
2-
All notable changes to this project will be documented in this file.
3-
4-
The format is based on [Keep a Changelog](http://keepachangelog.com/)
5-
and this project adheres to [Semantic Versioning](http://semver.org/).
6-
7-
# Release Notes
8-
91
## [v4.5.1](https://github.com/algolia/algoliasearch-client-javascript/compare/4.5.0...4.5.1)
102

113
### Fixed

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ TypeScript files are validated using a combination of [Prettier](https://github.
9090

9191
### Main version
9292

93-
To release a stable version, go on `master` (`git checkout master`) and use:
93+
To release a stable version, [generate a personal Github token](https://github.com/settings/tokens/new) with the `repo` scope from your logged-in Github account, go on the `master` branch (`git checkout master`) and use:
9494

9595
```sh
96-
npm run release
96+
export GITHUB_TOKEN=XXX # You can add this to your .env or .bashrc/.zshrc configuration file.
97+
yarn release
9798
```
9899

99-
If you're part of the Algolia team, you can read more details [here](https://github.com/algolia/doc-api-clients-squad/blob/master/release/javascript-v4.md)
100+
This will create a new Github PR proposing a PR to be made. Once merged, the CI will take care of publishing the new version on NPM registry.
101+
102+
If you're part of the Algolia team, you can read more details [here](https://algolia.atlassian.net/wiki/spaces/DX/pages/2034925622/JavaScript+v4+release+process).

conventional-changelog.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable functional/immutable-data */
2+
/* eslint-disable import/no-commonjs */
3+
/* eslint-disable max-len */
4+
5+
module.exports = {
6+
writerOpts: {
7+
headerPartial:
8+
'## [v{{version}}](https://github.com/algolia/algoliasearch-client-javascript/compare/{{previousTag}}...{{version}})\n',
9+
},
10+
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"private": true,
33
"license": "MIT",
4+
"version": "4.5.1",
45
"workspaces": [
56
"packages/*"
67
],
@@ -10,8 +11,7 @@
1011
"lint": "eslint . --ext .js,.ts --fix && node ./scripts/sort-package-json.js",
1112
"playground": "./scripts/prepare-playground.sh && yarn serve",
1213
"pre-commit": "yarn test:lint && yarn test:types",
13-
"release": "./scripts/release.sh",
14-
"release-publish": "lerna exec --concurrency 1 -- npm publish --verbose",
14+
"release": "shipjs prepare",
1515
"setup:browser": "yarn node scripts/setup-test-browser.js",
1616
"test:browser-ci": "yarn setup:browser && ./scripts/prepare-test-browser.sh && wdio ./wdio.saucelabs.conf.js",
1717
"test:browser-locally": "yarn setup:browser && ./scripts/prepare-test-browser.sh && wdio ./wdio.local.conf.js",
@@ -82,6 +82,7 @@
8282
"rollup-plugin-terser": "5.2.0",
8383
"rollup-plugin-typescript2": "0.26.0",
8484
"serve": "11.3.0",
85+
"shipjs": "0.22.0",
8586
"sort-package-json": "1.40.0",
8687
"ts-jest": "25.2.1",
8788
"ts-mockito": "2.5.0",

scripts/release.sh

Lines changed: 0 additions & 116 deletions
This file was deleted.

ship.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-disable functional/immutable-data */
2+
/* eslint-disable import/no-commonjs */
3+
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
module.exports = {
8+
monorepo: {
9+
mainVersionFile: 'package.json',
10+
packagesToBump: ['packages/*'],
11+
packagesToPublish: ['packages/*'],
12+
},
13+
getTagName: ({ version }) => `${version}`,
14+
conventionalChangelogArgs:
15+
'--config conventional-changelog.config.js --infile CHANGELOG.md --same-file',
16+
versionUpdated({ version, dir }) {
17+
// Update version in `lerna.json` file.
18+
const lernaConfigPath = path.resolve(dir, 'lerna.json');
19+
const lernaConfig = JSON.parse(fs.readFileSync(lernaConfigPath).toString());
20+
lernaConfig.version = version;
21+
fs.writeFileSync(lernaConfigPath, JSON.stringify(lernaConfig, null, 2));
22+
23+
// Update version in `packages/client-common/src/version.ts` file since
24+
// `shipjs prepare` does not seem to support Typescript version files
25+
// bumping (yet?).
26+
const clientCommonTypescriptPath = 'packages/client-common/src/version.ts';
27+
const clientCommonTypescript = path.resolve(dir, clientCommonTypescriptPath);
28+
fs.writeFileSync(clientCommonTypescript, `export const version = '${version}';\n`);
29+
},
30+
};

0 commit comments

Comments
 (0)