Skip to content

Commit f420ded

Browse files
Merge pull request #125 from FormidableLabs/ci-provenance
GitHub Actions release workflow addition
2 parents ee3915e + 6748ac4 commit f420ded

File tree

5 files changed

+1015
-36
lines changed

5 files changed

+1015
-36
lines changed

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@svitejs/changesets-changelog-github-compact",
5+
{
6+
"repo": "FormidableLabs/react-fast-compare"
7+
}
8+
],
9+
"access": "public",
10+
"baseBranch": "master"
11+
}

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
release:
8+
name: Release
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
id-token: write
13+
issues: write
14+
repository-projects: write
15+
deployments: write
16+
packages: write
17+
pull-requests: write
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-node@v3
21+
with:
22+
node-version: 18
23+
24+
- name: Install dependencies
25+
run: yarn install --frozen-lockfile
26+
27+
- name: Unit Tests
28+
run: yarn test
29+
30+
- name: PR or Publish
31+
id: changesets
32+
uses: changesets/action@v1
33+
with:
34+
version: yarn changeset version
35+
publish: yarn changeset publish
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ Before contributing, _please make sure the issue relates directly to this librar
99

1010
We encourage pull requests concerning:
1111

12-
* React features not handled in this library
13-
* Integrating updates from `fast-deep-equal` - This, unfortunately, now requires more manual work. Use the comment blocks in `index.js`
12+
- React features not handled in this library
13+
- Integrating updates from `fast-deep-equal` - This, unfortunately, now requires more manual work. Use the comment blocks in `index.js`
1414
to figure out what to paste and where.
15-
* Integrating tests from `fast-deep-equal` - This usually entails upgrading the `git`-based dependencies of `fast-deep-equal-git` and
15+
- Integrating tests from `fast-deep-equal` - This usually entails upgrading the `git`-based dependencies of `fast-deep-equal-git` and
1616
`npm`-published package of `fast-deep-equal` in `package.json:devDependencies`.
17-
* Bugs in this library
18-
* New tests for React
19-
* Documentation
17+
- Bugs in this library
18+
- New tests for React
19+
- Documentation
2020

2121
Pull requests that should be for [fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal):
2222

23-
* Equality of non-react comparisons
24-
* Performance of non-react comparisons
25-
* Tests for non-react comparisons
23+
- Equality of non-react comparisons
24+
- Performance of non-react comparisons
25+
- Tests for non-react comparisons
2626

2727
## Development
2828

@@ -130,23 +130,52 @@ please flag to your reviewers and have a discussion about whether or not the siz
130130

131131
3. Confirm you aren't impacting our bundle size.
132132
If you _do_ affect the bundle size, please update the bundle badge in the Readme by
133-
* Following the steps outlined in [size](#size):
133+
- Following the steps outlined in [size](#size):
134134
`yarn -s compress && yarn size-min-gz`
135-
* Grabbing that output and replacing the current size in the bundle_img: (`https://img.shields.io/badge/minzipped%20size-<NEW_SIZE>%20B-flatgreen.svg`)
135+
- Grabbing that output and replacing the current size in the bundle_img: (`https://img.shields.io/badge/minzipped%20size-<NEW_SIZE>%20B-flatgreen.svg`)
136136
For example, if the new size is `650`, the new bundle_img will be `https://img.shields.io/badge/minzipped%20size-650%20B-flatgreen.svg`
137-
* _Org members:_ Update the README's benchmark comparison png using this [internal Google Sheet template](https://docs.google.com/spreadsheets/d/1GuqpO0wgPjQ9usx6sR3t0Y_HTmAdRqjXkSjs3SBsmTc/edit?usp=sharing_eip&ts=5ed1642f).
137+
- _Org members:_ Update the README's benchmark comparison png using this [internal Google Sheet template](https://docs.google.com/spreadsheets/d/1GuqpO0wgPjQ9usx6sR3t0Y_HTmAdRqjXkSjs3SBsmTc/edit?usp=sharing_eip&ts=5ed1642f).
138138

139-
## Releasing a new version to NPM
139+
### Using changesets
140140

141-
_Only for project administrators_
141+
Our official release path is to use automation to perform the actual publishing of our packages. The steps are to:
142+
143+
1. A human developer adds a changeset. Ideally this is as a part of a PR that will have a version impact on a package.
144+
2. On merge of a PR our automation system opens a "Version Packages" PR.
145+
3. On merging the "Version Packages" PR, the automation system publishes the packages.
146+
147+
Here are more details:
148+
149+
### Add a changeset
150+
151+
When you would like to add a changeset (which creates a file indicating the type of change), in your branch/PR issue this command:
142152

143153
```sh
144-
# (1) Run tests, lint, build published dir, update package.json
145-
$ npm version [patch|minor|major|<version>]
154+
$ yarn changeset
155+
```
156+
157+
to produce an interactive menu. Navigate the packages with arrow keys and hit `<space>` to select 1+ packages. Hit `<return>` when done. Select semver versions for packages and add appropriate messages. From there, you'll be prompted to enter a summary of the change. Some tips for this summary:
158+
159+
1. Aim for a single line, 1+ sentences as appropriate.
160+
2. Include issue links in GH format (e.g. `#123`).
161+
3. You don't need to reference the current pull request or whatnot, as that will be added later automatically.
146162

147-
# (2) If all is well, publish the new version to the npm registry
148-
$ npm publish
163+
After this, you'll see a new uncommitted file in `.changesets` like:
149164

150-
# (3) Then, update github with the associated tag
151-
$ git push && git push --tags
165+
```sh
166+
$ git status
167+
# ....
168+
Untracked files:
169+
(use "git add <file>..." to include in what will be committed)
170+
.changeset/flimsy-pandas-marry.md
152171
```
172+
173+
Review the file, make any necessary adjustments, and commit it to source. When we eventually do a package release, the changeset notes and version will be incorporated!
174+
175+
### Creating versions
176+
177+
On a merge of a feature PR, the changesets GitHub action will open a new PR titled `"Version Packages"`. This PR is automatically kept up to date with additional PRs with changesets. So, if you're not ready to publish yet, just keep merging feature PRs and then merge the version packages PR later.
178+
179+
### Publishing packages
180+
181+
On the merge of a version packages PR, the changesets GitHub action will publish the packages to npm.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"repository": {
2222
"type": "git",
23-
"url": "git+https://github.com/FormidableLabs/react-fast-compare.git"
23+
"url": "https://github.com/FormidableLabs/react-fast-compare"
2424
},
2525
"keywords": [
2626
"fast",
@@ -39,6 +39,8 @@
3939
"devDependencies": {
4040
"@babel/core": "^7.21.0",
4141
"@babel/preset-env": "^7.20.2",
42+
"@changesets/cli": "^2.26.1",
43+
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
4244
"@testing-library/dom": "^9.0.1",
4345
"@testing-library/preact": "^3.2.3",
4446
"@types/node": "^18.15.0",

0 commit comments

Comments
 (0)