Skip to content

Commit dd6554d

Browse files
authored
Add changesets (#333)
* Remove lerna * Add changesets, related workflows and docs
1 parent 315dca5 commit dd6554d

File tree

24 files changed

+898
-2998
lines changed

24 files changed

+898
-2998
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{"repo": "Shopify/web-configs"}
6+
],
7+
"commit": false,
8+
"fixed": [],
9+
"linked": [],
10+
"access": "restricted",
11+
"baseBranch": "main",
12+
"updateInternalDependencies": "patch",
13+
"ignore": [],
14+
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
15+
"updateInternalDependents": "always"
16+
}
17+
}

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
## Description
22

33
<!--
4-
Please include a summary of what you want to achieve in this pull request.
5-
6-
If this fixes an existing issue, please include the issue number.
7-
-->
8-
9-
## Type of change
10-
11-
<!--
12-
Remember to indicate the affected package(s), as well as the type of change for each package.
4+
Please include a summary of what you want to achieve in this pull request. Remember to add a changeset that indicates the affected package(s) and if they are major / minor / patch changes by using `yarn changeset`. See https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md for more info.
135
-->
14-
15-
- [ ] <!--Package Name--> Patch: Bug (non-breaking change which fixes an issue)
16-
- [ ] <!--Package Name--> Minor: New feature (non-breaking change which adds functionality)
17-
- [ ] <!--Package Name--> Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)
18-
19-
## Checklist
20-
21-
- [ ] I have added a changelog entry, prefixed by the type of change noted above (Documentation fix and Test update does not need a changelog as we do not publish a new version for these changes)

.github/workflows/changelog.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Changelog
2+
3+
on:
4+
pull_request:
5+
types:
6+
- labeled
7+
- unlabeled
8+
- opened
9+
- synchronize
10+
- reopened
11+
12+
jobs:
13+
check:
14+
if: |
15+
!contains(github.event.pull_request.head.ref, 'changeset-release') &&
16+
!contains(github.event.pull_request.labels.*.name, '🤖Skip Changelog')
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout branch
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node with v16.13.0
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: 16.13.0
28+
29+
- name: Check for Changeset
30+
run: npx @changesets/cli status --since="origin/main"

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repo
16+
uses: actions/checkout@v2
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: 16.x
22+
cache: 'yarn'
23+
24+
- name: Install dependencies
25+
run: yarn --frozen-lockfile
26+
27+
- name: Create release Pull Request or publish to NPM
28+
id: changesets
29+
uses: changesets/action@v1
30+
with:
31+
publish: yarn release
32+
env:
33+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}s

