You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -25,10 +25,23 @@ Publishing automates all the bumping and synchronizing of package versions in th
25
25
|`--registry`|`-r`|`'https://registry.npmjs.org'`| npm registry for publishing |
26
26
|`--retries`||`3`| number of retries for a package publish before failing |
27
27
|`--tag`|`-t`|`'latest'`| dist-tag for npm publishes |
28
-
|`--token`|`-n`||credential to use with npm commands (type is specified by `--auth-type`) - locally, use `npm login` instead, or see [alternatives for CI](../concepts/ci-integration)|
28
+
|`--token`|`-n`||Not recommended; see alternatives below|
29
29
|`--verbose`||`false`| prints additional information to the console |
30
30
|`--yes`|`-y`| if CI detected, `true`| skips the prompts for publish |
31
31
32
+
#### Providing a token
33
+
34
+
There are a few different ways to handle npm authentication for `beachball publish`.
35
+
36
+
In CI, you should use [trusted publishing](https://docs.npmjs.com/trusted-publishers) if supported to remove the need for tokens. Unfortunately this isn't available in Azure DevOps.
37
+
38
+
If trusted publishing is unavailable or you're running `beachball` locally, you can do any of the following:
39
+
40
+
- Set the `NPM_TOKEN` environment variable (`beachball` passes this through to `npm`)
41
+
- Run `npm login` first (or a task which does the same)
42
+
- Manually set the token in [`.npmrc`](https://docs.npmjs.com/cli/v11/configuring-npm/npmrc#auth-related-configuration), possibly referencing an environment variable
43
+
- Old way: use `--token <token>` on the command line (not recommended)
44
+
32
45
### Algorithm
33
46
34
47
The `publish` command is designed to run steps in an order that minimizes the chances of mid-publish failure by doing validation upfront.
Copy file name to clipboardExpand all lines: docs/concepts/ci-integration.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,19 @@ There are a couple of options here:
57
57
58
58
## Setting options for publishing
59
59
60
+
### Providing an npm token
61
+
62
+
As mentioned above, if possible you should use [trusted publishing](https://docs.npmjs.com/trusted-publishers) to remove the need for tokens.
63
+
64
+
Other options:
65
+
66
+
- Set the `NPM_TOKEN` environment variable while running `beachball`
67
+
- Run `npm login` first (or a task which does the same)
68
+
- Manually set the token in [`.npmrc`](https://docs.npmjs.com/cli/v11/configuring-npm/npmrc#auth-related-configuration), possibly referencing an environment variable
69
+
- Old way: use `--token <token>` on the command line (not recommended)
70
+
71
+
### Other options
72
+
60
73
If you're passing any custom options besides the npm token to `beachball publish`, it's recommended to set them in either the `beachball` config (if they don't interfere with other commands), or a `package.json` script (if specific to `publish`).
61
74
62
75
For example, the following script could be used for publishing public scoped packages (`access` is also safe to set in the beachball config):
@@ -152,10 +165,6 @@ This sample assumes the following:
152
165
- `REPO_PAT`: A GitHub fine-grained personal access token with write access ([as described above](#github-token))
153
166
- `NPM_TOKEN`: An npm token with write access to the package(s) and/or scope(s), such as a [fine-grained token for public npm](#npm-token)
154
167
- A repo root `package.json` script `release` which runs `beachball publish`
155
-
- A `.npmrc` file with the following content (change the registry if needed):
156
-
```txt
157
-
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
158
-
```
159
168
160
169
```yml
161
170
# Add trigger configuration of your choice (this one is manual only)
0 commit comments