-
Notifications
You must be signed in to change notification settings - Fork 392
docs: add usage instructions to README #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tsevdos
wants to merge
4
commits into
changesets:main
Choose a base branch
from
tsevdos:docs/documentation-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+49
−37
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,12 +42,13 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v3 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js 20 | ||
| uses: actions/setup-node@v3 | ||
| - name: Setup Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| node-version: 24 | ||
| registry-url: "https://registry.npmjs.org" | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn | ||
|
|
@@ -58,7 +59,27 @@ jobs: | |
|
|
||
| #### With Publishing | ||
|
|
||
| Before you can setup this action with publishing, you'll need to have an [npm token](https://docs.npmjs.com/creating-and-viewing-authentication-tokens) that can publish the packages in the repo you're setting up the action for and doesn't have 2FA on publish enabled ([2FA on auth can be enabled](https://docs.npmjs.com/about-two-factor-authentication)). You'll also need to [add it as a secret on your GitHub repo](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) with the name `NPM_TOKEN`. Once you've done that, you can create a file at `.github/workflows/release.yml` with the following content. | ||
| Before you can set up this action with publishing, make sure you read and understand the [Trusted publishing for npm packages](https://docs.npmjs.com/trusted-publishers) and the [npm classic tokens revoked, session-based auth and CLI token management now available](https://github.blog/changelog/2025-12-09-npm-classic-tokens-revoked-session-based-auth-and-cli-token-management-now-available/) documentation from the NPM and GitHub sites. The first step is to [**configure trusted publishing**](https://docs.npmjs.com/trusted-publishers#configuring-trusted-publishing) on [Github actions](https://github.com/features/actions) or [GitLab CI/CD Pipelines](https://docs.gitlab.com/ci/pipelines/). Follow the [**instructions**](https://docs.npmjs.com/trusted-publishers#step-1-add-a-trusted-publisher-on-npmjscom) by configuring the fields below: | ||
|
|
||
| **[GitHub Actions](https://docs.npmjs.com/trusted-publishers#for-github-actions)**: | ||
|
|
||
| 1. Organization or user (required): Your GitHub username or organization name | ||
| 2. Repository (required): Your repository name | ||
| 3. Workflow filename (required): The filename of your workflow (e.g., publish.yml) | ||
| - Enter only the filename, not the full path | ||
| - Must include the .yml or .yaml extension | ||
| - The workflow file must exist in .github/workflows/ in your repository | ||
| 4. Environment name (optional): If using GitHub environments for deployment protection | ||
|
|
||
| **[GitLab CI/CD](https://docs.npmjs.com/trusted-publishers#for-gitlab-cicd)**: | ||
|
|
||
| 1. Namespace (required): Your GitLab username or group name | ||
| 2. Project name (required): Your project name | ||
| 3. Top-level CI file path (required): The path to your CI file (e.g., .gitlab-ci.yml) | ||
| - Must include the .yml extension | ||
| 4. Environment name (optional): If using GitLab environments | ||
|
|
||
| Once this configuration is complete, you can create a file at `.github/workflows/release.yml` with the following content. | ||
|
|
||
| ```yml | ||
| name: Release | ||
|
|
@@ -70,18 +91,24 @@ on: | |
|
|
||
| concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v3 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js 20.x | ||
| uses: actions/setup-node@v3 | ||
| - name: Setup Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20.x | ||
| node-version: 24 | ||
| registry-url: "https://registry.npmjs.org" | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn | ||
|
|
@@ -93,33 +120,16 @@ jobs: | |
| # This expects you to have a script called release which does a build for your packages and calls changeset publish | ||
| publish: yarn release | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: "" # https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868 | ||
| NPM_CONFIG_PROVENANCE: true | ||
|
|
||
| - name: Send a Slack notification if a publish happens | ||
| if: steps.changesets.outputs.published == 'true' | ||
| # You can do something when a publish happens. | ||
| run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!" | ||
| ``` | ||
|
|
||
| By default the GitHub Action creates a `.npmrc` file with the following content: | ||
|
|
||
| ``` | ||
| //registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN} | ||
| ``` | ||
|
|
||
| However, if a `.npmrc` file is found, the GitHub Action does not recreate the file. This is useful if you need to configure the `.npmrc` file on your own. | ||
| For example, you can add a step before running the Changesets GitHub Action: | ||
|
|
||
| ```yml | ||
| - name: Creating .npmrc | ||
| run: | | ||
| cat << EOF > "$HOME/.npmrc" | ||
| //registry.npmjs.org/:_authToken=$NPM_TOKEN | ||
| EOF | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| ``` | ||
|
|
||
| #### Custom Publishing | ||
|
|
||
| If you want to hook into when publishing should occur but have your own publishing functionality, you can utilize the `hasChangesets` output. | ||
|
|
@@ -140,12 +150,13 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v3 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js 20.x | ||
| uses: actions/setup-node@v3 | ||
| - name: Setup Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20.x | ||
| node-version: 24 | ||
| registry-url: "https://registry.npmjs.org" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this really should be the default, why do we want to call it out explicitly?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed with 842a27c |
||
|
|
||
| - name: Install Dependencies | ||
| run: yarn | ||
|
|
@@ -182,12 +193,13 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v3 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js 20.x | ||
| uses: actions/setup-node@v3 | ||
| - name: Setup Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20.x | ||
| node-version: 24 | ||
| registry-url: "https://registry.npmjs.org" | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should start recommending the latest versions -
actions/setup-node@v6is already availableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 842a27c