Skip to content

Commit

Permalink
GitHub Actions release workflow addition (#328)
Browse files Browse the repository at this point in the history
* GitHub Actions release workflow addition
  • Loading branch information
paulmarsicloud authored May 18, 2023
1 parent 486cb38 commit 0bd9951
Show file tree
Hide file tree
Showing 6 changed files with 1,415 additions and 13 deletions.
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": [
"@svitejs/changesets-changelog-github-compact",
{
"repo": "FormidableLabs/react-swipeable"
}
],
"access": "public",
"baseBranch": "main"
}
5 changes: 5 additions & 0 deletions .changeset/six-worms-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-swipeable": patch
---

Adding GitHub release workflow
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
issues: write
repository-projects: write
deployments: write
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build

- name: Unit Tests
run: yarn test

- name: PR or Publish
id: changesets
uses: changesets/action@v1
with:
version: yarn changeset version
publish: yarn changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
66 changes: 63 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ With this in mind feature requests and PRs that greatly expand its scope will li

We encourage pull requests concerning:

* Bugs in this library
* New tests for React
* Documentation
- Bugs in this library
- New tests for React
- Documentation

## Development

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

Build, run, and test examples locally:

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

All these steps can be verified via a single command.

```sh
# validate all the things
yarn test
Expand Down Expand Up @@ -80,20 +82,74 @@ $ yarn run format
```

If you see this error:

```
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
```

Then run the formatter:

```sh
$ yarn run format
```

### Using changesets

Our official release path is to use automation to perform the actual publishing of our packages. The steps are to:

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.
2. On merge of a PR our automation system opens a "Version Packages" PR.
3. On merging the "Version Packages" PR, the automation system publishes the packages.

Here are more details:

### Add a changeset

When you would like to add a changeset (which creates a file indicating the type of change), in your branch/PR issue this command:

```sh
$ yarn changeset
```

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:

1. Aim for a single line, 1+ sentences as appropriate.
2. Include issue links in GH format (e.g. `#123`).
3. You don't need to reference the current pull request or whatnot, as that will be added later automatically.

After this, you'll see a new uncommitted file in `.changesets` like:

```sh
$ git status
# ....
Untracked files:
(use "git add <file>..." to include in what will be committed)
.changeset/flimsy-pandas-marry.md
```

Changeset will use a randomly generated file name for the markdown description file.

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!

### Creating versions

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.

### Publishing packages

On the merge of a version packages PR, the changesets GitHub action will publish the packages to npm.

## Project Maintainers

### Manual publish method

<detail>
### Releasing a new version
1. Publish to npm
2. Update version in `examples`

#### 1. Publish to npm

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

After publishing a new version to npm we need to make sure the `examples` get updated.

1. Bump the `react-swipeable` version in `examples/package.json` to the new just released version
2. Run `yarn` to install and update the lock file
3. Push changes to `main` branch so the codesandbox examples get updated
4. Build and deploy updated examples to github pages

</detail>

### Building and deploying examples to github pages

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

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

(Optional) Validate examples build locally

```sh
# From root - build the examples
$ yarn examples:build
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@
],
"license": "MIT",
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@rollup/plugin-typescript": "^8.3.0",
"@size-limit/preset-small-lib": "^7.0.8",
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
"@testing-library/react": "^13.0.1",
"@types/jest": "^27.4.1",
"@types/react": "^18.0.8",
Expand All @@ -109,5 +111,8 @@
"dependencies": {},
"peerDependencies": {
"react": "^16.8.3 || ^17 || ^18"
},
"publishConfig": {
"provenance": true
}
}
Loading

0 comments on commit 0bd9951

Please sign in to comment.