Skip to content

Commit b41c080

Browse files
authored
use changesets (#3070)
## Overview **This PR adopts [Changesets](https://github.com/changesets/changesets) for versioning and releasing.** Changesets are a solution to the problem of versioning and updating release notes. Unlike other solutions which generate release notes from [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), Changesets do not prescribe a commit message format and provide more granular control over the contents of release notes. Instead, it keeps information about versions and release notes in a temporary file-based "database". These files are committed to version control, then "flushed" upon release. ### Adding Changesets To add a Changeset to your PR, you'll interface with [`@changesets/cli`](https://npm.im/@changesets/cli), which will ask you to choose whether the Changeset represents a patch, minor, or major version bump. It will also ask you to provide a changelog entry. That entry replaces our current convention for updating a `NEWS.md` file. Once complete, you'll be reminded to commit the Changeset (which will be a unique `.md` file in `.changeset/`), which you'll then push up to your PR. > [!NOTE] > > - Changesets don't need their own commit. > - Not all PRs need changesets--only those which impact the end user. > - [`changeset-bot`](https://github.com/changesets/bot) will automatically detect Changesets (or the lack thereof) and comment on any PR containing them with info about the version bump and the contents of the Changelog entry. ### Releasing The [Changesets Release Action](https://github.com/changesets/action) runs after every push to `master`. It creates and maintains a PR which uses the Changeset files it finds to bump packages and update `CHANGELOG.md` files. Once merged, this PR will create appropriate tags for all updated packages & GitHub Releases for each tag. ### Publishing To publish to npm, a maintainer will pull down the changes, then publish via `lerna publish from-package` (or `yarn npm:publish`)
2 parents fe9e137 + ea81c13 commit b41c080

File tree

6 files changed

+701
-166
lines changed

6 files changed

+701
-166
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"access": "public",
4+
"baseBranch": "master",
5+
"bumpVersionsWithWorkspaceProtocolOnly": true,
6+
"changelog": [
7+
"@changesets/changelog-github",
8+
{
9+
"repo": "endojs/endo"
10+
}
11+
],
12+
"commit": false,
13+
"fixed": [],
14+
"ignore": [],
15+
"linked": [],
16+
"privatePackages": {
17+
"tag": true,
18+
"version": true
19+
},
20+
"updateInternalDependencies": "patch"
21+
}

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
release:
16+
name: Release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout Repo
20+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
21+
22+
# without this, setup-node errors on mismatched yarn versions
23+
- run: corepack enable
24+
25+
- name: Setup Node.js 20
26+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
27+
with:
28+
node-version: 22.x
29+
cache: yarn
30+
31+
- name: Install Dependencies
32+
run: yarn
33+
34+
- name: Process Changesets
35+
# This action will create/update Changesets' Release PR *or* create a
36+
# GitHub Release and tags if its Release PR was just merged
37+
uses: changesets/action@c48e67d110a68bc90ccf1098e9646092baacaa87 # v1

CONTRIBUTING.md

Lines changed: 71 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
# Initial setup
1+
# Contributing to Endo
2+
3+
## Initial setup
24

35
```sh
46
git clone git@github.com:endojs/endo.git
57
cd endo
68
yarn
79
```
810

9-
Endo is a yarn workspaces repository. Running yarn in the root will install and hoist most dependencies up to the root `node_modules`.
11+
Endo is a yarn workspaces repository. Running yarn in the root will install and
12+
hoist most dependencies up to the root `node_modules`.
1013

1114
Note: running yarn `--ignore-scripts` will not complete the setup of SES.
1215
Note: Endo uses `lerna` only for releasing. `lerna bootstrap` is unlikely to work.
1316

14-
## Action pinning
17+
### Action pinning
1518

1619
GitHub Actions are pinned to commit SHAs.
1720
Run `node scripts/update-action-pins.mjs` to refresh patch/minor pins.
@@ -23,21 +26,21 @@ If no version comment exists, it infers the latest tag for that action.
2326
CI enforces pinning with `node scripts/update-action-pins.mjs --check-pins`.
2427
If this check fails, run the updater and commit the resulting changes.
2528

26-
## Creating a new package
29+
### Creating a new package
2730

2831
Run <code>[scripts/create-package.sh](./scripts/create-package.sh) $name</code>,
2932
then update the resulting README.md, package.json (specifically setting
3033
`description` and [if appropriate] removing `"private": false`), index.js, and
3134
index.test.js files.
3235

33-
## Markdown Style Guide
36+
### Markdown Style Guide
3437

3538
When writing Markdown documentation:
3639

37-
* Wrap lines at 80 to 100 columns for readability in terminal editors.
38-
* Start each sentence on a new line.
40+
- Wrap lines at 80 to 100 columns for readability in terminal editors.
41+
- Start each sentence on a new line.
3942
This ensures changes in one sentence do not cascade into the next in diffs.
40-
* Starting sentences on new lines also obviates any question of whether to use
43+
- Starting sentences on new lines also obviates any question of whether to use
4144
one or two spaces after a period.
4245

