semantic-release 25.0.2 → 25.0.4

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 CHANGED
@@ -30,6 +30,13 @@
30
30
 
31
31
  This removes the immediate connection between human emotions and version numbers, strictly following the [Semantic Versioning](http://semver.org) specification and communicating the **impact** of changes to consumers.
32
32
 
33
+ ## Core Engine
34
+
35
+ `semantic-release` now uses [`@semantic-release/core`](https://github.com/semantic-release/core) as its release engine.
36
+ For existing users, behavior stays the same: the `semantic-release` CLI, default plugin profile, and current configuration model remain backward compatible.
37
+
38
+ If you want to build a custom CLI or compose your own plugin stack directly, use `@semantic-release/core`.
39
+
33
40
  > Trust us, this will change your workflow for the better. – [egghead.io](https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-automating-releases-with-semantic-release)
34
41
 
35
42
  ## Highlights
@@ -139,7 +146,6 @@ In order to use **semantic-release** you need:
139
146
 
140
147
  - [GitHub Discussions](https://github.com/semantic-release/semantic-release/discussions)
141
148
  - [Stack Overflow](https://stackoverflow.com/questions/tagged/semantic-release)
142
- - [Twitter](https://twitter.com/SemanticRelease)
143
149
 
144
150
  ## Badge
145
151
 
@@ -225,3 +225,9 @@
225
225
  - `verifyConditions`: Verify that all needed configuration is present.
226
226
  - `prepare`: Convert different types of CurseForge game versions to their corresponding IDs.
227
227
  - `publish`: Publish the Minecraft project to CurseForge and Modrinth.
228
+ - [semantic-release-jira-fixversion](https://github.com/danbka33/semantic-release-jira-fixversion)
229
+ - `verifyConditions`: Verify Jira Server/Data Center connectivity, authentication, and plugin configuration.
230
+ - `success`: Create or reuse Jira Versions for affected projects, update `fixVersions`, add release comments to referenced issues, and transition them to the configured workflow state.
231
+ - [semantic-release-linear-issue-status](https://github.com/noahlaux/semantic-release-linear-issue-status)
232
+ - `verifyConditions`: Verify the presence of the `LINEAR_API_KEY` environment variable and required configuration options (`teamKey`, `issuePrefixes`).
233
+ - `success`: Move linked [Linear](https://linear.app) issues to a completed workflow state after a successful release, based on issue identifiers found in release commits.
@@ -21,6 +21,27 @@ This is because npm's Trusted Publisher mechanism authorizes the workflow that i
21
21
  Before trusted publishing was available, generating provenance attestations required configuring your project to enable publishing with provenance.
22
22
  With trusted publishing, npm provenance is automatically generated for packages published to npm from GitHub Actions without any additional configuration.
23
23
 
24
+ ## Important: Avoid `registry-url` in `setup-node`
25
+
26
+ **Do not** set the `registry-url` option in the `actions/setup-node` step when using semantic-release for npm publishing. The `registry-url` option causes `setup-node` to create an `.npmrc` file that can conflict with semantic-release's npm authentication mechanism, leading to `EINVALIDNPMTOKEN` errors even when your token is valid.
27
+
28
+ ```yaml
29
+ # ❌ Don't do this - can cause conflicts with semantic-release
30
+ - name: Setup Node.js
31
+ uses: actions/setup-node@v4
32
+ with:
33
+ node-version: "lts/*"
34
+ registry-url: "https://registry.npmjs.org"
35
+
36
+ # ✅ Do this instead - let semantic-release handle npm authentication
37
+ - name: Setup Node.js
38
+ uses: actions/setup-node@v4
39
+ with:
40
+ node-version: "lts/*"
41
+ ```
42
+
43
+ If you need to specify a custom registry, configure it in your project's `.npmrc` file instead. This ensures consistent behavior between local development and CI environments, and avoids conflicts with semantic-release.
44
+
24
45
  ## Node project configuration
25
46
 
26
47
  [GitHub Actions](https://github.com/features/actions) support [Workflows](https://help.github.com/en/articles/configuring-workflows), allowing to run tests on multiple Node versions and publish a release only when all test pass.
@@ -113,10 +134,3 @@ To trigger a release, call (with a [Personal Access Tokens](https://help.github.
113
134
  ```
114
135
  $ curl -v -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/[org-name-or-username]/[repository]/dispatches -d '{ "event_type": "semantic-release" }'
115
136
  ```
116
-
117
- ### Using 3rd party apps:
118
-
119
- If you'd like to use a GitHub app to manage this instead of creating a personal access token, you could consider using a project like:
120
-
121
- - [Actions Panel](https://www.actionspanel.app/) - A declaratively configured way for triggering GitHub Actions
122
- - [Action Button](https://github-action-button.web.app/#details) - A simple badge based mechanism for triggering GitHub Actions
package/index.js CHANGED
@@ -1,50 +1,23 @@
1
- import { createRequire } from "node:module";
2
- import { pick } from "lodash-es";
3
- import * as marked from "marked";
4
- import envCi from "env-ci";
5
- import { hookStd } from "hook-std";
6
- import semver from "semver";
7
- import AggregateError from "aggregate-error";
8
- import hideSensitive from "./lib/hide-sensitive.js";
9
- import getConfig from "./lib/get-config.js";
10
- import verify from "./lib/verify.js";
11
- import getNextVersion from "./lib/get-next-version.js";
12
- import getCommits from "./lib/get-commits.js";
13
- import getLastRelease from "./lib/get-last-release.js";
14
- import getReleaseToAdd from "./lib/get-release-to-add.js";
15
- import { extractErrors, makeTag } from "./lib/utils.js";
16
- import getGitAuthUrl from "./lib/get-git-auth-url.js";
17
- import getBranches from "./lib/branches/index.js";
18
- import getLogger from "./lib/get-logger.js";
19
- import { addNote, getGitHead, getTagHead, isBranchUpToDate, push, pushNotes, tag, verifyAuth } from "./lib/git.js";
20
- import getError from "./lib/get-error.js";
21
- import { COMMIT_EMAIL, COMMIT_NAME } from "./lib/definitions/constants.js";
1
+ import semanticReleaseCore, { resolveConfig, getLogger, resolveEnvCi } from "@semantic-release/core";
2
+ import { COMMIT_EMAIL, COMMIT_NAME, SEMANTIC_RELEASE_DEFAULT_CONFIG } from "./lib/definitions/constants.js";
22
3
 
23
- const require = createRequire(import.meta.url);
24
- const pkg = require("./package.json");
4
+ import pkg from "./package.json" with { type: "json" };
25
5
 
26
- let markedOptionsSet = false;
27
- async function terminalOutput(text) {
28
- if (!markedOptionsSet) {
29
- const { default: TerminalRenderer } = await import("marked-terminal"); // eslint-disable-line node/no-unsupported-features/es-syntax
30
- marked.setOptions({ renderer: new TerminalRenderer() });
31
- markedOptionsSet = true;
32
- }
33
-
34
- return marked.parse(text);
35
- }
36
-
37
- /* eslint complexity: off */
38
- async function run(context, plugins) {
39
- const { cwd, env, options, logger, envCi } = context;
40
- const { isCi, branch, prBranch, isPr } = envCi;
6
+ export default async (
7
+ cliOptions = {},
8
+ { cwd = process.cwd(), env = process.env, stdout = process.stdout, stderr = process.stderr } = {}
9
+ ) => {
10
+ const envCiResult = resolveEnvCi({ env, cwd });
11
+ const { isCi, branch, prBranch, isPr } = envCiResult;
41
12
  const ciBranch = isPr ? prBranch : branch;
13
+ const noCi = Boolean(cliOptions.noCi || cliOptions.ci === false);
14
+
15
+ const shouldAutoDryRun = !isCi && !cliOptions.dryRun && !noCi;
16
+ const effectiveCliOptions = shouldAutoDryRun ? { ...cliOptions, dryRun: true } : cliOptions;
17
+ const shouldSkipRelease = isCi && isPr && !noCi;
42
18
 
43
- if (!isCi && !options.dryRun && !options.noCi) {
44
- logger.warn("This run was not triggered in a known CI environment, running in dry-run mode.");
45
- options.dryRun = true;
46
- } else {
47
- // When running on CI, set the commits author and committer info and prevent the `git` CLI to prompt for username/password. See #703.
19
+ if (!shouldAutoDryRun) {
20
+ // Preserve git non-interactive behavior and bot identity outside of the auto dry-run path.
48
21
  Object.assign(env, {
49
22
  GIT_AUTHOR_NAME: COMMIT_NAME,
50
23
  GIT_AUTHOR_EMAIL: COMMIT_EMAIL,
@@ -56,235 +29,34 @@ async function run(context, plugins) {
56
29
  });
57
30
  }
58
31
 
59
- if (isCi && isPr && !options.noCi) {
60
- logger.log("This run was triggered by a pull request and therefore a new version won't be published.");
61
- return false;
62
- }
63
-
64
- // Verify config
65
- await verify(context);
66
-
67
- options.repositoryUrl = await getGitAuthUrl({ ...context, branch: { name: ciBranch } });
68
- context.branches = await getBranches(options.repositoryUrl, ciBranch, context);
69
- context.branch = context.branches.find(({ name }) => name === ciBranch);
70
-
71
- if (!context.branch) {
72
- logger.log(
73
- `This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${context.branches
74
- .map(({ name }) => name)
75
- .join(", ")}, therefore a new version won’t be published.`
76
- );
77
- return false;
78
- }
79
-
80
- logger[options.dryRun ? "warn" : "success"](
81
- `Run automated release from branch ${ciBranch} on repository ${options.originalRepositoryURL}${
82
- options.dryRun ? " in dry-run mode" : ""
83
- }`
84
- );
85
-
86
- try {
87
- try {
88
- await verifyAuth(options.repositoryUrl, context.branch.name, { cwd, env });
89
- } catch (error) {
90
- if (!(await isBranchUpToDate(options.repositoryUrl, context.branch.name, { cwd, env }))) {
91
- logger.log(
92
- `The local branch ${context.branch.name} is behind the remote one, therefore a new version won't be published.`
93
- );
94
- return false;
95
- }
96
-
97
- throw error;
98
- }
99
- } catch (error) {
100
- logger.error(`The command "${error.command}" failed with the error message ${error.stderr}.`);
101
- throw getError("EGITNOPERMISSION", context);
102
- }
103
-
104
- logger.success(`Allowed to push to the Git repository`);
105
-
106
- await plugins.verifyConditions(context);
107
-
108
- const errors = [];
109
- context.releases = [];
110
- const releaseToAdd = getReleaseToAdd(context);
111
-
112
- if (releaseToAdd) {
113
- const { lastRelease, currentRelease, nextRelease } = releaseToAdd;
114
-
115
- nextRelease.gitHead = await getTagHead(nextRelease.gitHead, { cwd, env });
116
- currentRelease.gitHead = await getTagHead(currentRelease.gitHead, { cwd, env });
117
- if (context.branch.mergeRange && !semver.satisfies(nextRelease.version, context.branch.mergeRange)) {
118
- errors.push(getError("EINVALIDMAINTENANCEMERGE", { ...context, nextRelease }));
119
- } else {
120
- const commits = await getCommits({ ...context, lastRelease, nextRelease });
121
- nextRelease.notes = await plugins.generateNotes({ ...context, commits, lastRelease, nextRelease });
122
-
123
- if (options.dryRun) {
124
- logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`);
125
- } else {
126
- await addNote({ channels: [...currentRelease.channels, nextRelease.channel] }, nextRelease.gitTag, {
127
- cwd,
128
- env,
129
- });
130
- await push(options.repositoryUrl, { cwd, env });
131
- await pushNotes(options.repositoryUrl, nextRelease.gitTag, {
132
- cwd,
133
- env,
134
- });
135
- logger.success(
136
- `Add ${nextRelease.channel ? `channel ${nextRelease.channel}` : "default channel"} to tag ${
137
- nextRelease.gitTag
138
- }`
139
- );
140
- }
141
-
142
- context.branch.tags.push({
143
- version: nextRelease.version,
144
- channel: nextRelease.channel,
145
- gitTag: nextRelease.gitTag,
146
- gitHead: nextRelease.gitHead,
147
- });
148
-
149
- const releases = await plugins.addChannel({ ...context, commits, lastRelease, currentRelease, nextRelease });
150
- context.releases.push(...releases);
151
- await plugins.success({ ...context, lastRelease, commits, nextRelease, releases });
152
- }
153
- }
154
-
155
- if (errors.length > 0) {
156
- throw new AggregateError(errors);
157
- }
158
-
159
- context.lastRelease = getLastRelease(context);
160
- if (context.lastRelease.gitHead) {
161
- context.lastRelease.gitHead = await getTagHead(context.lastRelease.gitHead, { cwd, env });
162
- }
163
-
164
- if (context.lastRelease.gitTag) {
165
- logger.log(
166
- `Found git tag ${context.lastRelease.gitTag} associated with version ${context.lastRelease.version} on branch ${context.branch.name}`
167
- );
168
- } else {
169
- logger.log(`No git tag version found on branch ${context.branch.name}`);
170
- }
171
-
172
- context.commits = await getCommits(context);
173
-
174
- const nextRelease = {
175
- type: await plugins.analyzeCommits(context),
176
- channel: context.branch.channel || null,
177
- gitHead: await getGitHead({ cwd, env }),
32
+ const context = {
33
+ cwd,
34
+ env,
35
+ stdout,
36
+ stderr,
37
+ envCi: envCiResult,
178
38
  };
179
- if (!nextRelease.type) {
180
- logger.log("There are no relevant changes, so no new version is released.");
181
- return context.releases.length > 0 ? { releases: context.releases } : false;
182
- }
183
-
184
- context.nextRelease = nextRelease;
185
- nextRelease.version = getNextVersion(context);
186
- nextRelease.gitTag = makeTag(options.tagFormat, nextRelease.version);
187
- nextRelease.name = nextRelease.gitTag;
188
39
 
189
- if (context.branch.type !== "prerelease" && !semver.satisfies(nextRelease.version, context.branch.range)) {
190
- throw getError("EINVALIDNEXTVERSION", {
191
- ...context,
192
- validBranches: context.branches.filter(
193
- ({ type, accept }) => type !== "prerelease" && accept.includes(nextRelease.type)
194
- ),
195
- });
196
- }
197
-
198
- await plugins.verifyRelease(context);
199
-
200
- nextRelease.notes = await plugins.generateNotes(context);
201
-
202
- await plugins.prepare(context);
40
+ context.logger = getLogger(context);
203
41
 
204
- if (options.dryRun) {
205
- logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`);
206
- } else {
207
- // Create the tag before calling the publish plugins as some require the tag to exists
208
- await tag(nextRelease.gitTag, nextRelease.gitHead, { cwd, env });
209
- await addNote({ channels: [nextRelease.channel] }, nextRelease.gitTag, { cwd, env });
210
- await push(options.repositoryUrl, { cwd, env });
211
- await pushNotes(options.repositoryUrl, nextRelease.gitTag, { cwd, env });
212
- logger.success(`Created tag ${nextRelease.gitTag}`);
42
+ context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
43
+ if (shouldAutoDryRun) {
44
+ context.logger.warn("This run was not triggered in a known CI environment, running in dry-run mode.");
213
45
  }
214
46
 
215
- const releases = await plugins.publish(context);
216
- context.releases.push(...releases);
217
-
218
- await plugins.success({ ...context, releases });
219
-
220
- logger.success(
221
- `Published release ${nextRelease.version} on ${nextRelease.channel ? nextRelease.channel : "default"} channel`
222
- );
223
-
224
- if (options.dryRun) {
225
- logger.log(`Release note for version ${nextRelease.version}:`);
226
- if (nextRelease.notes) {
227
- context.stdout.write(await terminalOutput(nextRelease.notes));
228
- }
47
+ if (shouldSkipRelease) {
48
+ context.logger.log("This run was triggered by a pull request and therefore a new version won't be published.");
49
+ return false;
229
50
  }
230
51
 
231
- return pick(context, ["lastRelease", "commits", "nextRelease", "releases"]);
232
- }
52
+ const { options: resolvedOptions, plugins } = await resolveConfig(context, effectiveCliOptions, {
53
+ baseConfig: SEMANTIC_RELEASE_DEFAULT_CONFIG,
54
+ buildPlugins: true,
55
+ });
56
+ resolvedOptions.originalRepositoryURL = resolvedOptions.repositoryUrl;
57
+ context.options = resolvedOptions;
233
58
 
234
- async function logErrors({ logger, stderr }, err) {
235
- const errors = extractErrors(err).sort((error) => (error.semanticRelease ? -1 : 0));
236
- for (const error of errors) {
237
- if (error.semanticRelease) {
238
- logger.error(`${error.code} ${error.message}`);
239
- if (error.details) {
240
- stderr.write(await terminalOutput(error.details)); // eslint-disable-line no-await-in-loop
241
- }
242
- } else {
243
- logger.error("An error occurred while running semantic-release: %O", error);
244
- }
245
- }
246
- }
247
-
248
- async function callFail(context, plugins, err) {
249
- const errors = extractErrors(err).filter((err) => err.semanticRelease);
250
- if (errors.length > 0) {
251
- try {
252
- await plugins.fail({ ...context, errors });
253
- } catch (error) {
254
- await logErrors(context, error);
255
- }
256
- }
257
- }
59
+ const result = await semanticReleaseCore({ context, plugins });
258
60
 
259
- export default async (cliOptions = {}, { cwd = process.cwd(), env = process.env, stdout, stderr } = {}) => {
260
- const { unhook } = hookStd(
261
- { silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean) },
262
- hideSensitive(env)
263
- );
264
- const context = {
265
- cwd,
266
- env,
267
- stdout: stdout || process.stdout,
268
- stderr: stderr || process.stderr,
269
- envCi: envCi({ env, cwd }),
270
- };
271
- context.logger = getLogger(context);
272
- context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
273
- try {
274
- const { plugins, options } = await getConfig(context, cliOptions);
275
- options.originalRepositoryURL = options.repositoryUrl;
276
- context.options = options;
277
- try {
278
- const result = await run(context, plugins);
279
- unhook();
280
- return result;
281
- } catch (error) {
282
- await callFail(context, plugins, error);
283
- throw error;
284
- }
285
- } catch (error) {
286
- await logErrors(context, error);
287
- unhook();
288
- throw error;
289
- }
61
+ return result;
290
62
  };
@@ -1,17 +1,18 @@
1
- export const RELEASE_TYPE = ["patch", "minor", "major"];
2
-
3
- export const FIRST_RELEASE = "1.0.0";
4
-
5
- export const FIRSTPRERELEASE = "1";
6
-
7
1
  export const COMMIT_NAME = "semantic-release-bot";
8
2
 
9
3
  export const COMMIT_EMAIL = "semantic-release-bot@martynus.net";
10
4
 
11
- export const RELEASE_NOTES_SEPARATOR = "\n\n";
12
-
13
5
  export const SECRET_REPLACEMENT = "[secure]";
14
6
 
15
7
  export const SECRET_MIN_SIZE = 5;
16
8
 
17
9
  export const GIT_NOTE_REF = "semantic-release";
10
+
11
+ export const SEMANTIC_RELEASE_DEFAULT_CONFIG = {
12
+ plugins: [
13
+ "@semantic-release/commit-analyzer",
14
+ "@semantic-release/release-notes-generator",
15
+ "@semantic-release/npm",
16
+ "@semantic-release/github",
17
+ ],
18
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "semantic-release",
3
3
  "description": "Automated semver compliant package publishing",
4
- "version": "25.0.2",
4
+ "version": "25.0.4",
5
5
  "type": "module",
6
6
  "author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
7
7
  "ava": {
@@ -53,33 +53,32 @@
53
53
  "read-package-up": "^12.0.0",
54
54
  "resolve-from": "^5.0.0",
55
55
  "semver": "^7.3.2",
56
- "semver-diff": "^5.0.0",
57
56
  "signale": "^1.2.1",
58
57
  "yargs": "^18.0.0"
59
58
  },
60
59
  "devDependencies": {
61
- "@types/node": "24.10.0",
60
+ "@types/node": "24.12.4",
62
61
  "@types/signale": "1.4.7",
63
- "ava": "6.4.1",
64
- "c8": "10.1.3",
65
- "clear-module": "4.1.2",
62
+ "ava": "8.0.1",
63
+ "c8": "11.0.0",
64
+ "clear-module": "4.1.3",
66
65
  "cz-conventional-changelog": "3.3.0",
67
- "dockerode": "4.0.9",
66
+ "dockerode": "5.0.0",
68
67
  "file-url": "4.0.0",
69
- "fs-extra": "11.3.2",
70
- "got": "14.6.2",
71
- "js-yaml": "4.1.0",
72
- "lockfile-lint": "4.14.1",
73
- "ls-engines": "0.9.3",
74
- "mockserver-client": "5.15.0",
75
- "nock": "14.0.10",
76
- "npm-run-all2": "8.0.4",
77
- "p-retry": "7.1.0",
78
- "prettier": "3.6.2",
79
- "publint": "0.3.15",
80
- "sinon": "21.0.0",
68
+ "fs-extra": "11.3.5",
69
+ "got": "15.0.5",
70
+ "js-yaml": "4.1.1",
71
+ "lockfile-lint": "5.0.0",
72
+ "ls-engines": "0.10.0",
73
+ "mockserver-client": "6.1.0",
74
+ "nock": "14.0.15",
75
+ "npm-run-all2": "9.0.1",
76
+ "p-retry": "8.0.0",
77
+ "prettier": "3.8.3",
78
+ "publint": "0.3.21",
79
+ "sinon": "22.0.0",
81
80
  "stream-buffers": "3.0.3",
82
- "tempy": "3.1.0",
81
+ "tempy": "3.2.0",
83
82
  "testdouble": "3.20.2"
84
83
  },
85
84
  "engines": {
@@ -163,5 +162,5 @@
163
162
  "github>semantic-release/.github:renovate-config"
164
163
  ]
165
164
  },
166
- "packageManager": "npm@11.4.2"
165
+ "packageManager": "npm@11.15.0+sha512.fa4d2d93b9519e93143e70bb913b94ff2ad5fe69c5a0f84943be557cbb59e9fc1bcce55768fb1313f225f4f9f50c78b8f366f2332aa41effd7b10efa98d8d72f"
167
166
  }
@@ -1,18 +0,0 @@
1
- import { isString, mapValues, omit, remove, template } from "lodash-es";
2
- import micromatch from "micromatch";
3
- import { getBranches } from "../git.js";
4
-
5
- export default async (repositoryUrl, { cwd }, branches) => {
6
- const gitBranches = await getBranches(repositoryUrl, { cwd });
7
-
8
- return branches.reduce(
9
- (branches, branch) => [
10
- ...branches,
11
- ...remove(gitBranches, (name) => micromatch(gitBranches, branch.name).includes(name)).map((name) => ({
12
- name,
13
- ...mapValues(omit(branch, "name"), (value) => (isString(value) ? template(value)({ name }) : value)),
14
- })),
15
- ],
16
- []
17
- );
18
- };
@@ -1,39 +0,0 @@
1
- import { escapeRegExp, template } from "lodash-es";
2
- import semver from "semver";
3
- import pReduce from "p-reduce";
4
- import debugTags from "debug";
5
- import { getTags, getTagsNotes } from "../../lib/git.js";
6
-
7
- const debug = debugTags("semantic-release:get-tags");
8
-
9
- export default async ({ cwd, env, options: { tagFormat } }, branches) => {
10
- // Generate a regex to parse tags formatted with `tagFormat`
11
- // by replacing the `version` variable in the template by `(.+)`.
12
- // The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
13
- // so it's guaranteed to no be present in the `tagFormat`.
14
- const tagRegexp = `^${escapeRegExp(template(tagFormat)({ version: " " })).replace(" ", "(.+)")}`;
15
-
16
- // Get the tags notes for all the tags in the repository
17
- const tagsNotesMap = await getTagsNotes({ cwd, env });
18
-
19
- return pReduce(
20
- branches,
21
- async (branches, branch) => {
22
- const branchTags = await pReduce(
23
- await getTags(branch.name, { cwd, env }),
24
- async (branchTags, tag) => {
25
- const [, version] = tag.match(tagRegexp) || [];
26
- const channels = tagsNotesMap.has(tag) ? tagsNotesMap.get(tag).channels : [null];
27
- return version && semver.valid(semver.clean(version))
28
- ? [...branchTags, { gitTag: tag, version, channels }]
29
- : branchTags;
30
- },
31
- []
32
- );
33
-
34
- debug("found tags for branch %s: %o", branch.name, branchTags);
35
- return [...branches, { ...branch, tags: branchTags }];
36
- },
37
- []
38
- );
39
- };
@@ -1,71 +0,0 @@
1
- import { isRegExp, isString } from "lodash-es";
2
- import AggregateError from "aggregate-error";
3
- import pEachSeries from "p-each-series";
4
- import * as DEFINITIONS from "../definitions/branches.js";
5
- import getError from "../get-error.js";
6
- import { fetch, fetchNotes, verifyBranchName } from "../git.js";
7
- import expand from "./expand.js";
8
- import getTags from "./get-tags.js";
9
- import * as normalize from "./normalize.js";
10
-
11
- export default async (repositoryUrl, ciBranch, context) => {
12
- const { cwd, env } = context;
13
-
14
- const remoteBranches = await expand(
15
- repositoryUrl,
16
- context,
17
- context.options.branches.map((branch) => (isString(branch) || isRegExp(branch) ? { name: branch } : branch))
18
- );
19
-
20
- await pEachSeries(remoteBranches, async ({ name }) => {
21
- await fetch(repositoryUrl, name, ciBranch, { cwd, env });
22
- });
23
-
24
- await fetchNotes(repositoryUrl, { cwd, env });
25
-
26
- const branches = await getTags(context, remoteBranches);
27
-
28
- const errors = [];
29
- const branchesByType = Object.entries(DEFINITIONS).reduce(
30
- // eslint-disable-next-line unicorn/no-fn-reference-in-iterator
31
- (branchesByType, [type, { filter }]) => ({ [type]: branches.filter(filter), ...branchesByType }),
32
- {}
33
- );
34
-
35
- const result = Object.entries(DEFINITIONS).reduce((result, [type, { branchesValidator, branchValidator }]) => {
36
- branchesByType[type].forEach((branch) => {
37
- if (branchValidator && !branchValidator(branch)) {
38
- errors.push(getError(`E${type.toUpperCase()}BRANCH`, { branch }));
39
- }
40
- });
41
-
42
- const branchesOfType = normalize[type](branchesByType);
43
-
44
- if (!branchesValidator(branchesOfType)) {
45
- errors.push(getError(`E${type.toUpperCase()}BRANCHES`, { branches: branchesOfType }));
46
- }
47
-
48
- return { ...result, [type]: branchesOfType };
49
- }, {});
50
-
51
- const duplicates = [...branches]
52
- .map((branch) => branch.name)
53
- .sort()
54
- .filter((_, idx, array) => array[idx] === array[idx + 1] && array[idx] !== array[idx - 1]);
55
-
56
- if (duplicates.length > 0) {
57
- errors.push(getError("EDUPLICATEBRANCHES", { duplicates }));
58
- }
59
-
60
- await pEachSeries(branches, async (branch) => {
61
- if (!(await verifyBranchName(branch.name))) {
62
- errors.push(getError("EINVALIDBRANCHNAME", branch));
63
- }
64
- });
65
-
66
- if (errors.length > 0) {
67
- throw new AggregateError(errors);
68
- }
69
-
70
- return [...result.maintenance, ...result.release, ...result.prerelease];
71
- };