Skip to content

Commit d839b67

Browse files
authored
Setup Changesets (#1722)
* chore(changesets): setup changesets for this repository * chore(changeset): add changeset for package release
1 parent 8faa5de commit d839b67

File tree

7 files changed

+665
-403
lines changed

7 files changed

+665
-403
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{
6+
"repo": "commercetools/nodejs"
7+
}
8+
],
9+
"commit": false,
10+
"access": "restricted",
11+
"baseBranch": "master"
12+
}

.github/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
# Pass a personal access token (using our `ct-release-bot` account) to be able to trigger
17+
# other workflows
18+
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
19+
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8
20+
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
21+
22+
- name: Read .nvmrc
23+
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
24+
id: nvm
25+
26+
- name: Setup Node (uses version in .nvmrc)
27+
uses: actions/setup-node@v2
28+
with:
29+
node-version: '${{ steps.nvm.outputs.NVMRC }}'
30+
31+
- name: Get yarn cache
32+
id: yarn-cache
33+
run: echo "::set-output name=dir::$(yarn cache dir)"
34+
35+
- uses: actions/cache@v2
36+
with:
37+
path: ${{ steps.yarn-cache.outputs.dir }}
38+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-yarn-
41+
42+
- name: Install dependencies
43+
run: yarn install --frozen-lockfile
44+
45+
- name: Creating .npmrc
46+
run: |
47+
cat << EOF > "$HOME/.npmrc"
48+
49+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
50+
EOF
51+
env:
52+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
54+
- name: Building packages
55+
run: yarn build
56+
57+
- name: Create Release Pull Request or Publish to npm
58+
id: changesets
59+
uses: changesets/action@master
60+
with:
61+
publish: yarn changeset publish
62+
version: yarn changeset:version-and-format
63+
commit: 'ci(changesets): version packages'
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}

CONTRIBUTING.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ To ensure the lock file is up-to-date with the new versions, it's recommended to
6161

6262
## Releases
6363

64-
We use lerna for releasing packages. Just run `yarn release` from `master` (after pulling in the latest merges) to publish a single or a set of modules. Lerna will check changes on packages providing semver bumps according to the commit messages used for each package.
64+
We use lerna to manage our multi-package (monorepo) repository and we use changesets to publish packages to npm, the following steps will allow you to add a changeset to a change you wish to publish
6565

66-
This will also append all PRs up until the release in the `CHANGELOG.md` and push it as a separate commit with the message `docs: update changelog`. For this to work, we need to have a `Type`-label on the PRs, so please make sure they are added.
66+
- Run the command `yarn changeset`, a list of packages will be listed.
67+
- Select the package(s) that include the changes.
68+
- Add the packages you wish to publish to npm
69+
- Commit the changes, push to Github and then create a PR
6770

68-
For this to work, it is essential that you create and export a github token that has read access to your public repos.
69-
70-
`$ export GITHUB_AUTH=<your_token>`
71+
When this PR is merged into the base branch, a new release PR will be created by changeset and this PR is repsonsible for the actual package release.
7172

7273
#### Commit message
7374

lerna.json

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,5 @@
22
"lerna": "3.16.4",
33
"version": "independent",
44
"useWorkspaces": true,
5-
"npmclient": "yarn",
6-
"changelog": {
7-
"rootPath": ".",
8-
"repo": "commercetools/nodejs",
9-
"labels": {
10-
"Type: New Feature": ":rocket: New Feature",
11-
"Type: Breaking Change": ":boom: Breaking Change",
12-
"Type: Bug": ":bug: Bug Fix",
13-
"Type: Enhancement": ":nail_care: Enhancement",
14-
"Type: Documentation": ":memo: Documentation",
15-
"Type: Maintenance": ":house: Maintenance"
16-
},
17-
"cacheDir": ".changelog",
18-
"ignoreCommitters": ["renovate", "renovate-bot"]
19-
},
20-
"command": {
21-
"publish": {
22-
"npmClient": "yarn",
23-
"message": "chore(release): releasing component"
24-
}
25-
}
5+
"npmclient": "yarn"
266
}

