Skip to content

Commit 0bd9951

Browse files
GitHub Actions release workflow addition (#328)
* GitHub Actions release workflow addition
1 parent 486cb38 commit 0bd9951

File tree

6 files changed

+1415
-13
lines changed

6 files changed

+1415
-13
lines changed

.changeset/config.json

+11
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-swipeable"
7+
}
8+
],
9+
"access": "public",
10+
"baseBranch": "main"
11+
}

.changeset/six-worms-tease.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-swipeable": patch
3+
---
4+
5+
Adding GitHub release workflow

.github/workflows/release.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
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: Build
28+
run: yarn build
29+
30+
- name: Unit Tests
31+
run: yarn test
32+
33+
- name: PR or Publish
34+
id: changesets
35+
uses: changesets/action@v1
36+
with:
37+
version: yarn changeset version
38+
publish: yarn changeset publish
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

+63-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ With this in mind feature requests and PRs that greatly expand its scope will li
1010

1111
We encourage pull requests concerning:
1212

13-
* Bugs in this library
14-
* New tests for React
15-
* Documentation
13+
- Bugs in this library
14+
- New tests for React
15+
- Documentation
1616

1717
## Development
1818

@@ -25,6 +25,7 @@ Make changes/updates to the `src/index.ts` file.
2525
### Verify updates with the examples
2626

2727
Build, run, and test examples locally:
28+
2829
```sh
2930
# Go into examples folder
3031
react-swipeable$ cd examples
@@ -43,6 +44,7 @@ You can now make updates/changes to `src/index.ts` and webpack will rebuild, the
4344
Our builds run unit tests, lint, prettier, compile/build, and watch package size via [size-limit](https://github.com/ai/size-limit/).
4445

4546
All these steps can be verified via a single command.
47+
4648
```sh
4749
# validate all the things
4850
yarn test
@@ -80,20 +82,74 @@ $ yarn run format
8082
```
8183

8284
If you see this error:
85+
8386
```
8487
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
8588
```
89+
8690
Then run the formatter:
91+
8792
```sh
8893
$ yarn run format
8994
```
9095

96+
### Using changesets
97+
98+
Our official release path is to use automation to perform the actual publishing of our packages. The steps are to:
99+
100+
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.
101+
2. On merge of a PR our automation system opens a "Version Packages" PR.
102+
3. On merging the "Version Packages" PR, the automation system publishes the packages.
103+
104+
Here are more details:
105+
106+
### Add a changeset
107+
108+
When you would like to add a changeset (which creates a file indicating the type of change), in your branch/PR issue this command:
109+
110+
```sh
111+
$ yarn changeset
112+
```
113+
114+
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:
115+
116+
1. Aim for a single line, 1+ sentences as appropriate.
117+
2. Include issue links in GH format (e.g. `#123`).
118+
3. You don't need to reference the current pull request or whatnot, as that will be added later automatically.
119+
120+
After this, you'll see a new uncommitted file in `.changesets` like:
121+
122+
```sh
123+
$ git status
124+
# ....
125+
Untracked files:
126+
(use "git add <file>..." to include in what will be committed)
127+
.changeset/flimsy-pandas-marry.md
128+
```
129+
130+
Changeset will use a randomly generated file name for the markdown description file.
131+
132+
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!
133+
134+
### Creating versions
135+
136+
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.
137+
138+
### Publishing packages
139+
140+
On the merge of a version packages PR, the changesets GitHub action will publish the packages to npm.
141+
91142
## Project Maintainers
143+
144+
### Manual publish method
145+
146+
<detail>
92147
### Releasing a new version
93148
1. Publish to npm
94149
2. Update version in `examples`
95150

96151
#### 1. Publish to npm
152+
97153
```sh
98154
# (1) Runs tests, lint, build published dir, updates package.json
99155
$ npm version [patch|minor|major|<version>]
@@ -108,18 +164,22 @@ $ git push --follow-tags
108164
#### 2. Update version in the examples
109165

110166
After publishing a new version to npm we need to make sure the `examples` get updated.
167+
111168
1. Bump the `react-swipeable` version in `examples/package.json` to the new just released version
112169
2. Run `yarn` to install and update the lock file
113170
3. Push changes to `main` branch so the codesandbox examples get updated
114171
4. Build and deploy updated examples to github pages
115172

173+
</detail>
174+
116175
### Building and deploying examples to github pages
117176

118177
The examples build using the most recent version of `react-swipeable`.
119178

120179
Make sure you've already completed the above steps for `Update version in the examples` so the `examples` have the most recent version installed.
121180

122181
(Optional) Validate examples build locally
182+
123183
```sh
124184
# From root - build the examples
125185
$ yarn examples:build

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@
8282
],
8383
"license": "MIT",
8484
"devDependencies": {
85+
"@changesets/cli": "^2.26.1",
8586
"@rollup/plugin-typescript": "^8.3.0",
8687
"@size-limit/preset-small-lib": "^7.0.8",
88+
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
8789
"@testing-library/react": "^13.0.1",
8890
"@types/jest": "^27.4.1",
8991
"@types/react": "^18.0.8",
@@ -109,5 +111,8 @@
109111
"dependencies": {},
110112
"peerDependencies": {
111113
"react": "^16.8.3 || ^17 || ^18"
114+
},
115+
"publishConfig": {
116+
"provenance": true
112117
}
113118
}

0 commit comments

Comments
 (0)