Movatterモバイル変換


[0]ホーム

URL:


Passa al contenuto principale
Questa è una documentazione non rilasciata per la versione pnpmProssimo.
Per la documentazione aggiornata, vediultima versione (10.x).
Versione: Prossimo

Utilizzo di Changesets con pnpm

note

At the time of writing this documentation, the latest pnpm version was v10.4.1. The latestChangesets version was v2.28.0.

Configurazione

Per configurare i changeset su uno spazio di lavoro pnpm, installa Changesets come dipendenza di svuluppo nella radice dello spazio di lavoro:

pnpm add -Dw @changesets/cli

Then run changesets' init command to generate a changesets config:

pnpm changeset init

Aggiunta di nuove modifiche

Per generare un nuovo changeset, eseguipnpm changeset nella radice del repository. I file markdown generati nella directory.changeset dovrebbero essere aggiunti al repository.

Rilascio delle modifiche

  1. Eseguipnpm changeset versione. Ciò aumenterà le versioni dei pacchetti precedentemente specificati conpnpm changeset (e tutti i dipendenti di questi) e aggiornerà i file del registro delle modifiche.
  2. Eseguipmnpm install. Questo aggiornerà il file di blocco e ricostruirà i pacchetti.
  3. Effettua un commit delle modifiche.
  4. Eseguipnpm publish -r. Questo comando pubblicherà tutti i pacchetti che hanno versioni incrementate non ancora presenti nel registro.

Integration with GitHub Actions

To automate the process, you can usechangeset version with GitHub actions. L'azione rileverà quando i file di changeset arrivano nel ramomain, e aprirà una nuova PR che elenca tutti i pacchetti con versioni incrementate. The PR will automatically update itself every time a new changeset file arrives inmain. Once merged the packages will be updated, and if thepublish input has been specified on the action they will be published using the given command.

Add a publish script

Add a new script calledci:publish which executespnpm publish -r. This will publish to the registry once the PR created bychangeset version has been merged. If the package is public and scoped, adding--access=public may be necessary to prevent npm rejecting the publish.

package.json

{
"scripts":{
"ci:publish":"pnpm publish -r"
},
...
}

Add the workflow

Add a new workflow at.github/workflows/changesets.yml. This workflow will create a new branch and PR, so Actions should be givenread and write permissions in the repo settings (github.com/<repo-owner>/<repo-name>/settings/actions). If including thepublish input on thechangesets/action step, the repo should also include an auth token for npm as a repository secret namedNPM_TOKEN.

.github/workflows/changesets.yml

name: Changesets

on:
push:
branches:
- main

env:
CI:true

jobs:
version:
timeout-minutes:15
runs-on: ubuntu-latest
steps:
-name: Checkout code repository
uses: actions/checkout@v4

-name: Setup pnpm
uses: pnpm/action-setup@v4

-name: Setup node.js
uses: actions/setup-node@v4
with:
node-version:20
cache:'pnpm'

-name: Install dependencies
run: pnpm install

-name: Create and publish versions
uses: changesets/action@v1
with:
commit:"chore: update versions"
title:"chore: update versions"
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
NPM_TOKEN: ${{ secrets.NPM_TOKEN}}

More info and documentation regarding the changesets action can be foundhere.


[8]ページ先頭

©2009-2025 Movatter.jp