4346
Example:
@@ -60,175 +63,83 @@ uses a different Markdown flavor for those contexts.
6063
Changes to `ses` require a `yarn build` to be reflected in any dependency where `import 'ses';` appears. Use `yarn build` under `packages/ses` to refresh the build.
6164
Everything else is wired up thanks to workspaces, so no need to run installs in other packages.
6265

63-
# Making a Release
64-
65-
* Review the [next release](
66-
https://github.com/endojs/endo/labels/next-release
67-
) label for additional tasks or pending changes particular to this release.
68-
69-
* Do not release from a Git workspace.
70-
In a Git workspace, `.git` is a file and not a directory.
71-
At time of writing, Lerna does not account for Git workspaces when it looks
72-
up the repository location.
73-
74-
* Create a release branch.
75-
76-
```sh
77-
now=`date -u +%Y-%m-%d-%H-%M-%S`
78-
git checkout -b release-$now
79-
```
80-
81-
* Create the release CHANGELOGs.
82-
83-
```sh
84-
yarn lerna version --no-push --conventional-graduate --no-git-tag-version
85-
```
86-
87-
Use `--conventional-prerelease` instead of `--conventional-graduate` if you
88-
just want to generate a dev release.
89-
90-
* Commit the results.
91-
92-
```sh
93-
git commit -am 'chore: lerna version'
94-
```
95-
96-
* Identify `NEWS.md` files that need to be updated.
97-
Ensure `NEWS.md` captures all user-visible changes in prose that are
98-
user-relevant.
99-
100-
```sh
101-
git grep '# Next'
102-
```
103-
104-
For each of these files, copy the version number and timestamp from the
105-
adjacent `CHANGELOG.md` generated in the previous step.
106-
For example,
107-
108-
```diff
109-
-# Next release
110-
+# 0.5.1 (2021-08-12)
111-
```
66+
## Using Changesets
11267

