Skip to content

Commit ca8d4fb

Browse files
authored
Update using-changesets.md (#643)
Updates Changesets + PNPM documentation to reflect current available API's. Adds more structure and information to some portions of the page.
1 parent 5424878 commit ca8d4fb

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

docs/using-changesets.md

+30-29
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Using Changesets with pnpm
66
:::note
77

88
At the time of writing this documentation, the latest pnpm version was
9-
v6.14. The latest [Changesets](https://github.com/changesets/changesets) version was v2.16.0.
9+
v10.4.1. The latest [Changesets](https://github.com/changesets/changesets) version was v2.28.0.
1010

1111
:::
1212

@@ -19,7 +19,7 @@ in the root of the workspace:
1919
pnpm add -Dw @changesets/cli
2020
```
2121

22-
Then changesets' init command:
22+
Then run changesets' init command to generate a changesets config:
2323

2424
```sh
2525
pnpm changeset init
@@ -41,18 +41,13 @@ to the repository.
4141
4. Run `pnpm publish -r`. This command will publish all packages that have
4242
bumped versions not yet present in the registry.
4343

44-
## Using GitHub Actions
44+
## Integration with GitHub Actions
4545

46-
To automate the process, you can use `changeset version` with GitHub actions.
46+
To automate the process, you can use `changeset version` with GitHub actions. The action will detect when changeset files arrive in the `main` branch, and then open a new PR listing all the packages with bumped versions. The PR will automatically update itself every time a new changeset file arrives in `main`. Once merged the packages will be updated, and if the `publish` input has been specified on the action they will be published using the given command.
4747

48-
### Bump up package versions
48+
### Add a publish script
4949

50-
The action will detect when changeset files arrive in the `main` branch, and then open a new PR listing all the packages with bumped versions. Once merged, the packages will be updated and you can decide whether to publish or not by adding the `publish` property.
51-
52-
### Publishing
53-
54-
Add a new script `ci:publish` which executes `pnpm publish -r`.
55-
It will publish to the registry once the PR is opened by `changeset version`.
50+
Add a new script called `ci:publish` which executes `pnpm publish -r`. This will publish to the registry once the PR created by `changeset version` has been merged. If the package is public and scoped, adding `--access=public` may be necessary to prevent npm rejecting the publish.
5651

5752
**package.json**
5853
```json
@@ -64,46 +59,52 @@ It will publish to the registry once the PR is opened by `changeset version`.
6459
}
6560
```
6661

62+
### Add the workflow
63+
64+
Add a new workflow at `.github/workflows/changesets.yml`. This workflow will create a new branch and PR, so Actions should be given **read and write** permissions in the repo settings (`github.com/<repo-owner>/<repo-name>/settings/actions`). If including the `publish` input on the `changesets/action` step, the repo should also include an auth token for npm as a repository secret named `NPM_TOKEN`.
65+
66+
**.github/workflows/changesets.yml**
6767
```yaml
6868
name: Changesets
69+
6970
on:
7071
push:
7172
branches:
7273
- main
74+
7375
env:
7476
CI: true
75-
PNPM_CACHE_FOLDER: .pnpm-store
77+
7678
jobs:
7779
version:
7880
timeout-minutes: 15
7981
runs-on: ubuntu-latest
8082
steps:
81-
- name: checkout code repository
82-
uses: actions/checkout@v3
83-
with:
84-
fetch-depth: 0
85-
- name: setup node.js
86-
uses: actions/setup-node@v3
83+
- name: Checkout code repository
84+
uses: actions/checkout@v4
85+
86+
- name: Setup pnpm
87+
uses: pnpm/action-setup@v4
88+
89+
- name: Setup node.js
90+
uses: actions/setup-node@v4
8791
with:
88-
node-version: 14
89-
- name: install pnpm
90-
run: npm i pnpm@latest -g
91-
- name: Setup npmrc
92-
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
93-
- name: setup pnpm config
94-
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
95-
- name: install dependencies
92+
node-version: 20
93+
cache: 'pnpm'
94+
95+
- name: Install dependencies
9696
run: pnpm install
97-
- name: create and publish versions
97+
98+
- name: Create and publish versions
9899
uses: changesets/action@v1
99100
with:
100-
version: pnpm ci:version
101101
commit: "chore: update versions"
102102
title: "chore: update versions"
103103
publish: pnpm ci:publish
104104
env:
105105
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
106107
```
107108
108-
More info and documentation regarding this action can be found
109+
More info and documentation regarding the changesets action can be found
109110
[here](https://github.com/changesets/action).

0 commit comments

Comments
 (0)