package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
"clean": "rm -rf coverage; lerna exec -- rimraf lib dist",
1212
"commit": "git-cz",
1313
"build": "lerna run build --no-private",
14-
"build:changelog": "lerna-changelog --from=$(git log --grep='chore(release): releasing component' --format='%H' | sed -n 2p) > tmp && cat CHANGELOG.md >> tmp && cat tmp > CHANGELOG.md && rm tmp",
15-
"push:changelog": "git add CHANGELOG.md && git commit -m 'docs: update changelog' && git push",
1614
"check-gh-auth-token": "if [[ -z \"${GITHUB_AUTH}\" ]]; then echo \"Need to set GITHUB_AUTH\" && exit 1; fi",
1715
"build:typings": "NODE_ENV=production lerna run build:typings --no-private",
1816
"lint": "jest --projects jest.eslint.config.js jest.flow.config.js",
@@ -28,7 +26,6 @@
2826
"test:coverage": "yarn build && npm test -- --no-watchman --coverage",
2927
"test:ci": "yarn test -- --ci --no-watchman --maxWorkers=10",
3028
"test:coverage:ci": "yarn test:ci -- --coverage && codecov",
31-
"release": "yarn check-gh-auth-token && cross-env NODE_ENV=cli yarn build && lerna publish --registry=https://registry.npmjs.org/ && yarn build:changelog && yarn push:changelog && yarn docs:publish",
3229
"docs:clean": "rimraf _book",
3330
"docs:prepare": "gitbook install",
3431
"docs:build": "yarn docs:prepare && gitbook build && cp logo/apple-touch-icon.png _book/gitbook/images/apple-touch-icon-precomposed-152.png && cp logo/favicon.ico _book/gitbook/images",
@@ -37,7 +34,9 @@
3734
"typecheck": "yarn typecheck:flow && yarn typecheck:ts",
3835
"typecheck:flow": "flow check --include-warnings",
3936
"typecheck:ts": "lerna run typecheck:ts",
40-
"package-readme-entry": "./scripts/package-readme-entry.sh"
37+
"package-readme-entry": "./scripts/package-readme-entry.sh",
38+
"changeset": "changeset",
39+
"changeset:version-and-format": "changeset version && prettier --write --parser json '**/package.json'"
4140
},
4241
"workspaces": [
4342
"integration-tests",
@@ -57,6 +56,8 @@
5756
"@babel/preset-env": "7.11.0",
5857
"@babel/preset-flow": "7.10.4",
5958
"@babel/preset-typescript": "7.10.4",
59+
"@changesets/changelog-github": "^0.4.1",
60+
"@changesets/cli": "^2.17.0",
6061
"@commitlint/cli": "9.1.2",
6162
"@commitlint/config-conventional": "9.1.2",
6263
"@rollup/plugin-alias": "3.1.1",
@@ -73,7 +74,6 @@
7374
"commitizen": "4.1.2",
7475
"common-tags": "1.8.0",
7576
"cross-env": "7.0.2",
76-
"cz-lerna-changelog": "2.0.3",
7777
"debug": "4.1.1",
7878
"eslint": "7.7.0",
7979
"eslint-config-airbnb": "18.2.0",
@@ -102,7 +102,6 @@
102102
"jest-runner-flowtype": "0.0.7",
103103
"jest-silent-reporter": "0.2.1",
104104
"lerna": "3.22.1",
105-
"lerna-changelog": "1.0.1",
106105
"lint-staged": "10.2.11",
107106
"npm-check-updates": "7.1.1",
108107
"prettier": "2.0.5",
@@ -136,10 +135,5 @@
136135
"serialize-javascript": "3.1.0",
137136
"diff": "3.5.0",
138137
"object-path": "0.11.5"
139-
},
140-
"config": {
141-
"commitizen": {
142-
"path": "./node_modules/cz-lerna-changelog"
143-
}
144138
}
145139
}

0 commit comments

Comments
 (0)