113-
Also, capture these into a release notes document, where each heading
114-
is the name of the package and the version number instead of the
115-
version number and release date, like so:
68+
Endo uses [Changesets](https://github.com/changesets/changesets) to manage
69+
versioning and changelogs.
70+
A **changeset** is a Markdown file in the `.changeset/` directory that captures:
11671

117-
```
118-
# `ses` 1.0.0
119-
```
72+
- Which packages need to be released
73+
- The [semver](https://semver.org/) bump type (major, minor, or patch)
74+
- A changelog entry describing the change
12075

121-
In the release notes document, we do not manually wrap long lines.
122-
All paragraphs should be joined into long lines, since Github uses a
123-
different flavor of Markdown for descriptions and release notes.
76+
Changesets are "intents to release" that accumulate until maintainers cut a
77+
release.
78+
The changeset files themselves are temporary—when a release is cut, they are
79+
consumed and removed from version control, with their contents incorporated into
80+
each package's `CHANGELOG.md`.
12481

125-
* Commit the results.
82+
This approach automates version bumping across the monorepo (including internal
83+
dependency updates) and generates changelogs automatically, while keeping humans
84+
in the loop to review and edit release notes before publishing.
12685

127-
```sh
128-
git commit -am 'docs: Update release notes'
129-
```
86+
Contributors make versioning decisions _at contribution time_ (i.e. _in the PR
87+
itself_), when the context is fresh.
13088

131-
* Update `yarn.lock`.
89+
### Adding a Changeset
13290

133-
```sh
134-
yarn
135-
git commit -um 'chore: Update yarn.lock'
136-
```
91+
When your PR includes changes that should be released, add a changeset:
13792

138-
* Push the branch.
93+
1. Run `yarn changeset`
94+
2. Select the affected packages (use arrow keys to navigate, space to select,
95+
enter to confirm)
96+
3. Choose the appropriate bump type for each package
97+
4. Write a clear, complete description of the change—what changed, why, and any
98+
migration notes if needed. Consider security and performance implications.
99+
This text will appear verbatim in `CHANGELOG.md`, so make it useful for
100+
consumers of the package.
101+
5. Commit the generated `.changeset/*.md` file with your PR
139102

140-
```sh
141-
git push -u origin release-$now
142-
```
103+
> Do not be alarmed by the unique, auto-generated names of the changeset files!
104+
> This is expected.
143105
144-
* Create a pull request and request a review, using the release notes
145-
from above as the description.
146-
This is an opportunity to:
106+
### Editing a Changeset
147107

148-
- verify that the changes pass tests under continuous integration,
149-
- reflect on whether the automatically chosen version numbers tell an
150-
accurate story about the backward and mutual compatibility of the packages
151-
you are about to publish,
152-
- and to verify that all user-facing changes are noted in the NEWS.md files
153-
with appropriate migration advice when necessary.
108+
You typically want to do this _before_ your PR lands, but all you need to do is
109+
find the changeset file in `.changeset/`, edit it, and commit.
154110

155-
* When your reviewer has approved your release, use `git rebase -i
156-
origin/master` to remove the automatically generated `chore: lerna version`
157-
commit.
111+
### Do I Need a Changeset?
158112

159-
* Recreate the changelogs with the current date *and* generate tags for the new
160-
versions. This is the effect of removing the `--no-git-tag-version` flag.
113+
Generally, you need a changeset only if your PR contains **user-facing changes**
114+
to a package—bug fixes, new features, breaking changes, or other modifications
115+
that consumers of the package would notice.
161116

162-
```sh
163-
yarn lerna version --no-push --conventional-graduate
164-
```
117+
You typically **do not** need a changeset for:
165118

166-
* Update `yarn.lock`.
119+
- Documentation-only changes
120+
- Test additions or fixes
121+
- CI/build configuration changes
122+
- Refactoring that doesn't change public behavior
167123

168-
```sh
169-
yarn
170-
git commit -um 'chore: Update yarn.lock'
171-
```
124+
The helpful [changeset-bot](https://github.com/apps/changeset-bot) will comment
125+
on your PR if no changeset is present, but this won't block merging.
172126

173-
* Publish the versions to npm.
174-
Being a member of the project or organization and having two-factor
175-
authentication may be necessary. It may be necessary to login with
176-
`npm login`. You can check with `npm whoami`.
127+
> [!TIP]
128+
>
129+
> When in doubt, ask a friendly maintainer. Avoid the unfriendly ones.
177130
178-
```sh
179-
npm whoami
180-
# if it does not show you logged in, then do
181-
npm login
182-
# two factor authentication stuff
183-
yarn lerna publish from-package
184-
# repeat this command until all packages are successfully published
185-
```
131+
### Release Workflow (For Maintainers)
186132

187-
* To verify that packages were published, go to the npm web page for the
188-
package, for example
189-
[https://www.npmjs.com/package/ses](https://www.npmjs.com/package/ses).
190-
***However*** do not be alarmed if it does not show your new version for
191-
a distressingly long time. Instead you can verify the version with
133+
The release process works as follows:
192134

193-
```sh
194-
npm view ses
195-
```
196-
197-
* Force push these changes back to the pull request branch.
198-
199-
```sh
200-
git push origin -f release-$now
201-
```
202-
203-
* Merge the release PR into master.
204-
DO NOT REBASE OR SQUASH OR YOU WILL LOSE REFERENCES TO YOUR TAGS.
205-
206-
Notice the little triangle on the merge button and select "Create a merge
207-
commit" from the drop down menu.
208-
Do not rebase.
209-
Do not squash.
210-
Rebasing or squashing will remove the tag from the history of the `master`
211-
branch.
212-
213-
* Selecting "Create a merge commit" in that drop down is sticky. Assuming you
214-
normally want "Squash and merge", be sure to set it back to that at your
215-
next opportunity.
216-
217-
* Push the released tags to Github.
218-
219-
```sh
220-
git tag -l | egrep -e '@[0-9]+\.[0-9]+\.[0-9]+$' | xargs git push origin
221-
```
222-
223-
* Go to https://github.com/endojs/endo/releases and create a new release
224-
using the latest tag for `ses` as the reference tag, and the release
225-
notes you prepared for the pull request description.
226-
227-
## More information
228-
229-
To get help for the command-line options that will affect these commands, use:
230-
231-
```sh
232-
yarn lerna version --help
233-
yarn lerna publish --help
234-
```
135+
1. As changesets accumulate on `master`, the `changesets/action` GitHub Action
136+
(see [.github/workflows/release.yml](.github/workflows/release.yml))
137+
automatically creates and maintains a **Release PR** titled "Version
138+
Packages"
139+
2. This Release PR applies all pending changesets; it bumps versions, updates
140+
`CHANGELOG.md` files, and deletes the consumed changeset files
141+
3. Maintainers review the Release PR to verify versions and changelog entries
142+
look correct. Maintainer will approve and/or merge when ready.
143+
Merging will also create tags and GitHub Releases for each affected package.
144+
4. After merging the Release PR, pull `master` and run `yarn release:npm` to
145+
publish the updated packages to npm.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
},
1010
"packageManager": "yarn@4.10.3",
1111
"devDependencies": {
12+
"@changesets/changelog-github": "^0.5.2",
13+
"@changesets/cli": "^2.29.8",
1214
"@endo/ses-ava": "workspace:^",
1315
"@jessie.js/eslint-plugin": "^0.4.2",
1416
"@lavamoat/allow-scripts": "^3.3.5",
@@ -46,6 +48,7 @@
4648
"lint:fix": "yarn lint:eslint -- --fix",
4749
"lint:workspaces:fix": "yarn workspaces foreach --all run lint-fix",
4850
"lint:prettier": "prettier --check .github packages",
51+
"release:npm": "lerna publish from-package",
4952
"test": "yarn workspaces foreach --all --exclude @endo/skel run test",
5053
"test:c8": "yarn workspaces foreach --all run test:c8",
5154
"test:xs": "yarn workspaces foreach --all run test:xs",

0 commit comments

Comments
 (0)