Skip to content
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

docs: Update documentation to reflect changesets publish expected environment variable #428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EduardoAC
Copy link

@EduardoAC EduardoAC commented Dec 4, 2024

Changelog

  • Documentation updated to assist with the usage of the action in combination with changesets publish

fixes changesets/changesets#942

Additional context

I wanted to add some background to this PR to provide better context for the reviewers to assist with the approval. The environment variable is defined by how NodeJS is set up within the GitHub Action Setup-node, which will automatically create a .npmrc file using this as an environment variable.

Therefore, the action expects us to use this variable over others, while if you decide to create your own .npmrc, we will be in control. As we can see on here. Hence the documentation updated to align with the previous steps above to align with the setup-node specifications mitigating potential issues when developer use the code given in the Readme

Copy link

changeset-bot bot commented Dec 4, 2024

⚠️ No Changeset found

Latest commit: d35d0f9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

@Fart10 Fart10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@hyunbinseo
Copy link

I personally had to add the registry-url for this to work:

Documentation

- uses: actions/setup-node@v4
  with:
    # Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, 
    # and set up auth to read in from env.NODE_AUTH_TOKEN.
    # Default: ''
    registry-url: ''

The error message:

🦋  error an error occurred while publishing create-svelte-kitty: ENEEDAUTH This command requires you to be logged in to https://registry.npmjs.org/ 
🦋  error You need to authorize this machine using `npm adduser`
🦋  error npm error code ENEEDAUTH
🦋  error npm error need auth This command requires you to be logged in to https://registry.npmjs.org/
🦋  error npm error need auth You need to authorize this machine using `npm adduser`
🦋  error npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2024-12-17T14_14_43_668Z-debug-0.log
🦋  error

and my setup: hyunbinseo/svelte-kitty@34a0e0a

steps:
  - uses: actions/checkout@v4
  - uses: pnpm/action-setup@v4
  - uses: actions/setup-node@v4
    with:
      node-version: 22
      registry-url: https://registry.npmjs.org # had to add this
      cache: pnpm
  - run: pnpm install
  - uses: changesets/action@v1
    with:
      publish: node --run ci:release
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

@EduardoAC
Copy link
Author

I personally had to add the registry-url for this to work:

Documentation

- uses: actions/setup-node@v4
  with:
    # Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, 
    # and set up auth to read in from env.NODE_AUTH_TOKEN.
    # Default: ''
    registry-url: ''

The error message:

🦋  error an error occurred while publishing create-svelte-kitty: ENEEDAUTH This command requires you to be logged in to https://registry.npmjs.org/ 
🦋  error You need to authorize this machine using `npm adduser`
🦋  error npm error code ENEEDAUTH
🦋  error npm error need auth This command requires you to be logged in to https://registry.npmjs.org/
🦋  error npm error need auth You need to authorize this machine using `npm adduser`
🦋  error npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2024-12-17T14_14_43_668Z-debug-0.log
🦋  error

and my setup: hyunbinseo/svelte-kitty@34a0e0a

steps:
  - uses: actions/checkout@v4
  - uses: pnpm/action-setup@v4
  - uses: actions/setup-node@v4
    with:
      node-version: 22
      registry-url: https://registry.npmjs.org # had to add this
      cache: pnpm
  - run: pnpm install
  - uses: changesets/action@v1
    with:
      publish: node --run ci:release
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Indeed, adding the registry-url in the GitHub Actions workflow is a valid approach, especially for ensuring the workflow works in CI/CD environments.

However, I prefer keeping the registry configuration in the package.json (e.g., under the publishConfig key), as it can simplify the configuration and make the project setup more portable.

This way, you avoid hardcoding it in the workflow and ensure the configuration is applied consistently across environments.

That said, both approaches are valid and situational. Just something to consider!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E404 Not Found
4 participants