Skip to content

Commit d194cbe

Browse files
author
Sravan S
authored
feat: improve release steps (#458)
* Update readme * Auto add version number to dist/index.d.ts * Generate package.json in dist automatically * Cleanup PR template fixes: https://sendbird.atlassian.net/browse/UIKIT-3471
1 parent 361db19 commit d194cbe

File tree

6 files changed

+80
-117
lines changed

6 files changed

+80
-117
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,9 @@ and we'll evaluate if we can setup a [CLA](https://en.wikipedia.org/wiki/Contrib
99

1010
## For Internal Contributors
1111

12-
[<TICKET_ID>](https://sendbird.atlassian.net/browse/<TICKET_ID>)
13-
14-
## Description Of Changes
12+
### Description Of Changes
1513

1614
Add a brief description of the changes that you have involved in this PR
15+
Follow conventional commit format: https://www.conventionalcommits.org/en/v1.0.0/
1716

18-
## Types Of Changes
19-
20-
What types of changes does your code introduce to this project?
21-
Put an `x` in the boxes that apply_
22-
23-
- [ ] Bugfix
24-
- [ ] New feature
25-
- [ ] Documentation (correction or otherwise)
26-
- [ ] Cosmetics (whitespace, appearance (ex) Prettier)
27-
- [ ] Build configuration
28-
- [ ] Improvement (refactor code)
17+
[<TICKET_ID>](https://sendbird.atlassian.net/browse/<TICKET_ID>)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
"scripts": {
1919
"test": "jest",
2020
"test-update-snapshot": "jest -u",
21+
"afterbuild": "node ./scripts/post_build.js;",
2122
"cp-css": "./scripts/copy-css.sh",
2223
"clean-release": "rm -rf ./release; rm -rf ./dist",
23-
"build": "npm run clean-release; rollup -c",
24+
"build": "npm run clean-release; rollup -c; npm run afterbuild",
2425
"start": "rollup -c -w",
2526
"reset": "rm -rf ./node_modules; npm install",
2627
"prepublishOnly": "npm run build",

rollup.config.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ module.exports = ({
106106
dest: 'dist',
107107
rename: 'index.d.ts',
108108
},
109-
{
110-
src: './package-lock.json',
111-
dest: 'dist',
112-
},
113109
{
114110
src: './README.md',
115111
dest: 'dist',
@@ -122,15 +118,6 @@ module.exports = ({
122118
src: './CHANGELOG.md',
123119
dest: 'dist',
124120
},
125-
{
126-
src: './.size-snapshot.json',
127-
dest: 'dist',
128-
},
129-
{
130-
src: './scripts/package.template.json',
131-
dest: 'dist',
132-
rename: 'package.json',
133-
},
134121
],
135122
}),
136123
visualizer({

scripts/package.template.json

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,22 @@
11
{
22
"name": "@sendbird/uikit-react",
3-
"version": "{{ version }}",
43
"description": "React based UI kit for sendbird",
54
"type": "module",
65
"main": "index.js",
76
"style": "dist/index.css",
87
"typings": "index.d.ts",
98
"module": "index.js",
10-
"devEngines": {
11-
"node": "14.x || 15.x || 16.x"
12-
},
139
"files": [
1410
"**/*"
1511
],
16-
"scripts": {
17-
},
1812
"repository": {
1913
"type": "git",
2014
"url": "[email protected]:sendbird/sendbird-uikit-react-sources.git"
2115
},
2216
"author": "SendBird <[email protected]>",
2317
"license": "SEE LICENSE IN LICENSE.md",
24-
"peerDependencies": {
25-
"react": "^16.8.6 || ^17.0.0 || ^18.0.0",
26-
"react-dom": "^16.8.6 || ^17.0.0 || ^18.0.0"
27-
},
28-
"dependencies": {
29-
"@sendbird/chat": "^4.1.1",
30-
"css-vars-ponyfill": "^2.3.2",
31-
"date-fns": "^2.16.1",
32-
"prop-types": "^15.7.2",
33-
"dompurify": "^3.0.1"
34-
},
3518
"bugs": {
3619
"url": "https://community.sendbird.com"
3720
},
38-
"homepage": "https://sendbird.com",
39-
"devDependencies": {
40-
"@babel/core": "^7.8.4",
41-
"@babel/plugin-proposal-class-properties": "^7.8.3",
42-
"@babel/plugin-proposal-export-default-from": "^7.8.3",
43-
"@babel/preset-env": "^7.8.3",
44-
"@babel/preset-react": "^7.8.3",
45-
"@babel/preset-typescript": "^7.10.4",
46-
"@rollup/plugin-babel": "^5.3.0",
47-
"@rollup/plugin-commonjs": "^19.0.0",
48-
"@rollup/plugin-eslint": "^8.0.1",
49-
"@rollup/plugin-node-resolve": "^7.1.3",
50-
"@rollup/plugin-replace": "^2.4.2",
51-
"@rollup/plugin-typescript": "^8.2.1",
52-
"@storybook/addon-actions": "^6.3.4",
53-
"@storybook/addon-docs": "^6.3.4",
54-
"@storybook/addon-links": "^6.3.4",
55-
"@storybook/addons": "^6.3.4",
56-
"@storybook/preset-scss": "^1.0.3",
57-
"@storybook/react": "^6.3.4",
58-
"@storybook/storybook-deployer": "^2.8.10",
59-
"@svgr/rollup": "^5.5.0",
60-
"@svgr/webpack": "^5.1.0",
61-
"@typescript-eslint/eslint-plugin": "^3.6.0",
62-
"@typescript-eslint/parser": "^3.6.0",
63-
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.2",
64-
"autoprefixer": "^9.7.4",
65-
"babel-eslint": "^10.0.3",
66-
"babel-jest": "^25.1.0",
67-
"babel-loader": "^8.0.6",
68-
"browserslist": "^4.14.5",
69-
"caniuse-lite": "^1.0.30001148",
70-
"css-loader": "^3.4.2",
71-
"dts-bundle-generator": "^6.5.0",
72-
"enzyme": "^3.11.0",
73-
"eslint": "^6.8.0",
74-
"eslint-config-airbnb": "^18.0.1",
75-
"eslint-plugin-import": "^2.20.0",
76-
"eslint-plugin-jsx-a11y": "^6.2.3",
77-
"eslint-plugin-react": "^7.18.0",
78-
"eslint-plugin-react-hooks": "^1.7.0",
79-
"jest": "^27.0.6",
80-
"jsdom": "^16.1.0",
81-
"node-sass": "^6.0.1",
82-
"np": "^7.5.0",
83-
"plop": "^2.5.3",
84-
"postcss": "^8.3.5",
85-
"react": "^17.0.2",
86-
"react-dom": "^17.0.2",
87-
"react-test-renderer": "^17.0.2",
88-
"rollup": "^2.53.1",
89-
"rollup-plugin-copy": "^3.4.0",
90-
"rollup-plugin-postcss": "^4.0.0",
91-
"rollup-plugin-scss": "^3.0.0",
92-
"rollup-plugin-size-snapshot": "^0.12.0",
93-
"sass-loader": "^10.2.0",
94-
"style-loader": "^1.1.3",
95-
"stylelint": "^13.0.0",
96-
"stylelint-config-sass-guidelines": "^7.0.0",
97-
"ts-loader": "^7.0.5",
98-
"tslib": "^2.0.0",
99-
"typescript": "^4.3.5"
100-
},
101-
"browserslist": [
102-
"defaults",
103-
"IE 11"
104-
]
21+
"homepage": "https://sendbird.com"
10522
}

scripts/post_build.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Node script to append the version number to index.d.ts & package.json
3+
*/
4+
const fs = require('fs');
5+
const path = require('path');
6+
const packageJson = require('../package.json');
7+
const packageTemplate = require('./package.template.json');
8+
9+
const { version } = packageJson;
10+
const distPath = path.resolve(__dirname, '../dist');
11+
12+
function appendVersionToTypeDefn() {
13+
const indexDtsPath = path.resolve(distPath, 'index.d.ts');
14+
const indexDts = fs.readFileSync(indexDtsPath, 'utf8');
15+
const indexDtsWithVersion = indexDts.replace(
16+
'Type Definitions for @sendbird/uikit-react@{{ version }}',
17+
`Type Definitions for @sendbird/uikit-react@${version}`,
18+
);
19+
20+
fs.writeFileSync(indexDtsPath, indexDtsWithVersion);
21+
}
22+
23+
/**
24+
* Remove all the unnecessary fields from package.json in root of the project
25+
*/
26+
function cleanupPackageJSON(json) {
27+
/**
28+
* We remove scripts, module, main, types, and private fields from package.json
29+
* Becuase folder structure is different in dist
30+
* And, we don't want to run obligatory scripts in dist
31+
*/
32+
const cleanedPkgJSON = {
33+
version: json.version,
34+
...packageTemplate,
35+
peerDependencies: json.peerDependencies,
36+
dependencies: json.dependencies,
37+
devDependencies: json.devDependencies,
38+
browserslist: json.browserslist,
39+
};
40+
return cleanedPkgJSON;
41+
}
42+
43+
function movePackageJSON() {
44+
const packageJSONDistPath = path.resolve(distPath, 'package.json');
45+
const cleanedUpPackageJSON = cleanupPackageJSON(packageJson);
46+
fs.writeFileSync(
47+
packageJSONDistPath,
48+
JSON.stringify(cleanedUpPackageJSON, null, 2),
49+
{ flag: 'w' },
50+
);
51+
}
52+
53+
/** Add version information to index.d.ts in dist */
54+
appendVersionToTypeDefn();
55+
/** Copy content of package.json to dist, but remove unnecessary fields */
56+
movePackageJSON();

scripts/steps.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
1. Run `npm run build`
2-
2. Commit .size-snapshot.json, encouraged to summarize the bundle-size in the changelog
3-
3. Add a package version to the `dist/package.json` and `dist/index.d.ts`
4-
4. `npm publish` inside dist
5-
* Run `npm publish --tag beta` for beta
1+
## Step 0 - Setup
2+
1. Create a new branch for the release: `git checkout -b release/vX.X.X`
3+
2. Write changelog in CHANGELOG.md
4+
3. Commit all changes
5+
6+
## Step 1 - Release Candidate
7+
4. Update the version in `package.json` and `package-lock.json` to the new Release Candidate version: Run `npm version prepatch/preminor/premajor`
8+
5. Run `npm run build`
9+
6. Inside `./<root>/dist`, Run `npm publish --tag beta` for beta release. You can also use `npm publish --tag <next | rc>` for other release candidates
10+
7. Commit .bundle_analysis.json, encouraged to summarize the bundle-size in the changelog
11+
8. Test the rc version in your project(s) https://github.com/sendbird/uikit-react-test_suite (WIP: We are automating this step)
12+
9. If everything is fine go to Step 2, otherwise make changes to main branch, rebase and repeat Step 1
13+
14+
## Step 2 - Actual release
15+
10. Commit all changes
16+
11. Update the version in `package.json` and `package-lock.json` to the new real release version: Run `npm version patch/minor/major`
17+
12. Run `npm run build`
18+
13. Inside `./<root>/dist`, Run `npm publish`

0 commit comments

Comments
 (0)