본문으로 건너뛰기
버전: 9.x

pnpm에서 changesets 사용하기

note

이 문서를 작성할 당시 최신 pnpm 버전은 v6.14 였습니다. The latest Changesets version was v2.16.0.

설치

pnpm 워크스페이스에서 changesets를 설정하려면 워크스페이스의 루트에서 개발 의존성으로 changesets를 설치하세요.

pnpm add -Dw @changesets/cli

그런 다음 changesets의 초기화 명령어를 실행합니다.

pnpm changeset init

새 changesets 추가하기

To generate a new changeset, run pnpm changeset in the root of the repository. The generated markdown files in the .changeset directory should be committed to the repository.

변경 사항 릴리즈하기

  1. Run pnpm changeset version. This will bump the versions of the packages previously specified with pnpm changeset (and any dependents of those) and update the changelog files.
  2. Run pnpm install. 이를 통해 lockfile을 업데이트하고 패키지를 재빌드합니다.
  3. 변경 사항을 커밋합니다.
  4. Run pnpm publish -r. This command will publish all packages that have bumped versions not yet present in the registry.

GitHub Action 사용하기

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. Once merged, the packages will be updated and you can decide whether to publish or not by adding the publish property.

게시

Add a new script ci:publish which executes pnpm publish -r. It will publish to the registry once the PR is opened by changeset version.

package.json

{
"scripts": {
"ci:publish": "pnpm publish -r"
},
...
}
name: Changesets
on:
push:
branches:
- main
env:
CI: true
PNPM_CACHE_FOLDER: .pnpm-store
jobs:
version:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: checkout code repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: install pnpm
run: npm i pnpm@latest -g
- name: Setup npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
- name: setup pnpm config
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
- name: install dependencies
run: pnpm install
- name: create and publish versions
uses: changesets/action@v1
with:
version: pnpm ci:version
commit: "chore: update versions"
title: "chore: update versions"
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

More info and documentation regarding this action can be found here.