.github/workflows/snapit.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Snapit
2+
3+
on:
4+
issue_comment:
5+
types:
6+
- created
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
snapshot:
12+
name: Snapshot Release
13+
if: github.event.issue.pull_request && github.event.comment.body == '/snapit'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Validate pull request
17+
uses: actions/github-script@v6
18+
with:
19+
script: |
20+
try {
21+
await github.rest.reactions.createForIssueComment({
22+
...context.repo,
23+
comment_id: context.payload.comment.id,
24+
content: 'eyes',
25+
})
26+
const actorPermission = (await github.rest.repos.getCollaboratorPermissionLevel({
27+
...context.repo,
28+
username: context.actor
29+
})).data.permission
30+
const isPermitted = ['write', 'admin'].includes(actorPermission)
31+
if (!isPermitted) {
32+
const errorMessage = 'Only users with write permission to the respository can run /snapit'
33+
await github.rest.issues.createComment({
34+
...context.repo,
35+
issue_number: context.issue.number,
36+
body: errorMessage,
37+
})
38+
core.setFailed(errorMessage)
39+
return;
40+
}
41+
const pullRequest = await github.rest.pulls.get({
42+
...context.repo,
43+
pull_number: context.issue.number,
44+
})
45+
// Pull request from fork
46+
if (context.payload.repository.full_name !== pullRequest.data.head.repo.full_name) {
47+
const errorMessage = '`/snapit` is not supported on pull requests from forked repositories.'
48+
await github.rest.issues.createComment({
49+
...context.repo,
50+
issue_number: context.issue.number,
51+
body: errorMessage,
52+
})
53+
core.setFailed(errorMessage)
54+
}
55+
} catch (err) {
56+
core.setFailed(`Request failed with error ${err}`)
57+
}
58+
- name: Checkout pull request branch
59+
uses: actions/checkout@v2
60+
with:
61+
ref: ${{ format('refs/pull/{0}/merge', github.event.issue.number) }}
62+
63+
# Because changeset entries are consumed and removed on the
64+
# 'changeset-release/main' branch, we need to reset the files
65+
# so the following 'changeset version --snapshot' command will
66+
# regenerate the package version bumps with the snapshot releases
67+
- name: Reset changeset entries on changeset-release/main branch
68+
run: |
69+
if [[ $(git branch --show-current) == 'changeset-release/main' ]]; then
70+
git checkout origin/main -- .changeset
71+
fi
72+
- name: Setup Node.js
73+
uses: actions/setup-node@v2
74+
with:
75+
node-version: 16.x
76+
77+
- name: Install dependencies
78+
run: yarn --frozen-lockfile
79+
80+
- name: Create an .npmrc
81+
env:
82+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
run: |
84+
cat << EOF > "$HOME/.npmrc"
85+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
86+
EOF
87+
- name: Create and publish snapshot release
88+
uses: actions/github-script@v6
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
with:
92+
script: |
93+
await exec.exec('yarn run changeset version --snapshot snapshot')
94+
const {stdout} = await exec.getExecOutput('yarn run release -- --no-git-tags --snapshot --tag snapshot')
95+
const newTags = Array
96+
.from(stdout.matchAll(/New tag:\s+([^\s\n]+)/g))
97+
.map(([_, tag]) => tag)
98+
if (newTags.length) {
99+
const multiple = newTags.length > 1
100+
const body = (
101+
`🫰✨ **Thanks @${context.actor}! ` +
102+
`Your snapshot${multiple ? 's have' : ' has'} been published to npm.**\n\n` +
103+
`Test the snapshot${multiple ? 's' : ''} by updating your \`package.json\` ` +
104+
`with the newly published version${multiple ? 's' : ''}:\n` +
105+
newTags.map(tag => (
106+
'```sh\n' +
107+
`yarn add ${tag}\n` +
108+
'```'
109+
)).join('\n')
110+
)
111+
await github.rest.issues.createComment({
112+
...context.repo,
113+
issue_number: context.issue.number,
114+
body,
115+
})
116+
await github.rest.reactions.createForIssueComment({
117+
...context.repo,
118+
comment_id: context.payload.comment.id,
119+
content: 'rocket',
120+
})
121+
}

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ node_modules
3232
npm-debug.log
3333
**/npm-debug.log
3434

35-
# Debug log from lerna
36-
lerna-debug.log
37-
3835
# Debug logs from yarn
3936
**/yarn-error.log
4037

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Web Configs
44

55
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)
6-
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)
76

87
This repository contains common configurations for building web apps at Shopify.
98

