@jsdevtools/npm-publish 4.1.0 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -41
- package/lib/action/core.d.ts +1 -1
- package/lib/action/core.js +2 -2
- package/lib/action/core.js.map +1 -1
- package/lib/format-publish-result.js +5 -4
- package/lib/format-publish-result.js.map +1 -1
- package/package.json +18 -18
- package/src/action/core.ts +2 -2
- package/src/format-publish-result.ts +3 -5
package/README.md
CHANGED
|
@@ -32,16 +32,14 @@ jobs:
|
|
|
32
32
|
contents: read
|
|
33
33
|
id-token: write
|
|
34
34
|
steps:
|
|
35
|
-
- uses: actions/checkout@
|
|
36
|
-
- uses: actions/setup-node@
|
|
35
|
+
- uses: actions/checkout@v6
|
|
36
|
+
- uses: actions/setup-node@v6
|
|
37
37
|
with:
|
|
38
38
|
node-version: "24"
|
|
39
39
|
registry-url: "https://registry.npmjs.org"
|
|
40
40
|
- run: npm ci
|
|
41
41
|
- run: npm test
|
|
42
|
-
- run: npm publish --
|
|
43
|
-
env:
|
|
44
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
42
|
+
- run: npm publish --ignore-scripts
|
|
45
43
|
```
|
|
46
44
|
|
|
47
45
|
See GitHub's [Node.js publishing][] guide and npm's [trusted publishing][] docs for more details and examples.
|
|
@@ -78,7 +76,7 @@ This package can be used three different ways:
|
|
|
78
76
|
|
|
79
77
|
## GitHub Action
|
|
80
78
|
|
|
81
|
-
To use the GitHub Action, you'll need to add it as a step in your [workflow file][]. By default, the only thing you need to do is set
|
|
79
|
+
To use the GitHub Action, you'll need to add it as a step in your [workflow file][]. By default, the only thing you need to do is set `permissions.id-token` to `write` to enable [trusted publishing][] via OIDC.
|
|
82
80
|
|
|
83
81
|
```yaml
|
|
84
82
|
on:
|
|
@@ -88,41 +86,27 @@ on:
|
|
|
88
86
|
jobs:
|
|
89
87
|
publish:
|
|
90
88
|
runs-on: ubuntu-latest
|
|
89
|
+
permissions:
|
|
90
|
+
contents: read
|
|
91
|
+
id-token: write
|
|
91
92
|
steps:
|
|
92
|
-
- uses: actions/checkout@
|
|
93
|
-
- uses: actions/setup-node@
|
|
93
|
+
- uses: actions/checkout@v6
|
|
94
|
+
- uses: actions/setup-node@v6
|
|
94
95
|
with:
|
|
95
96
|
node-version: "24"
|
|
96
97
|
- run: npm ci
|
|
97
98
|
- run: npm test
|
|
98
99
|
- uses: JS-DevTools/npm-publish@v4
|
|
99
|
-
with:
|
|
100
|
-
token: ${{ secrets.NPM_TOKEN }}
|
|
101
100
|
```
|
|
102
101
|
|
|
103
|
-
If you have [trusted publishing][] configured for your package and use `npm@>=11.5.1`, you can omit the `token` input and use OIDC instead.
|
|
104
|
-
|
|
105
102
|
> [!IMPORTANT]
|
|
106
|
-
> If you're publishing a private package, you will still need to provide a read-only `token` so the action can read existing versions from the registry before publish.
|
|
107
|
-
|
|
108
|
-
```diff
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
+ contents: read
|
|
114
|
-
+ id-token: write # required to use OIDC
|
|
115
|
-
steps:
|
|
116
|
-
- uses: actions/checkout@v5
|
|
117
|
-
- uses: actions/setup-node@v5
|
|
118
|
-
with:
|
|
119
|
-
node-version: "24" # includes npm@11.6.0
|
|
120
|
-
- run: npm ci
|
|
121
|
-
- run: npm test
|
|
122
|
-
- uses: JS-DevTools/npm-publish@v4
|
|
123
|
-
- with:
|
|
124
|
-
- token: ${{ secrets.NPM_TOKEN }}
|
|
125
|
-
```
|
|
103
|
+
> If you're publishing a private package with [trusted publishing][], you will still need to provide a read-only [`token`][npm authentication token] so the action can read existing versions from the registry before publish.
|
|
104
|
+
>
|
|
105
|
+
> ```diff
|
|
106
|
+
> - uses: JS-DevTools/npm-publish@v4
|
|
107
|
+
> + with:
|
|
108
|
+
> + token: ${{ secrets.NPM_TOKEN }}
|
|
109
|
+
> ```
|
|
126
110
|
|
|
127
111
|
You can also publish to third-party registries. For example, to publish to the [GitHub Package Registry][], set `token` to `secrets.GITHUB_TOKEN` and `registry` to `https://npm.pkg.github.com`:
|
|
128
112
|
|
|
@@ -138,8 +122,8 @@ jobs:
|
|
|
138
122
|
contents: read
|
|
139
123
|
packages: write # allow GITHUB_TOKEN to publish packages
|
|
140
124
|
steps:
|
|
141
|
-
- uses: actions/checkout@
|
|
142
|
-
- uses: actions/setup-node@
|
|
125
|
+
- uses: actions/checkout@v6
|
|
126
|
+
- uses: actions/setup-node@v6
|
|
143
127
|
with:
|
|
144
128
|
node-version: "24"
|
|
145
129
|
- run: npm ci
|
|
@@ -161,7 +145,7 @@ You can set any or all of the following input parameters using `with`:
|
|
|
161
145
|
|
|
162
146
|
| Name | Type | Default | Description |
|
|
163
147
|
| ---------------- | ---------------------- | ----------------------------- | -------------------------------------------------------------------------------- |
|
|
164
|
-
| `token` | string |
|
|
148
|
+
| `token` | string | None | Registry authentication token, not required if using [trusted publishing][]³ |
|
|
165
149
|
| `registry`¹ | string | `https://registry.npmjs.org/` | Registry URL to use. |
|
|
166
150
|
| `package` | string | Current working directory | Path to a package directory, a `package.json`, or a packed `.tgz` to publish. |
|
|
167
151
|
| `tag`¹ | string | `latest` | [Distribution tag][npm-tag] to publish to. |
|
|
@@ -187,8 +171,6 @@ npm-publish exposes several output variables, which you can use in later steps o
|
|
|
187
171
|
steps:
|
|
188
172
|
- uses: JS-DevTools/npm-publish@v4
|
|
189
173
|
+ id: publish
|
|
190
|
-
with:
|
|
191
|
-
token: ${{ secrets.NPM_TOKEN }}
|
|
192
174
|
|
|
193
175
|
+ - if: ${{ steps.publish.outputs.type }}
|
|
194
176
|
+ run: echo "Version changed!"
|
|
@@ -237,7 +219,7 @@ import type { Options } from "@jsdevtools/npm-publish";
|
|
|
237
219
|
|
|
238
220
|
| Name | Type | Default | Description |
|
|
239
221
|
| -------------------- | ---------------------- | ----------------------------- | -------------------------------------------------------------------------------- |
|
|
240
|
-
| `token` | string |
|
|
222
|
+
| `token` | string | None | Registry authentication token, not required if using [trusted publishing][]³ |
|
|
241
223
|
| `registry`¹ | string, `URL` | `https://registry.npmjs.org/` | Registry URL to use. |
|
|
242
224
|
| `package` | string | Current working directory | Path to a package directory, a `package.json`, or a packed `.tgz` to publish. |
|
|
243
225
|
| `tag`¹ | string | `latest` | [Distribution tag][npm-tag] to publish to. |
|
|
@@ -246,7 +228,7 @@ import type { Options } from "@jsdevtools/npm-publish";
|
|
|
246
228
|
| `strategy` | `all`, `upgrade` | `all` | Use `all` to publish all unique versions, `upgrade` for only semver upgrades. |
|
|
247
229
|
| `ignoreScripts` | boolean | `true` | Run `npm publish` with the `--ignore-scripts` flag as a security precaution. |
|
|
248
230
|
| `dryRun` | boolean | `false` | Run `npm publish` with the `--dry-run` flag to prevent publication. |
|
|
249
|
-
| `logger` | object |
|
|
231
|
+
| `logger` | object | None | Logging interface with `debug`, `info`, and `error` log methods. |
|
|
250
232
|
| `temporaryDirectory` | string | `os.tmpdir()` | Temporary directory to hold a generated `.npmrc` file |
|
|
251
233
|
|
|
252
234
|
1. May be specified using `publishConfig` in `package.json`.
|
|
@@ -395,7 +377,7 @@ The `check-version` and `greater-version-only` boolean options were replaced wit
|
|
|
395
377
|
`check-version: false` has been removed. If you only need to publish, without first checking whether the version exists in the registry, you can [use `npm` directly][publishing-nodejs-packages] instead:
|
|
396
378
|
|
|
397
379
|
```diff
|
|
398
|
-
- uses: actions/setup-node@
|
|
380
|
+
- uses: actions/setup-node@v6
|
|
399
381
|
with:
|
|
400
382
|
node-version: '24'
|
|
401
383
|
+ registry-url: https://registry.npmjs.org/
|
|
@@ -447,7 +429,7 @@ If you can't change your build, you can set the `ignore-scripts` input to `false
|
|
|
447
429
|
The global `.npmrc` file is no longer read nor modified. This means the `token` option is now required for the library and CLI. (It was already required for the action.) You may have workarounds in place referencing `INPUT_TOKEN`, which v1 [erroneously wrote][#15] to `.npmrc`. These workarounds should be removed.
|
|
448
430
|
|
|
449
431
|
```diff
|
|
450
|
-
- uses: actions/setup-node@
|
|
432
|
+
- uses: actions/setup-node@v6
|
|
451
433
|
with:
|
|
452
434
|
node-version: '24'
|
|
453
435
|
registry-url: https://registry.npmjs.org/
|
package/lib/action/core.d.ts
CHANGED
package/lib/action/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** Wrapper module for
|
|
1
|
+
/** Wrapper module for `@actions/core` */
|
|
2
2
|
import { debug as ghLogDebug, error as ghLogError, getInput as ghGetInput, info as ghLogInfo, setFailed as ghSetFailed, setOutput as ghSetOutput, setSecret as ghSetSecret, } from "@actions/core";
|
|
3
|
-
/** Logger using the methods from
|
|
3
|
+
/** Logger using the methods from `@actions/core`. */
|
|
4
4
|
export const logger = {
|
|
5
5
|
debug: ghLogDebug,
|
|
6
6
|
info: ghLogInfo,
|
package/lib/action/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/action/core.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/action/core.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EACL,KAAK,IAAI,UAAU,EACnB,KAAK,IAAI,UAAU,EACnB,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,SAAS,EACjB,SAAS,IAAI,WAAW,EACxB,SAAS,IAAI,WAAW,EACxB,SAAS,IAAI,WAAW,GACzB,MAAM,eAAe,CAAC;AAIvB,qDAAqD;AACrD,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,WAAW,EAAE,CAAC;QAChB,WAAW,CAAC,WAAW,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAEnD,IAAI,WAAW,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,WAAW,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,WAAW,CAAC,KAAc,CAAC,CAAC;AAC9B,CAAC;AAuBD,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,KAAmC,EACnC,YAA+B;IAE/B,WAAW,CAAC,IAAI,EAAE,KAAK,IAAI,YAAY,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -10,10 +10,11 @@ const CONTENTS_BANNER = "=== Contents ===";
|
|
|
10
10
|
* @returns Formatted string.
|
|
11
11
|
*/
|
|
12
12
|
export function formatPublishResult(manifest, options, result) {
|
|
13
|
-
const lines = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const lines = [
|
|
14
|
+
result.id === undefined
|
|
15
|
+
? `🙅♀️ ${manifest.name}@${manifest.version} already published.`
|
|
16
|
+
: `📦 ${result.id}`,
|
|
17
|
+
];
|
|
17
18
|
if (result.files.length > 0) {
|
|
18
19
|
lines.push("", CONTENTS_BANNER);
|
|
19
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-publish-result.js","sourceRoot":"","sources":["../src/format-publish-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAMzB,MAAM,cAAc,GAClB,iEAAiE,CAAC;AAEpE,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAyB,EACzB,OAA0B,EAC1B,MAAqB;IAErB,MAAM,KAAK,GAAG
|
|
1
|
+
{"version":3,"file":"format-publish-result.js","sourceRoot":"","sources":["../src/format-publish-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAMzB,MAAM,cAAc,GAClB,iEAAiE,CAAC;AAEpE,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAyB,EACzB,OAA0B,EAC1B,MAAqB;IAErB,MAAM,KAAK,GAAG;QACZ,MAAM,CAAC,EAAE,KAAK,SAAS;YACrB,CAAC,CAAC,SAAS,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,qBAAqB;YACjE,CAAC,CAAC,MAAM,MAAM,CAAC,EAAE,EAAE;KACtB,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1C,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,CACL,OAAO,CAAC,MAAM,CAAC,KAAK;QAClB,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,cAAc,CAAC;QACpD,CAAC,CAAC,KAAK,CACV,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE;IAC1C,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;QAChB,OAAO,GAAG,IAAI,IAAI,CAAC;IACrB,CAAC;IACD,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1C,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/C,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsdevtools/npm-publish",
|
|
3
3
|
"description": "Fast, easy publishing to NPM",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github-action",
|
|
7
7
|
"npm",
|
|
@@ -52,32 +52,32 @@
|
|
|
52
52
|
"provenance": true
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@actions/core": "^
|
|
56
|
-
"@mcous/eslint-config": "^0.
|
|
55
|
+
"@actions/core": "^2.0.1",
|
|
56
|
+
"@mcous/eslint-config": "^0.8.0",
|
|
57
57
|
"@mcous/prettier-config": "^0.4.0",
|
|
58
58
|
"@mcous/typescript-config": "^0.3.0",
|
|
59
59
|
"@types/command-line-args": "^5.2.3",
|
|
60
|
-
"@types/node": "^
|
|
60
|
+
"@types/node": "^25.0.3",
|
|
61
61
|
"@types/validate-npm-package-name": "^4.0.2",
|
|
62
|
-
"@vitest/coverage-v8": "^
|
|
62
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
63
63
|
"concurrently": "^9.2.1",
|
|
64
|
-
"eslint": "^9.
|
|
65
|
-
"eslint-plugin-jsdoc": "^
|
|
66
|
-
"globals": "^
|
|
67
|
-
"prettier": "^3.
|
|
68
|
-
"prettier-plugin-jsdoc": "^1.
|
|
69
|
-
"rimraf": "^6.
|
|
70
|
-
"rolldown": "1.0.0-beta.
|
|
64
|
+
"eslint": "^9.39.2",
|
|
65
|
+
"eslint-plugin-jsdoc": "^61.5.0",
|
|
66
|
+
"globals": "^17.0.0",
|
|
67
|
+
"prettier": "^3.7.4",
|
|
68
|
+
"prettier-plugin-jsdoc": "^1.8.0",
|
|
69
|
+
"rimraf": "^6.1.2",
|
|
70
|
+
"rolldown": "1.0.0-beta.58",
|
|
71
71
|
"typescript": "^5.9.2",
|
|
72
|
-
"vitest": "^
|
|
73
|
-
"vitest-when": "^0.
|
|
72
|
+
"vitest": "^4.0.16",
|
|
73
|
+
"vitest-when": "^0.10.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@types/semver": "^7.7.1",
|
|
77
77
|
"command-line-args": "6.0.1",
|
|
78
|
-
"semver": "7.7.
|
|
79
|
-
"tar": "7.
|
|
80
|
-
"validate-npm-package-name": "^
|
|
78
|
+
"semver": "7.7.3",
|
|
79
|
+
"tar": "7.5.2",
|
|
80
|
+
"validate-npm-package-name": "^7.0.1"
|
|
81
81
|
},
|
|
82
|
-
"packageManager": "pnpm@10.
|
|
82
|
+
"packageManager": "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
83
83
|
}
|
package/src/action/core.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Wrapper module for
|
|
1
|
+
/** Wrapper module for `@actions/core` */
|
|
2
2
|
import {
|
|
3
3
|
debug as ghLogDebug,
|
|
4
4
|
error as ghLogError,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import type { Logger } from "../options.js";
|
|
13
13
|
|
|
14
|
-
/** Logger using the methods from
|
|
14
|
+
/** Logger using the methods from `@actions/core`. */
|
|
15
15
|
export const logger: Logger = {
|
|
16
16
|
debug: ghLogDebug,
|
|
17
17
|
info: ghLogInfo,
|
|
@@ -22,13 +22,11 @@ export function formatPublishResult(
|
|
|
22
22
|
options: NormalizedOptions,
|
|
23
23
|
result: PublishResult
|
|
24
24
|
): string {
|
|
25
|
-
const lines = [
|
|
26
|
-
|
|
27
|
-
lines.push(
|
|
25
|
+
const lines = [
|
|
28
26
|
result.id === undefined
|
|
29
27
|
? `🙅♀️ ${manifest.name}@${manifest.version} already published.`
|
|
30
|
-
: `📦 ${result.id}
|
|
31
|
-
|
|
28
|
+
: `📦 ${result.id}`,
|
|
29
|
+
];
|
|
32
30
|
|
|
33
31
|
if (result.files.length > 0) {
|
|
34
32
|
lines.push("", CONTENTS_BANNER);
|