Skip to content

Commit f6bdd55

Browse files
benjieacao
authored andcommitted
chore: document our release process using conventions (#948)
* chore: add commitlint, lerna conventional commits/releases/etc * add commitlint to `commit-msg` hook * add `conventionalCommits` * add scripts for `prerelease` and `graduate` * update docs
1 parent 241983e commit f6bdd55

27 files changed

Lines changed: 3096 additions & 1299 deletions

File tree

CONTRIBUTING.md

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,95 @@ Complete your CLA here: <https://code.facebook.com/cla>
5959
5. Ensure all tests pass
6060

6161
```sh
62-
npm test
62+
yarn test
6363
```
6464

65-
## Release on NPM
65+
## Commit Message Conventions
6666

67-
*Only core contributors may release to NPM.*
67+
Our commit messages are linted by `commitlint` following the angular changelog convention. You may end up losing a commit message or two if you don't follow this rule. We can add a prompt if people ask for it. This was designed for compatiblity with various git clients.
6868

69-
To release a new version on NPM, first ensure you're on the `master` branch and
70-
have recently run `git pull` and that all tests pass with `npm test`.
71-
Use `npm version patch|minor|major` in order to increment the version in
72-
package.json and tag and commit a release. Then `git push --follow-tags`
73-
this change so Travis CI can deploy to NPM. *Do not run `npm publish` directly.*
74-
Once published, add [release notes](https://github.com/graphql/graphql-js/tags).
75-
Use [semver](http://semver.org/) to determine which version part to increment.
7669

77-
Example for a patch release:
70+
## Cutting New Releases
71+
72+
We chose a manual process which is pretty simple and flexible because of our conventional commit messages.
73+
74+
If you have NPM privileges, you have the ability to cut new releases of the packages herein.
75+
76+
### Requirements
77+
78+
You'll need:
79+
- `GH_TOKEN` : a github user token as an environment variable
80+
- `git` command line installed, obviously!
81+
- to run `yarn adduser` first to ensure you're authenticated for publishing
82+
- your npm 2FA should be enabled, and you should have your second factor device handy for publish
83+
- your remote should be named `origin` for github, and should be the ssh url
84+
- (coming soon) GPG key uploaded to account for signing
85+
86+
Note: Ideally we can avoid publishing from any branch but `master`, but we can always `--allow-branch mybranch` in case of an emergency for pre-releases. _Whenever you can, always publish from `master`_.
87+
88+
### Prereleases
89+
90+
```sh
91+
yarn version:prerelease graphiql,codemirror-graphql
92+
```
93+
94+
Or
95+
96+
```sh
97+
yarn version:prerelease *
98+
```
99+
100+
for all packages.
101+
102+
It will automatically create and prompt you for each of the pre-release versions that reflect the conventional pattern from the commit log - so some packages may end up pre-alpha, others may be pre-minor, etc.
103+
104+
For example, if you made a change to `graphql-language-service-utils` there would be a new version for every single package. But if you made a change to `graphiql` in the commits since the last publish, there should only be a new pre-release version for `graphiql` when you run this command.
105+
106+
You can also `--amend` a previous release before publishing.
107+
108+
Once this is complete, run `publish:prerelease` to complete this process, so that we can ensure we use pre-release tags. And then you'll of course authenticate again with your 2FA device.
109+
110+
111+
### Graduating Prereleases
112+
113+
Now, after creating and publishing some pre-release versions, if you want to graduate them you can do so with a command that works in very much the same way as above.
78114

79115
```sh
80-
npm version patch
81-
git push --follow-tags
116+
yarn version:graduate *
82117
```
83118

119+
Would graduate all pre-alphas to patch releases, pre-minors to minor releases, etc.
120+
121+
You can also give a comma seperated list of packages, or just a single one, as with `prereleases`
122+
123+
```sh
124+
yarn version:graduate codemirror-graphql
125+
```
126+
127+
then you can run
128+
129+
```sh
130+
yarn run publish:graduate
131+
```
132+
133+
And authenticate with 2FA
134+
135+
136+
### Full Releases
137+
138+
```sh
139+
yarn version:release
140+
```
141+
142+
Will automatically detect and generate changelog/etc with appropriate versions and entries for all subpackage, no need to supply package names or an asterisk
143+
144+
Then you can run
145+
```sh
146+
lerna publish
147+
```
148+
149+
And authenticate with 2FA
150+
84151
## License
85152

86153
By contributing to GraphiQL, you agree that your contributions will be

commitlint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
extends: [
3+
'@commitlint/config-conventional'
4+
],
5+
};

lerna.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
{
2-
"lerna": "3.13.1",
3-
"packages": [
4-
"packages/*",
5-
"packages/graphiql-examples/*"
6-
],
2+
"packages": ["packages/*", "packages/graphiql-examples/*"],
73
"npmClient": "yarn",
84
"useWorkspaces": true,
9-
"version": "independent"
5+
"version": "independent",
6+
"command": {
7+
"publish": {
8+
"allowBranch": [
9+
"master"
10+
],
11+
"preDistTag": "next",
12+
"distTag": "latest"
13+
},
14+
"version": {
15+
"ignoreChanges": "'__tests__' '**/*.spec.js' '**/*.spec.js' '**/*.spec.ts'",
16+
"allowBranch": ["master"],
17+
"message": "chore(release): publish %s",
18+
"conventionalCommits": true,
19+
"createRelease": "github"
20+
}
21+
}
1022
}

package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"browser": {
1717
"copy-to-clipboard": "./node-modules/copy-to-clipboard/index.js"
1818
},
19+
"husky": {
20+
"hooks": {
21+
"pre-commit": "yarn lint",
22+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
23+
}
24+
},
1925
"scripts": {
2026
"build": "lerna run build",
2127
"test": "yarn run lint && yarn run check && yarn run build && yarn run testonly",
@@ -26,7 +32,10 @@
2632
"check": "flow check --show-all-errors",
2733
"prepublish": "node resources/prepublish.js",
2834
"pretty": "node resources/pretty.js",
29-
"pretty-check": "node resources/pretty.js --check"
35+
"pretty-check": "node resources/pretty.js --check",
36+
"version:release": "lerna version",
37+
"version:prerelease": "lerna version --conventional-prerelease",
38+
"version:graduate": "lerna version --conventional-graduate"
3039
},
3140
"devDependencies": {
3241
"@babel/cli": "7.4.4",
@@ -39,8 +48,12 @@
3948
"@babel/preset-flow": "7.0.0",
4049
"@babel/preset-react": "7.0.0",
4150
"@babel/register": "^7.4.4",
51+
"@commitlint/cli": "^8.1.0",
52+
"@commitlint/config-conventional": "^8.1.0",
53+
"@commitlint/config-lerna-scopes": "^8.1.0",
4254
"babel-eslint": "^10.0.1",
4355
"chai": "4.2.0",
56+
"conventional-changelog-conventionalcommits": "^4.1.0",
4457
"eslint": "^5.16.0",
4558
"eslint-config-prettier": "4.3.0",
4659
"eslint-plugin-babel": "5.3.0",
@@ -51,7 +64,8 @@
5164
"fetch-mock": "^6.0.0",
5265
"flow-bin": "^0.101.0",
5366
"graphql": "^14.3.1",
54-
"lerna": "^3.15.0",
67+
"husky": "^3.0.5",
68+
"lerna": "^3.16.4",
5569
"mocha": "6.1.4",
5670
"prettier": "^1.18.2"
5771
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
## 0.9.1-alpha.1 (2019-09-01)
7+
8+
**Note:** Version bump only for package codemirror-graphql
9+
10+
11+
12+
13+
14+
## 0.9.1-alpha.0 (2019-09-01)
15+
16+
**Note:** Version bump only for package codemirror-graphql
17+
18+
19+
20+
21+
22+
## 0.9.1 (2019-09-01)
23+
24+
**Note:** Version bump only for package codemirror-graphql

packages/codemirror-graphql/package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "codemirror-graphql",
3-
"version": "0.9.0",
3+
"version": "0.9.1-alpha.1",
44
"description": "GraphQL mode and helpers for CodeMirror.",
55
"contributors": [
66
"Hyohyeon Jeong <asiandrummer@fb.com>",
77
"Lee Byron <lee@leebyron.com> (http://leebyron.com/)",
88
"Angel Gomez Salazar <agomezs@fb.com>"
99
],
1010
"homepage": "https://github.com/graphql/graphiql/tree/master/packages/codemirror-graphql#readme",
11-
"repository": "https://github.com/graphql/graphiql/tree/master/packages/codemirror-graphql",
11+
"repository": "https://github.com/graphql/graphiql",
1212
"bugs": {
1313
"url": "https://github.com/graphql/graphiql/issues?q=issue+label:codemirror-graphql"
1414
},
@@ -31,17 +31,15 @@
3131
"build": "babel src --root-mode upward --ignore __tests__ --out-dir .",
3232
"build-js": "node ../../resources/buildJs.js",
3333
"build-flow": "node ../../resources/buildFlow.js",
34-
"watch": "babel --optional runtime resources/watch.js | node",
35-
"preversion": ". ./resources/checkgit.sh && yarn test",
36-
"prepublish": ". ./resources/prepublish.sh"
34+
"watch": "babel --optional runtime resources/watch.js | node"
3735
},
3836
"peerDependencies": {
3937
"codemirror": "^5.26.0",
4038
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
4139
},
4240
"dependencies": {
43-
"graphql-language-service-interface": "^2.1.0",
44-
"graphql-language-service-parser": "^1.3.0"
41+
"graphql-language-service-interface": "^2.1.1-alpha.1",
42+
"graphql-language-service-parser": "^1.3.1-alpha.1"
4543
},
4644
"devDependencies": {
4745
"chai": "4.1.1",

packages/graphiql-examples/cdn/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"name": "graphiql-example-cdn",
3+
"version": "0.0.1",
4+
"private": true,
35
"license": "MIT",
46
"description": "An example using GraphiQL",
57
"scripts": {

packages/graphiql/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
## 0.14.3 (2019-09-01)
7+
8+
9+
### Bug Fixes
10+
11+
* check `this.editor` exist before `this.editor.off` in QueryEditor ([#669](https://github.com/graphql/graphiql/issues/669)) ([ca226ee](https://github.com/graphql/graphiql/commit/ca226ee)), closes [#665](https://github.com/graphql/graphiql/issues/665)
12+
* extraKeys bugfix window regression ([f3d0427](https://github.com/graphql/graphiql/commit/f3d0427))
13+
* preserve ctrl-f key for macOS ([7c381f9](https://github.com/graphql/graphiql/commit/7c381f9))
14+
* remove newline ([19f5d1d](https://github.com/graphql/graphiql/commit/19f5d1d))
15+
16+
17+
18+
## 0.13.2 (2019-06-21)
19+
20+
21+
22+
23+
24+
## 0.13.2 (2019-06-21)

packages/graphiql/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "graphiql",
3-
"version": "0.14.2",
3+
"version": "0.14.3",
44
"description": "An graphical interactive in-browser GraphQL IDE.",
55
"contributors": [
66
"Hyohyeon Jeong <asiandrummer@fb.com>",
77
"Lee Byron <lee@leebyron.com> (http://leebyron.com/)"
88
],
9-
"repository": "http://github.com/graphql/graphiql/tree/master/packages/graphiql",
9+
"repository": "http://github.com/graphql/graphiql",
1010
"homepage": "http://github.com/graphql/graphiql/tree/master/packages/graphiql#readme",
1111
"bugs": {
1212
"url": "https://github.com/graphql/graphiql/issues?q=issue+label:graphiql"
@@ -41,7 +41,6 @@
4141
"build-flow": "node ../../resources/buildFlow.js",
4242
"check": "flow check",
4343
"dev": "babel-node --root-mode upward test/server.js",
44-
"preversion": ". ./resources/checkgit.sh && npm test",
4544
"test": "jest --no-cache spec"
4645
},
4746
"lint-staged": {

packages/graphiql/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
87
import 'regenerator-runtime/runtime';
98
// The primary React component to use.
109
module.exports = require('./components/GraphiQL').GraphiQL;

0 commit comments

Comments
 (0)