semantic-release 25.0.4 → 25.0.6
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 +36 -37
- package/bin/semantic-release.js +1 -1
- package/index.js +265 -37
- package/lib/branches/expand.js +18 -0
- package/lib/branches/get-tags.js +39 -0
- package/lib/branches/index.js +71 -0
- package/lib/branches/normalize.js +104 -0
- package/lib/definitions/branches.js +22 -0
- package/lib/definitions/constants.js +8 -9
- package/lib/definitions/errors.js +303 -0
- package/lib/definitions/plugins.js +108 -0
- package/lib/get-commits.js +31 -0
- package/lib/get-config.js +98 -0
- package/lib/get-error.js +7 -0
- package/lib/get-git-auth-url.js +126 -0
- package/lib/get-last-release.js +48 -0
- package/lib/get-logger.js +19 -0
- package/lib/get-next-version.js +35 -0
- package/lib/get-release-to-add.js +59 -0
- package/lib/git.js +381 -0
- package/lib/hide-sensitive.js +14 -1
- package/lib/plugins/index.js +103 -0
- package/lib/plugins/normalize.js +69 -0
- package/lib/plugins/pipeline.js +59 -0
- package/lib/plugins/utils.js +81 -0
- package/lib/utils.js +101 -0
- package/lib/verify.js +43 -0
- package/package.json +20 -15
- package/docs/README.md +0 -7
- package/docs/developer-guide/README.md +0 -5
- package/docs/developer-guide/js-api.md +0 -294
- package/docs/developer-guide/plugin.md +0 -284
- package/docs/developer-guide/shareable-configuration.md +0 -1
- package/docs/extending/README.md +0 -4
- package/docs/extending/plugins-list.md +0 -233
- package/docs/extending/shareable-configurations-list.md +0 -22
- package/docs/recipes/ci-configurations/README.md +0 -7
- package/docs/recipes/ci-configurations/circleci-workflows.md +0 -49
- package/docs/recipes/ci-configurations/github-actions.md +0 -136
- package/docs/recipes/ci-configurations/gitlab-ci.md +0 -98
- package/docs/recipes/ci-configurations/jenkins-ci.md +0 -61
- package/docs/recipes/ci-configurations/travis.md +0 -97
- package/docs/recipes/git-hosted-services/README.md +0 -3
- package/docs/recipes/git-hosted-services/git-auth-ssh-keys.md +0 -166
- package/docs/recipes/release-workflow/README.md +0 -5
- package/docs/recipes/release-workflow/distribution-channels.md +0 -117
- package/docs/recipes/release-workflow/maintenance-releases.md +0 -157
- package/docs/recipes/release-workflow/pre-releases.md +0 -197
- package/docs/support/FAQ.md +0 -253
- package/docs/support/README.md +0 -7
- package/docs/support/git-version.md +0 -4
- package/docs/support/node-support-policy.md +0 -21
- package/docs/support/node-version.md +0 -38
- package/docs/support/resources.md +0 -22
- package/docs/support/troubleshooting.md +0 -70
- package/docs/usage/README.md +0 -9
- package/docs/usage/ci-configuration.md +0 -50
- package/docs/usage/configuration.md +0 -206
- package/docs/usage/getting-started.md +0 -8
- package/docs/usage/installation.md +0 -51
- package/docs/usage/plugins.md +0 -105
- package/docs/usage/shareable-configurations.md +0 -7
- package/docs/usage/workflow-configuration.md +0 -199
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
import { castArray, isNil, isPlainObject, isString, pickBy } from "lodash-es";
|
|
5
|
+
import { readPackageUp } from "read-package-up";
|
|
6
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
7
|
+
import importFrom from "import-from-esm";
|
|
8
|
+
import debugConfig from "debug";
|
|
9
|
+
import { repoUrl } from "./git.js";
|
|
10
|
+
import PLUGINS_DEFINITIONS from "./definitions/plugins.js";
|
|
11
|
+
import plugins from "./plugins/index.js";
|
|
12
|
+
import { parseConfig, validatePlugin } from "./plugins/utils.js";
|
|
13
|
+
|
|
14
|
+
const debug = debugConfig("semantic-release:config");
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
|
|
17
|
+
const CONFIG_NAME = "release";
|
|
18
|
+
|
|
19
|
+
export default async (context, cliOptions) => {
|
|
20
|
+
const { cwd, env } = context;
|
|
21
|
+
const { config, filepath } = (await cosmiconfig(CONFIG_NAME).search(cwd)) || {};
|
|
22
|
+
|
|
23
|
+
debug("load config from: %s", filepath);
|
|
24
|
+
|
|
25
|
+
// Merge config file options and CLI/API options
|
|
26
|
+
let options = { ...config, ...cliOptions };
|
|
27
|
+
|
|
28
|
+
const pluginsPath = {};
|
|
29
|
+
let extendPaths;
|
|
30
|
+
({ extends: extendPaths, ...options } = options);
|
|
31
|
+
if (extendPaths) {
|
|
32
|
+
// If `extends` is defined, load and merge each shareable config with `options`
|
|
33
|
+
options = {
|
|
34
|
+
...(await castArray(extendPaths).reduce(async (eventualResult, extendPath) => {
|
|
35
|
+
const result = await eventualResult;
|
|
36
|
+
const extendsOptions = (await importFrom.silent(__dirname, extendPath)) || (await importFrom(cwd, extendPath));
|
|
37
|
+
|
|
38
|
+
// For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path,
|
|
39
|
+
// so those plugin will be loaded relative to the config file
|
|
40
|
+
Object.entries(extendsOptions)
|
|
41
|
+
.filter(([, value]) => Boolean(value))
|
|
42
|
+
.reduce((pluginsPath, [option, value]) => {
|
|
43
|
+
castArray(value).forEach((plugin) => {
|
|
44
|
+
if (option === "plugins" && validatePlugin(plugin)) {
|
|
45
|
+
pluginsPath[parseConfig(plugin)[0]] = extendPath;
|
|
46
|
+
} else if (
|
|
47
|
+
PLUGINS_DEFINITIONS[option] &&
|
|
48
|
+
(isString(plugin) || (isPlainObject(plugin) && isString(plugin.path)))
|
|
49
|
+
) {
|
|
50
|
+
pluginsPath[isString(plugin) ? plugin : plugin.path] = extendPath;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return pluginsPath;
|
|
54
|
+
}, pluginsPath);
|
|
55
|
+
|
|
56
|
+
return { ...result, ...extendsOptions };
|
|
57
|
+
}, {})),
|
|
58
|
+
...options,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Set default options values if not defined yet
|
|
63
|
+
options = {
|
|
64
|
+
branches: [
|
|
65
|
+
"+([0-9])?(.{+([0-9]),x}).x",
|
|
66
|
+
"master",
|
|
67
|
+
"main",
|
|
68
|
+
"next",
|
|
69
|
+
"next-major",
|
|
70
|
+
{ name: "beta", prerelease: true },
|
|
71
|
+
{ name: "alpha", prerelease: true },
|
|
72
|
+
],
|
|
73
|
+
repositoryUrl: (await pkgRepoUrl({ normalize: false, cwd })) || (await repoUrl({ cwd, env })),
|
|
74
|
+
tagFormat: `v\${version}`,
|
|
75
|
+
plugins: [
|
|
76
|
+
"@semantic-release/commit-analyzer",
|
|
77
|
+
"@semantic-release/release-notes-generator",
|
|
78
|
+
"@semantic-release/npm",
|
|
79
|
+
"@semantic-release/github",
|
|
80
|
+
],
|
|
81
|
+
// Remove `null` and `undefined` options, so they can be replaced with default ones
|
|
82
|
+
...pickBy(options, (option) => !isNil(option)),
|
|
83
|
+
...(options.branches ? { branches: castArray(options.branches) } : {}),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (options.ci === false) {
|
|
87
|
+
options.noCi = true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
debug("options values: %O", options);
|
|
91
|
+
|
|
92
|
+
return { options, plugins: await plugins({ ...context, options }, pluginsPath) };
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
async function pkgRepoUrl(options) {
|
|
96
|
+
const { packageJson } = (await readPackageUp(options)) || {};
|
|
97
|
+
return packageJson && (isPlainObject(packageJson.repository) ? packageJson.repository.url : packageJson.repository);
|
|
98
|
+
}
|
package/lib/get-error.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import SemanticReleaseError from "@semantic-release/error";
|
|
2
|
+
import * as ERROR_DEFINITIONS from "./definitions/errors.js";
|
|
3
|
+
|
|
4
|
+
export default (code, ctx = {}) => {
|
|
5
|
+
const { message, details } = ERROR_DEFINITIONS[code](ctx);
|
|
6
|
+
return new SemanticReleaseError(message, code, details);
|
|
7
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { format, parse } from "node:url";
|
|
2
|
+
import { isNil } from "lodash-es";
|
|
3
|
+
import hostedGitInfo from "hosted-git-info";
|
|
4
|
+
import debugAuthUrl from "debug";
|
|
5
|
+
import { verifyAuth } from "./git.js";
|
|
6
|
+
|
|
7
|
+
const debug = debugAuthUrl("semantic-release:get-git-auth-url");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Machinery to format a repository URL with the given credentials
|
|
11
|
+
*
|
|
12
|
+
* @param {String} protocol URL protocol (which should not be present in repositoryUrl)
|
|
13
|
+
* @param {String} repositoryUrl User-given repository URL
|
|
14
|
+
* @param {String} gitCredentials The basic auth part of the URL
|
|
15
|
+
*
|
|
16
|
+
* @return {String} The formatted Git repository URL.
|
|
17
|
+
*/
|
|
18
|
+
function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
|
|
19
|
+
const [match, auth, host, basePort, path] =
|
|
20
|
+
/^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<port>\d+)?:?\/?(?<path>.*)$/.exec(repositoryUrl) || [];
|
|
21
|
+
const { port, hostname, ...parsed } = parse(
|
|
22
|
+
match ? `ssh://${auth ? `${auth}@` : ""}${host}${basePort ? `:${basePort}` : ""}/${path}` : repositoryUrl
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return format({
|
|
26
|
+
...parsed,
|
|
27
|
+
auth: gitCredentials,
|
|
28
|
+
host: `${hostname}${protocol === "ssh:" ? "" : port ? `:${port}` : ""}`,
|
|
29
|
+
protocol: protocol && /http[^s]/.test(protocol) ? "http" : "https",
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Verify authUrl by calling git.verifyAuth, but don't throw on failure
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} context semantic-release context.
|
|
37
|
+
* @param {String} authUrl Repository URL to verify
|
|
38
|
+
*
|
|
39
|
+
* @return {String} The authUrl as is if the connection was successful, null otherwise
|
|
40
|
+
*/
|
|
41
|
+
async function ensureValidAuthUrl({ cwd, env, branch }, authUrl) {
|
|
42
|
+
try {
|
|
43
|
+
await verifyAuth(authUrl, branch.name, { cwd, env });
|
|
44
|
+
return authUrl;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
debug(error);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Determine the git repository URL to use to push, either:
|
|
53
|
+
* - The `repositoryUrl` as is if allowed to push
|
|
54
|
+
* - The `repositoryUrl` converted to `https` or `http` with Basic Authentication
|
|
55
|
+
*
|
|
56
|
+
* In addition, expand shortcut URLs (`owner/repo` => `https://github.com/owner/repo.git`) and transform `git+https` / `git+http` URLs to `https` / `http`.
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} context semantic-release context.
|
|
59
|
+
*
|
|
60
|
+
* @return {String} The formatted Git repository URL.
|
|
61
|
+
*/
|
|
62
|
+
export default async (context) => {
|
|
63
|
+
const { cwd, env, branch } = context;
|
|
64
|
+
const GIT_TOKENS = {
|
|
65
|
+
GIT_CREDENTIALS: undefined,
|
|
66
|
+
GH_TOKEN: undefined,
|
|
67
|
+
// GitHub Actions require the "x-access-token:" prefix for git access
|
|
68
|
+
// https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation
|
|
69
|
+
GITHUB_TOKEN: isNil(env.GITHUB_ACTION) ? undefined : "x-access-token:",
|
|
70
|
+
GL_TOKEN: "gitlab-ci-token:",
|
|
71
|
+
GITLAB_TOKEN: "gitlab-ci-token:",
|
|
72
|
+
BB_TOKEN: "x-token-auth:",
|
|
73
|
+
BITBUCKET_TOKEN: "x-token-auth:",
|
|
74
|
+
BB_TOKEN_BASIC_AUTH: "",
|
|
75
|
+
BITBUCKET_TOKEN_BASIC_AUTH: "",
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
let { repositoryUrl } = context.options;
|
|
79
|
+
const info = hostedGitInfo.fromUrl(repositoryUrl, { noGitPlus: true });
|
|
80
|
+
const { protocol, ...parsed } = parse(repositoryUrl);
|
|
81
|
+
|
|
82
|
+
if (info && info.getDefaultRepresentation() === "shortcut") {
|
|
83
|
+
// Expand shorthand URLs (such as `owner/repo` or `gitlab:owner/repo`)
|
|
84
|
+
repositoryUrl = info.https();
|
|
85
|
+
} else if (protocol && protocol.includes("http")) {
|
|
86
|
+
// Replace `git+https` and `git+http` with `https` or `http`
|
|
87
|
+
repositoryUrl = format({ ...parsed, protocol: protocol.includes("https") ? "https" : "http", href: null });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Test if push is allowed without transforming the URL (e.g. is ssh keys are set up)
|
|
91
|
+
try {
|
|
92
|
+
debug("Verifying ssh auth by attempting to push to %s", repositoryUrl);
|
|
93
|
+
await verifyAuth(repositoryUrl, branch.name, { cwd, env });
|
|
94
|
+
} catch {
|
|
95
|
+
debug("SSH key auth failed, falling back to https.");
|
|
96
|
+
const envVars = Object.keys(GIT_TOKENS).filter((envVar) => !isNil(env[envVar]));
|
|
97
|
+
|
|
98
|
+
// Skip verification if there is no ambiguity on which env var to use for authentication
|
|
99
|
+
if (envVars.length === 1) {
|
|
100
|
+
const gitCredentials = `${GIT_TOKENS[envVars[0]] || ""}${env[envVars[0]]}`;
|
|
101
|
+
return formatAuthUrl(protocol, repositoryUrl, gitCredentials);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (envVars.length > 1) {
|
|
105
|
+
debug(`Found ${envVars.length} credentials in environment, trying all of them`);
|
|
106
|
+
|
|
107
|
+
const candidateRepositoryUrls = [];
|
|
108
|
+
for (const envVar of envVars) {
|
|
109
|
+
const gitCredentials = `${GIT_TOKENS[envVar] || ""}${env[envVar]}`;
|
|
110
|
+
const authUrl = formatAuthUrl(protocol, repositoryUrl, gitCredentials);
|
|
111
|
+
candidateRepositoryUrls.push(ensureValidAuthUrl(context, authUrl));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const validRepositoryUrls = await Promise.all(candidateRepositoryUrls);
|
|
115
|
+
const chosenAuthUrlIndex = validRepositoryUrls.findIndex((url) => url !== null);
|
|
116
|
+
if (chosenAuthUrlIndex > -1) {
|
|
117
|
+
debug(`Using "${envVars[chosenAuthUrlIndex]}" to authenticate`);
|
|
118
|
+
return validRepositoryUrls[chosenAuthUrlIndex];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Log completion of this process
|
|
124
|
+
debug("SSH key auth successful.");
|
|
125
|
+
return repositoryUrl;
|
|
126
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isUndefined } from "lodash-es";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import { isSameChannel, makeTag } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Last release.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Object} LastRelease
|
|
9
|
+
* @property {string} version The version number of the last release.
|
|
10
|
+
* @property {string} gitHead The Git reference used to make the last release.
|
|
11
|
+
* @property {string} gitTag The git tag associated with the last release.
|
|
12
|
+
* @property {string} channel The channel on which of the last release was published.
|
|
13
|
+
* @property {string} name The name of the last release.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Determine the Git tag and version of the last tagged release.
|
|
18
|
+
*
|
|
19
|
+
* - Filter out the branch tags that are not valid semantic version
|
|
20
|
+
* - Sort the versions
|
|
21
|
+
* - Retrieve the highest version
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} context semantic-release context.
|
|
24
|
+
* @param {Object} params Function parameters.
|
|
25
|
+
* @param {Object} params.before Find only releases with version number lower than this version.
|
|
26
|
+
*
|
|
27
|
+
* @return {LastRelease} The last tagged release or empty object if none is found.
|
|
28
|
+
*/
|
|
29
|
+
export default ({ branch, options: { tagFormat } }, { before } = {}) => {
|
|
30
|
+
const [{ version, gitTag, channels } = {}] = branch.tags
|
|
31
|
+
.filter(
|
|
32
|
+
(tag) =>
|
|
33
|
+
((branch.type === "prerelease" &&
|
|
34
|
+
tag.channels.some((channel) => isSameChannel(branch.channel, channel)) &&
|
|
35
|
+
semver
|
|
36
|
+
.parse(tag.version)
|
|
37
|
+
.prerelease.includes(branch.prerelease === true ? branch.name : branch.prerelease)) ||
|
|
38
|
+
!semver.prerelease(tag.version)) &&
|
|
39
|
+
(isUndefined(before) || semver.lt(tag.version, before))
|
|
40
|
+
)
|
|
41
|
+
.sort((a, b) => semver.rcompare(a.version, b.version));
|
|
42
|
+
|
|
43
|
+
if (gitTag) {
|
|
44
|
+
return { version, gitTag, channels, gitHead: gitTag, name: makeTag(tagFormat, version) };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {};
|
|
48
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import signale from "signale";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
const { Signale } = signale;
|
|
5
|
+
|
|
6
|
+
export default ({ stdout, stderr }) =>
|
|
7
|
+
new Signale({
|
|
8
|
+
config: { displayTimestamp: true, underlineMessage: false, displayLabel: false },
|
|
9
|
+
disabled: false,
|
|
10
|
+
interactive: false,
|
|
11
|
+
scope: "semantic-release",
|
|
12
|
+
stream: [stdout],
|
|
13
|
+
types: {
|
|
14
|
+
error: { badge: figures.cross, color: "red", label: "", stream: [stderr] },
|
|
15
|
+
log: { badge: figures.info, color: "magenta", label: "", stream: [stdout] },
|
|
16
|
+
success: { badge: figures.tick, color: "green", label: "", stream: [stdout] },
|
|
17
|
+
warn: { badge: figures.warning, color: "yellow", label: "", stream: [stderr] },
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { FIRST_RELEASE, FIRSTPRERELEASE } from "./definitions/constants.js";
|
|
3
|
+
import { getLatestVersion, highest, isSameChannel, tagsToVersions } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
export default ({ branch, nextRelease: { type, channel }, lastRelease, logger }) => {
|
|
6
|
+
let version;
|
|
7
|
+
if (lastRelease.version) {
|
|
8
|
+
const { major, minor, patch } = semver.parse(lastRelease.version);
|
|
9
|
+
|
|
10
|
+
if (branch.type === "prerelease") {
|
|
11
|
+
if (
|
|
12
|
+
semver.prerelease(lastRelease.version) &&
|
|
13
|
+
lastRelease.channels.some((lastReleaseChannel) => isSameChannel(lastReleaseChannel, channel))
|
|
14
|
+
) {
|
|
15
|
+
version = highest(
|
|
16
|
+
semver.inc(lastRelease.version, "prerelease"),
|
|
17
|
+
`${semver.inc(getLatestVersion(tagsToVersions(branch.tags), { withPrerelease: true }), type)}-${
|
|
18
|
+
branch.prerelease
|
|
19
|
+
}.${FIRSTPRERELEASE}`
|
|
20
|
+
);
|
|
21
|
+
} else {
|
|
22
|
+
version = `${semver.inc(`${major}.${minor}.${patch}`, type)}-${branch.prerelease}.${FIRSTPRERELEASE}`;
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
version = semver.inc(lastRelease.version, type);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
logger.log("The next release version is %s", version);
|
|
29
|
+
} else {
|
|
30
|
+
version = branch.type === "prerelease" ? `${FIRST_RELEASE}-${branch.prerelease}.${FIRSTPRERELEASE}` : FIRST_RELEASE;
|
|
31
|
+
logger.log(`There is no previous release, the next release version is ${version}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return version;
|
|
35
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { intersection, uniqBy } from "lodash-es";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import getLastRelease from "./get-last-release.js";
|
|
4
|
+
import { getLowerBound, getVersionDiff, makeTag } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Find releases that have been merged from a higher branch but not added on the channel of the current branch.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} context semantic-release context.
|
|
10
|
+
*
|
|
11
|
+
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
|
|
12
|
+
*/
|
|
13
|
+
export default (context) => {
|
|
14
|
+
const {
|
|
15
|
+
branch,
|
|
16
|
+
branches,
|
|
17
|
+
options: { tagFormat },
|
|
18
|
+
} = context;
|
|
19
|
+
|
|
20
|
+
const higherChannels = branches
|
|
21
|
+
// Consider only releases of higher branches
|
|
22
|
+
.slice(branches.findIndex(({ name }) => name === branch.name) + 1)
|
|
23
|
+
// Exclude prerelease branches
|
|
24
|
+
.filter(({ type }) => type !== "prerelease")
|
|
25
|
+
.map(({ channel }) => channel || null);
|
|
26
|
+
|
|
27
|
+
const versiontoAdd = uniqBy(
|
|
28
|
+
branch.tags.filter(
|
|
29
|
+
({ channels, version }) =>
|
|
30
|
+
!channels.includes(branch.channel || null) &&
|
|
31
|
+
intersection(channels, higherChannels).length > 0 &&
|
|
32
|
+
(branch.type !== "maintenance" || semver.gte(version, getLowerBound(branch.mergeRange)))
|
|
33
|
+
),
|
|
34
|
+
"version"
|
|
35
|
+
).sort((a, b) => semver.compare(b.version, a.version))[0];
|
|
36
|
+
|
|
37
|
+
if (versiontoAdd) {
|
|
38
|
+
const { version, gitTag, channels } = versiontoAdd;
|
|
39
|
+
const lastRelease = getLastRelease(context, { before: version });
|
|
40
|
+
if (semver.gt(getLastRelease(context).version, version)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const type = lastRelease.version ? getVersionDiff(lastRelease.version, version) : "major";
|
|
45
|
+
const name = makeTag(tagFormat, version);
|
|
46
|
+
return {
|
|
47
|
+
lastRelease,
|
|
48
|
+
currentRelease: { type, version, channels, gitTag, name, gitHead: gitTag },
|
|
49
|
+
nextRelease: {
|
|
50
|
+
type,
|
|
51
|
+
version,
|
|
52
|
+
channel: branch.channel || null,
|
|
53
|
+
gitTag: makeTag(tagFormat, version),
|
|
54
|
+
name,
|
|
55
|
+
gitHead: gitTag,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
};
|