@anolilab/semantic-release-pnpm 8.0.0 → 8.1.1
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/CHANGELOG.md +16 -0
- package/README.md +26 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## @anolilab/semantic-release-pnpm [8.1.1](https://github.com/anolilab/semantic-release/compare/@anolilab/semantic-release-pnpm@8.1.0...@anolilab/semantic-release-pnpm@8.1.1) (2026-04-15)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **semantic-release-pnpm:** support pnpm v10 in prepare step ([f1dee76](https://github.com/anolilab/semantic-release/commit/f1dee765dc2278cecde34e85bc6d7096eeeba3d5))
|
|
6
|
+
|
|
7
|
+
## @anolilab/semantic-release-pnpm [8.1.0](https://github.com/anolilab/semantic-release/compare/@anolilab/semantic-release-pnpm@8.0.0...@anolilab/semantic-release-pnpm@8.1.0) (2026-04-08)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **semantic-release-pnpm:** add generic and CircleCI trusted publishing via NPM_ID_TOKEN ([c2aafd3](https://github.com/anolilab/semantic-release/commit/c2aafd301b45cdf5f92eef78ff0d461f7e0df0fb))
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **semantic-release-pnpm:** allow tarballDir option to be set to false ([a31e1d6](https://github.com/anolilab/semantic-release/commit/a31e1d64b2e8481a73700a3dff64233e14aab91d)), closes [#302](https://github.com/anolilab/semantic-release/issues/302)
|
|
16
|
+
|
|
1
17
|
## @anolilab/semantic-release-pnpm [8.0.0](https://github.com/anolilab/semantic-release/compare/@anolilab/semantic-release-pnpm@7.0.0...@anolilab/semantic-release-pnpm@8.0.0) (2026-04-08)
|
|
2
18
|
|
|
3
19
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -128,6 +128,28 @@ id_tokens:
|
|
|
128
128
|
|
|
129
129
|
See the [npm documentation for more details about configuring pipeline details](https://docs.npmjs.com/trusted-publishers#gitlab-cicd-configuration)
|
|
130
130
|
|
|
131
|
+
##### Trusted publishing for CircleCI
|
|
132
|
+
|
|
133
|
+
To use trusted publishing in [CircleCI](https://docs.npmjs.com/trusted-publishers#circleci-configuration) you need to set the environment variable `NPM_ID_TOKEN` to an NPM Identity Token:
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
jobs:
|
|
137
|
+
semantic-release:
|
|
138
|
+
steps:
|
|
139
|
+
# ...
|
|
140
|
+
- run:
|
|
141
|
+
name: Semantic Release with Trusted Publishing via OIDC
|
|
142
|
+
command: |
|
|
143
|
+
# Fetch the OIDC token with the correct audience for npm
|
|
144
|
+
export NPM_ID_TOKEN=$(circleci run oidc get --claims '{"aud": "npm:registry.npmjs.org"}')
|
|
145
|
+
# Run semantic release
|
|
146
|
+
npx semantic-release
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
##### Generic Trusted Publishing
|
|
150
|
+
|
|
151
|
+
The generic mechanism for trusted publishing is to set the `NPM_ID_TOKEN` environment variable to an OIDC identity token. This approach works with any CI platform that has implemented trusted publishing support with npm but does not have specific built-in support in this plugin. If token exchange fails, it will fall back to using token authentication.
|
|
152
|
+
|
|
131
153
|
##### Unsupported CI providers
|
|
132
154
|
|
|
133
155
|
Token authentication is **required** and can be set via [environment variables](#environment-variables).
|
|
@@ -158,9 +180,10 @@ Provenance applies specifically to publishing, so configure it under `publishCon
|
|
|
158
180
|
|
|
159
181
|
### Environment variables
|
|
160
182
|
|
|
161
|
-
| Variable
|
|
162
|
-
|
|
|
163
|
-
| `NPM_TOKEN`
|
|
183
|
+
| Variable | Description |
|
|
184
|
+
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
185
|
+
| `NPM_TOKEN` | Npm token created via [npm token create](https://docs.npmjs.com/getting-started/working_with_tokens#how-to-create-new-tokens) |
|
|
186
|
+
| `NPM_ID_TOKEN` | OIDC identity token for [trusted publishing](https://docs.npmjs.com/trusted-publishers). Must be configured in your CI job (see [GitLab](#trusted-publishing-for-gitlab-pipelines), [CircleCI](#trusted-publishing-for-circleci)). Takes priority over CI-specific token retrieval when set. |
|
|
164
187
|
|
|
165
188
|
### Options
|
|
166
189
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,12 +19,12 @@ const __cjs_getBuiltinModule = (module) => {
|
|
|
19
19
|
|
|
20
20
|
import dbg from 'debug';
|
|
21
21
|
import { execa } from 'execa';
|
|
22
|
-
import { validRange, gte } from 'semver';
|
|
23
|
-
import { isAccessibleSync, ensureFileSync, move, writeFile } from '@visulima/fs';
|
|
22
|
+
import { validRange, major, gte } from 'semver';
|
|
23
|
+
import { isAccessibleSync, ensureFileSync, isAccessible, readJson, writeJson, move, writeFile } from '@visulima/fs';
|
|
24
24
|
import { resolve } from '@visulima/path';
|
|
25
25
|
import { rc } from '@anolilab/rc';
|
|
26
26
|
import normalizeUrl from 'normalize-url';
|
|
27
|
-
import {
|
|
27
|
+
import { getPackageManagerVersion, findPackageJson } from '@visulima/package';
|
|
28
28
|
import SemanticReleaseError from '@semantic-release/error';
|
|
29
29
|
import { stringify } from 'ini';
|
|
30
30
|
import getAuthToken from 'registry-auth-token';
|
|
@@ -58,7 +58,6 @@ const getNpmrcPath = (cwd, environment) => {
|
|
|
58
58
|
|
|
59
59
|
const OFFICIAL_REGISTRY = "https://registry.npmjs.org/";
|
|
60
60
|
const GITHUB_ACTIONS_PROVIDER_NAME = "GitHub Actions";
|
|
61
|
-
const GITLAB_PIPELINES_PROVIDER_NAME = "GitLab CI/CD";
|
|
62
61
|
|
|
63
62
|
const debug$9 = dbg("semantic-release-pnpm:registry");
|
|
64
63
|
const getRegistryUrl = (scope, npmrc) => {
|
|
@@ -159,7 +158,11 @@ const debug$7 = dbg("semantic-release-pnpm:prepare");
|
|
|
159
158
|
const prepare$1 = async ({ pkgRoot, tarballDir }, { cwd, env, logger, nextRelease: { version }, stderr, stdout }) => {
|
|
160
159
|
const basePath = pkgRoot ? resolve(cwd, pkgRoot) : cwd;
|
|
161
160
|
logger.log("Write version %s to package.json in %s", version, basePath);
|
|
162
|
-
const
|
|
161
|
+
const pnpmVersion = getPackageManagerVersion("pnpm");
|
|
162
|
+
const pnpmMajor = major(pnpmVersion);
|
|
163
|
+
debug$7("Detected pnpm major version: %d", pnpmMajor);
|
|
164
|
+
const versionArguments = pnpmMajor >= 10 ? ["pkg", "set", `version=${version}`] : ["version", version, "--no-git-tag-version", "--allow-same-version"];
|
|
165
|
+
const versionResult = execa("pnpm", versionArguments, {
|
|
163
166
|
cwd: basePath,
|
|
164
167
|
env,
|
|
165
168
|
preferLocal: true
|
|
@@ -167,6 +170,15 @@ const prepare$1 = async ({ pkgRoot, tarballDir }, { cwd, env, logger, nextReleas
|
|
|
167
170
|
versionResult.stdout.pipe(stdout, { end: false });
|
|
168
171
|
versionResult.stderr.pipe(stderr, { end: false });
|
|
169
172
|
await versionResult;
|
|
173
|
+
if (pnpmMajor >= 10) {
|
|
174
|
+
const shrinkwrapPath = resolve(basePath, "npm-shrinkwrap.json");
|
|
175
|
+
if (await isAccessible(shrinkwrapPath)) {
|
|
176
|
+
debug$7(`Updating npm-shrinkwrap.json at ${shrinkwrapPath}`);
|
|
177
|
+
const shrinkwrap = await readJson(shrinkwrapPath);
|
|
178
|
+
shrinkwrap.version = version;
|
|
179
|
+
await writeJson(shrinkwrapPath, shrinkwrap, { indent: 2 });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
170
182
|
if (tarballDir) {
|
|
171
183
|
logger.log("Creating npm package version %s", version);
|
|
172
184
|
const packResult = execa("pnpm", ["pack", basePath], { cwd, env, preferLocal: true });
|
|
@@ -299,7 +311,7 @@ Your configuration for the \`publishBranch\` option is \`${String(publishBranch)
|
|
|
299
311
|
},
|
|
300
312
|
EINVALIDTARBALLDIR: ({ tarballDir }) => {
|
|
301
313
|
return {
|
|
302
|
-
details: `The [tarballDir option](${linkify("README.md#tarballdir")}) option, if defined, must be a \`String\`.
|
|
314
|
+
details: `The [tarballDir option](${linkify("README.md#tarballdir")}) option, if defined, must be a \`String\` or \`false\`.
|
|
303
315
|
Your configuration for the \`tarballDir\` option is \`${String(tarballDir)}\`.`,
|
|
304
316
|
message: "Invalid `tarballDir` option."
|
|
305
317
|
};
|
|
@@ -399,37 +411,27 @@ const exchangeGithubActionsToken = async (packageName, context) => {
|
|
|
399
411
|
}
|
|
400
412
|
return exchangeIdToken(idToken, packageName, context);
|
|
401
413
|
};
|
|
402
|
-
const exchangeGitlabPipelinesToken = async (packageName, context) => {
|
|
403
|
-
const idToken = process.env.NPM_ID_TOKEN;
|
|
404
|
-
debug$5("Verifying OIDC context for publishing from GitLab Pipelines");
|
|
405
|
-
if (!idToken) {
|
|
406
|
-
debug$5("NPM_ID_TOKEN environment variable is not set");
|
|
407
|
-
debug$5("Configure trusted publishing in your GitLab project settings and set the NPM_ID_TOKEN variable");
|
|
408
|
-
return void 0;
|
|
409
|
-
}
|
|
410
|
-
return exchangeIdToken(idToken, packageName, context);
|
|
411
|
-
};
|
|
412
414
|
const tokenExchange = (pkg, context) => {
|
|
413
415
|
if (!pkg.name || typeof pkg.name !== "string" || pkg.name.trim() === "") {
|
|
414
416
|
context.logger.error("Invalid package name provided for OIDC token exchange");
|
|
415
417
|
return Promise.resolve(void 0);
|
|
416
418
|
}
|
|
419
|
+
const idToken = process.env.NPM_ID_TOKEN;
|
|
420
|
+
if (idToken) {
|
|
421
|
+
debug$5("NPM_ID_TOKEN environment variable detected, using it for OIDC token exchange");
|
|
422
|
+
return exchangeIdToken(idToken, pkg.name, context);
|
|
423
|
+
}
|
|
417
424
|
const ciEnv = envCi();
|
|
418
425
|
const ciProviderName = typeof ciEnv.name === "string" ? ciEnv.name : void 0;
|
|
419
426
|
if (!ciProviderName) {
|
|
420
427
|
debug$5("Unable to detect CI provider for OIDC token exchange");
|
|
421
|
-
debug$5("Supported CI providers for OIDC trusted publishing: GitHub Actions, GitLab CI/CD");
|
|
422
428
|
return Promise.resolve(void 0);
|
|
423
429
|
}
|
|
424
430
|
debug$5(`Detected CI provider: ${ciProviderName}`);
|
|
425
431
|
if (GITHUB_ACTIONS_PROVIDER_NAME === ciProviderName) {
|
|
426
432
|
return exchangeGithubActionsToken(pkg.name, context);
|
|
427
433
|
}
|
|
428
|
-
|
|
429
|
-
return exchangeGitlabPipelinesToken(pkg.name, context);
|
|
430
|
-
}
|
|
431
|
-
debug$5(`CI provider "${ciProviderName}" is not supported for OIDC trusted publishing`);
|
|
432
|
-
debug$5("Supported CI providers: GitHub Actions, GitLab CI/CD");
|
|
434
|
+
debug$5(`CI provider "${ciProviderName}" does not have built-in OIDC support; set NPM_ID_TOKEN to use trusted publishing`);
|
|
433
435
|
return Promise.resolve(void 0);
|
|
434
436
|
};
|
|
435
437
|
|
|
@@ -685,7 +687,8 @@ const VALIDATORS = {
|
|
|
685
687
|
npmPublish: (value) => typeof value === "boolean",
|
|
686
688
|
pkgRoot: isNonEmptyString,
|
|
687
689
|
publishBranch: isNonEmptyString,
|
|
688
|
-
|
|
690
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
691
|
+
tarballDir: (value) => value === false || isNonEmptyString(value)
|
|
689
692
|
};
|
|
690
693
|
const verifyConfig = (config) => (
|
|
691
694
|
// eslint-disable-next-line unicorn/no-array-reduce
|