Skip to content

Commit

Permalink
ci: implement release-please to automate release creation (#863)
Browse files Browse the repository at this point in the history
* ci: implement release-please to automate release creation

* docs: remove unnecessary validate step from PR checklist

* chore: fix current version

* docs: update README's Releasing section

* ci: add semantic-pull-request validation

* docs: add note about versioning in the PR template

* chore: address code review feedback
  • Loading branch information
rmartins90 authored Jan 21, 2025
1 parent 9fe4499 commit 7f5f754
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 58 deletions.
10 changes: 3 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Closes #...

## Short description

<!--
Please describe your implementation and any details that we should keep in mind during review.
-->

## PR Checklist

Expand All @@ -16,14 +18,8 @@ Feel free to leave unchecked or remove the lines that are not applicable.

- [ ] Added tests for bugs / new features
- [ ] Updated docs (storybooks, readme)
- [ ] Executed `npm run validate` and made sure no errors / warnings were shown
- [ ] Described changes in `CHANGELOG.md`
- [ ] Bumped version in `package.json` and `package-lock.json` (`npm --no-git-tag-version version <major|minor|patch>`) [ref](https://docs.npmjs.com/cli/v6/commands/npm-version)
- [ ] Reviewed and approved Chromatic visual regression tests in CI

## Versioning

<!--
Please state if this is a breaking change, a new feature, a bug fix, or if it
does not require a new version being published at all (e.g. README update, etc.)
_Note:_ versioning is handled by [release-please](https://github.com/googleapis/release-please) action, based on the PR title.
-->
14 changes: 14 additions & 0 deletions .github/release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"release-type": "node",
"bump-minor-pre-major": false,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"prerelease": false,
"include-component-in-tag": false
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
3 changes: 3 additions & 0 deletions .github/release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "27.2.1"
}
25 changes: 25 additions & 0 deletions .github/workflows/check-semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Semantic Pull Request

on:
pull_request:
types:
- edited
- opened
- synchronize
push:
branches:
- gh-readonly-queue/main/**

jobs:
validate-title:
name: Validate Title
runs-on: ubuntu-latest

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 5
steps:
- name: Validate pull request title
uses: amannn/action-semantic-pull-request@db6e259b93f286e3416eef27aaae88935d16cf2e
with:
validateSingleCommit: true
8 changes: 5 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Release @doist/reactist package

on:
release:
types: [created]
workflow_dispatch:
push:
tags:
- 'v*'

permissions:
# Enable the use of OIDC for npm provenance
Expand All @@ -14,6 +14,8 @@ permissions:

jobs:
publish:
# Only run if release-please created a release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
# Based on historical data
timeout-minutes: 60
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release Please

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: '@doist/reactist'
config-file: .github/release-please-config.json
manifest-file: .github/release-please-manifest.json
68 changes: 20 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,58 +203,30 @@ When you open a GitHub PR, you'll notice the "UI Review" and "UI Tests" CI steps

# Releasing

A new version of reactist is published both on npm and GitHub Package Registry whenever a new release on GitHub is created.
This project uses [release-please](https://github.com/googleapis/release-please) to automate version management and package publishing.

## Before merging your changes
## How it works

In the GitHub PR that contains your new changes, make sure that you also include the following:
1. Make your changes using [Conventional Commits](https://www.conventionalcommits.org/):

1. Add tests for bugs and new feature
- `feat:` for new features (minor version bump)
- `fix:` for bug fixes (patch version bump)
- `feat!:` or `fix!:` for breaking changes (major version bump)
- `docs:` for documentation changes
- `chore:` for maintenance tasks
- `ci:` for CI changes

2. Update relevant docs (storybooks, readme)
2. When commits are pushed to `main`:

3. Execute:
- Release-please automatically creates/updates a release PR
- The PR includes version bump and changelog updates
- Review the PR and merge when ready

```sh
npm run validate
```

and make sure no errors nor warnings are shown

4. Describe your changes in [`CHANGELOG.md`](CHANGELOG.md)

5. Bump the version in [`package.json`](package.json) and [`package-lock.json`](package-lock.json) by running:

```sh
npm --no-git-tag-version version <major|minor|patch>
```

[ref](https://docs.npmjs.com/cli/v6/commands/npm-version)

Note that the steps above are also documented in the [PR template](.github/PULL_REQUEST_TEMPLATE.md) that you will be prompted with whenever you open a new reactist GitHub PR.

## After merging your changes

Once your changes have been merged to `main`, create a new GitHub release:

1. Visit https://github.com/Doist/reactist/releases/new

2. In the "Choose a tag" dropdown, type the new release version (i.e. vX.Y.Z) and select "Create new tag: vX.Y.Z on publish"

3. In the "Release title" field, type the new release version (i.e. vX.Y.Z)

4. In the "Describe the release" box, paste the same content you added to the [`CHANGELOG.md`](CHANGELOG.md), but without the title header

5. Make sure the "Set as the latest release" checkbox is checked

6. Click "Publish release"

7. Visit https://github.com/Doist/reactist/actions

8. Make sure that a new GitHub action is now running (this will automatically perform all the necessary steps to publish the package)

9. Once the action is complete, check https://npmjs.com/package/@doist/reactist and verify that there's a new public release

Finally, be sure to update both [todoist-web](https://github.com/Doist/todoist-web) and [twist-web](https://github.com/Doist/twist-web) to use the new reactist version you just published.
3. After merging the release PR:
- A new GitHub release is automatically created
- A new tag is created
- The `publish` workflow is triggered
- The package is published to npm and GitHub Packages
- Storybook documentation is automatically updated

The storybook hosted on GitHub pages will be automatically updated on each push to `main`. Should there be a problem, try running the action manually from the [Actions settings](https://github.com/Doist/reactist/actions).
The storybook hosted on GitHub pages will be automatically updated on each push to `main`. If there's a problem, try running the action manually from the [Actions settings](https://github.com/Doist/reactist/actions).

0 comments on commit 7f5f754

Please sign in to comment.