@@ -50,7 +49,6 @@ dev up
5049
# External Contributor - To start working on the codebase, first fork the repo, then clone it
5150
git clone [email protected]:{your-username}/web-configs.git # replace {your-username} with your GitHub handle
5251
yarn # install project dependencies
53-
yarn lerna bootstrap
5452
```
5553

5654
##### What is `dev`?

documentation/release-and-deploy.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Creating Releases
2+
3+
Changelogs and releases are managed using [`changesets`](https://github.com/changesets/changesets).
4+
5+
## Performing a mainline release
6+
7+
We have a [GitHub Action](https://github.com/Shopify/web-configs/blob/main/.github/workflows/release.yml) that leverages [`changesets/action`](https://github.com/changesets/action) to handle the release process.
8+
9+
Upon merging PRs with a changeset entry, it shall create a "Version Packages" PR that shall contain any changeset changes since the last release.
10+
11+
To perform a release:
12+
13+
- Find the [currently open "Version Packages" PR](https://github.com/Shopify/web-configs/pulls?q=is%3Apr+is%3Aopen+author%3Aapp%2Fgithub-actions+%22Version+Packages%22)
14+
- Note that by default all required CI checks are absent. This is expected as the pull request and commit are created using the default GITHUB_TOKEN access token, which [skips downstream events to prevent infinite loops](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow).
15+
- Merge the PR by checking the `Merge without waiting for requirements to be met (administrators only)` checkbox and choosing `Squash and merge`. We consider skipping the required checks to be acceptable as we are confident that these automated updates of `package.json` and `CHANGELOG.md` would not cause CI to fail.
16+
17+
The `Release` action shall run on the merge commit on the `main` branch, and shall publish the npm packages and create a GitHub tag and release for each package that is referenced in the PR. You can find the action log by looking at the release commit status on the merge commit.
18+
19+
## Performing a snapshot release
20+
21+
[Snapshot releases](https://github.com/changesets/changesets/blob/main/docs/snapshot-releases.md) publish the state of a single PR. This lets you rapidly test a PR in a consuming project without dealing with `yalc` and its occasional weirdness.
22+
23+
To perform a snapshot release:
24+
25+
- Ensure your PR contains at least one changeset entry.
26+
- Comment `/snapit` on your PR.
27+
28+
The `Snapit` action shall run, and shall publish a new version of the packages in your PR's changeset entry with the `snapshot` dist tag. On sucessful publication a comment shall be posted in the issue detailing the published packages and details on how to use them in your consuming project.
29+
30+
This functionality is only available in PRs that point to a branch in the `Shopify/web-configs` repository - PRs from forks are not supported.

lerna.json

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

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@
99
"scripts": {
1010
"test": "jest",
1111
"lint": "eslint '**/*.{js,jsx,ts,tsx}'",
12-
"check": "lerna run check",
1312
"generate": "plop",
14-
"version-bump": "lerna version --no-push --include-merged-tags",
15-
"version": "node scripts/update-changelogs-on-version.js",
1613
"generate:package": "plop package && yarn plop docs",
17-
"tophat": "tophat",
18-
"updated": "lerna updated"
14+
"release": "changeset publish",
15+
"tophat": "tophat"
1916
},
2017
"devDependencies": {
18+
"@changesets/cli": "^2.23.0",
2119
"@shopify/tophat": "^0.0.4",
2220
"@types/jest": "^26.0.24",
2321
"eslint": "^8.3.0",
2422
"fs-extra": "^9.0.0",
2523
"glob": "^7.1.6",
2624
"jest": "^27.0.6",
27-
"lerna": "^4.0.0",
2825
"plop": "^2.6.0",
2926
"prettier": "^2.0.5",
3027
"watchpack": "^2.2.0"

packages/babel-preset/CHANGELOG.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file.
4-
5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7-
8-
<!-- ## Unreleased -->
9-
103
## 24.1.5 - 2021-11-18
114

125
### Changed

packages/browserslist-config/CHANGELOG.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file.
4-
5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7-
8-
<!-- ## Unreleased -->
9-
103
## 3.0.0 - 2021-07-12
114

125
### Breaking Change

packages/eslint-plugin/.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ node_modules
44
.eslintignore
55
coverage
66
*.log
7-
shipit.yml

packages/eslint-plugin/CHANGELOG.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file.
4-
5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7-
8-
<!-- ## Unreleased -->
9-
103
## 41.3.0 - 2022-05-30
114

125
### Changed

packages/images/CHANGELOG.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file.
4-
5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7-
8-
<!-- ## Unreleased -->
9-
103
## 3.1.0 - 2021-12-08
114

125
### Changed

packages/postcss-plugin/CHANGELOG.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file.
4-
5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7-
8-
<!-- ## Unreleased -->
9-
103
## 5.0.1 - 2021-07-08
114

125
- Fix options. [[#270](https://github.com/Shopify/web-configs/pull/270)]

0 commit comments

Comments
 (0)