Skip to content

Commit

Permalink
chore: setup release-please
Browse files Browse the repository at this point in the history
  • Loading branch information
leavesster committed Aug 1, 2024
1 parent ae3a175 commit 1e77bcb
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"packages/a": "0.1.0",
"packages/b": "0.1.0"
}
58 changes: 55 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,60 @@
# monorepo-changelog-example
# Monorepo Changelog Example

a example that use release-please to auto generate independent changelog in JavaScript mono repo.
An example that utilizes release-please to automatically generate independent changelogs in a JavaScript monorepo.

## reference
## How to Use Release-please

### Prepare Release-please Configuration and Manifest

Add `release-please-config.json` in the root directory:

```javascript
{
"packages": {
// Specify the path for every package in the "packages" field.
"packages/a": {
// The "component" field specifies the tag name by release-please.
// If not set, release-please will use the package name and remove @scope prefix to tag.
"component": "b"
},
"packages/b": {
"component": "a"
}
},
// It specifies where to update the version. In Node.js, it will update the "package.json" version field.
"release-type": "node",
// To support monorepo, we need to specify the workspace plugin.
"plugins": ["node-workspace"],
// Schema for autocompletion, not used in release-please.
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
```

Add `.release-please-manifest.json` manually; do not use the release-please bootstrap command because it may throw errors for monorepos:

```javascript
{
// Path to the package, release-please will update the version in this field and also in "package.json".
"packages/a": "0.1.0",
"packages/b": "0.1.0"
}
```

### Action Permissions
Release-please requires the following permissions:

```yaml
contents: write
pull-requests: write
```
After adding these permissions, you also need to set action permission settings in repo/org settings: `Repo/Org settings -- Actions -- General`

![Repo/Org settings -- Actions -- General](./action.png)

> If you use GITHUB_TOKEN for release-please-action, be aware that it cannot trigger other actions. If you want to trigger other actions, you need to create an organization PAT or user PAT. Refer to [Github Credential](https://github.com/google-github-actions/release-please-action?tab=readme-ov-file#github-credentials) for more details.

## Reference

- [release-please](https://github.com/googleapis/release-please)
- [release-please-action](https://github.com/google-github-actions/release-please-action)
Expand Down
Binary file added action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/a/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {}
export const a = 'a';
2 changes: 1 addition & 1 deletion packages/b/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {}
export const b = 'b';
20 changes: 20 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"packages": {
"packages/a": {
"component": "a"
},
"packages/b": {
"component": "b"
}
},
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"release-type": "node",
"include-v-in-tag": false,
"tag-separator": "@",
"plugins": [{
"type": "node-workspace",
"updatePeerDependencies": true
}],
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}

0 comments on commit 1e77bcb

Please sign in to comment.