semantic-release 26.0.0-beta.1 → 26.0.0-beta.3

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
@@ -57,11 +57,11 @@ Tools such as [commitizen](https://github.com/commitizen/cz-cli) or [commitlint]
57
57
 
58
58
  The table below shows which commit message gets you which release type when `semantic-release` runs (using the default configuration):
59
59
 
60
- | Commit message | Release type |
61
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
62
- | `fix(pencil): stop graphite breaking when too much pressure applied` | ~~Patch~~ Fix Release |
63
- | `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
64
- | `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release <br /> (Note that the `BREAKING CHANGE: ` token must be in the footer of the commit) |
60
+ | Commit message | Release type |
61
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
62
+ | `fix(pencil): stop graphite breaking when too much pressure applied` | ~~Patch~~ Fix Release |
63
+ | `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
64
+ | `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release <br><br> (Note that the `BREAKING CHANGE: ` token must be in the footer of the commit) |
65
65
 
66
66
  ### Automation with CI
67
67
 
@@ -147,10 +147,10 @@ In order to use **semantic-release** you need:
147
147
 
148
148
  Let people know that your package is published using **semantic-release** and which [commit-convention](#commit-message-format) is followed by including this badge in your readme.
149
149
 
150
- [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
150
+ [![semantic-release: COMMIT-CONVENTION](https://img.shields.io/badge/semantic--release-COMMIT--CONVENTION-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
151
151
 
152
152
  ```md
153
- [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
153
+ [![semantic-release: COMMIT-CONVENTION](https://img.shields.io/badge/semantic--release-COMMIT--CONVENTION-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
154
154
  ```
155
155
 
156
156
  ## Team
package/index.js CHANGED
@@ -83,19 +83,15 @@ async function run(context, plugins) {
83
83
  }`
84
84
  );
85
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
- }
86
+ if (!(await isBranchUpToDate(options.repositoryUrl, context.branch.name, { cwd, env }))) {
87
+ logger.log(
88
+ `The local branch ${context.branch.name} is behind the remote one, therefore a new version won't be published.`
89
+ );
90
+ return false;
91
+ }
96
92
 
97
- throw error;
98
- }
93
+ try {
94
+ await verifyAuth(options.repositoryUrl, { cwd, env });
99
95
  } catch (error) {
100
96
  logger.error(`The command "${error.command}" failed with the error message ${error.stderr}.`);
101
97
  throw getError("EGITNOPERMISSION", context);
@@ -16,6 +16,10 @@ const debug = debugAuthUrl("semantic-release:get-git-auth-url");
16
16
  * @return {String} The formatted Git repository URL.
17
17
  */
18
18
  function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
19
+ if (protocol === "file:") {
20
+ return repositoryUrl;
21
+ }
22
+
19
23
  const [match, auth, host, basePort, path] =
20
24
  /^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<port>\d+)?:?\/?(?<path>.*)$/.exec(repositoryUrl) || [];
21
25
  const { port, hostname, ...parsed } = parse(
@@ -40,7 +44,7 @@ function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
40
44
  */
41
45
  async function ensureValidAuthUrl({ cwd, env, branch }, authUrl) {
42
46
  try {
43
- await verifyAuth(authUrl, branch.name, { cwd, env });
47
+ await verifyAuth(authUrl, { cwd, env });
44
48
  return authUrl;
45
49
  } catch (error) {
46
50
  debug(error);
@@ -90,7 +94,7 @@ export default async (context) => {
90
94
  // Test if push is allowed without transforming the URL (e.g. is ssh keys are set up)
91
95
  try {
92
96
  debug("Verifying ssh auth by attempting to push to %s", repositoryUrl);
93
- await verifyAuth(repositoryUrl, branch.name, { cwd, env });
97
+ await verifyAuth(repositoryUrl, { cwd, env });
94
98
  } catch {
95
99
  debug("SSH key auth failed, falling back to https.");
96
100
  const envVars = Object.keys(GIT_TOKENS).filter((envVar) => !isNil(env[envVar]));
package/lib/git.js CHANGED
@@ -198,18 +198,32 @@ export async function isGitRepo(execaOptions) {
198
198
  }
199
199
 
200
200
  /**
201
- * Verify the write access authorization to remote repository with push dry-run.
201
+ * Verify the write access authorization to remote repository with tags push dry-run.
202
202
  *
203
203
  * @param {String} repositoryUrl The remote repository URL.
204
- * @param {String} branch The repository branch for which to verify write access.
205
204
  * @param {Object} [execaOpts] Options to pass to `execa`.
206
205
  *
207
206
  * @throws {Error} if not authorized to push.
208
207
  */
209
- export async function verifyAuth(repositoryUrl, branch, execaOptions) {
208
+ export async function verifyAuth(repositoryUrl, execaOptions) {
210
209
  try {
211
- await execa("git", ["push", "--dry-run", "--no-verify", "--", repositoryUrl, `HEAD:${branch}`], execaOptions);
210
+ await execa("git", ["push", "--dry-run", "--no-verify", "--", repositoryUrl], execaOptions);
211
+
212
+ const tags = (await execa("git", ["tag", "--list"], execaOptions)).stdout
213
+ .split("\n")
214
+ .map((tag) => tag.trim())
215
+ .filter(Boolean);
216
+
217
+ if (tags.length > 0) {
218
+ await execa("git", ["push", "--dry-run", "--no-verify", "--tags", "--", repositoryUrl], execaOptions);
219
+ }
212
220
  } catch (error) {
221
+ const message = `${error.stderr ?? ""}\n${error.message ?? ""}`;
222
+
223
+ if (/tip of your current branch is behind|rejected|non-fast-forward/i.test(message)) {
224
+ return;
225
+ }
226
+
213
227
  debug(error);
214
228
  throw error;
215
229
  }
@@ -291,15 +305,31 @@ export async function verifyBranchName(branch, execaOptions) {
291
305
  * @param {String} branch The repository branch for which to verify status.
292
306
  * @param {Object} [execaOpts] Options to pass to `execa`.
293
307
  *
294
- * @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise.
308
+ * @return {Boolean} `true` only if the local branch is ahead of the remote branch, falsy otherwise.
295
309
  */
296
310
  export async function isBranchUpToDate(repositoryUrl, branch, execaOptions) {
297
- return (
298
- (await getGitHead(execaOptions)) ===
299
- (await execa("git", ["ls-remote", "--heads", "--", repositoryUrl, branch], execaOptions)).stdout.match(
300
- /^(?<ref>\w+)?/
301
- )[1]
302
- );
311
+ const localHead = await getGitHead(execaOptions);
312
+ const { stdout } = await execa("git", ["ls-remote", "--heads", "--", repositoryUrl, branch], execaOptions);
313
+ const remoteHead = stdout.match(/^(?<ref>\w+)/)?.[0];
314
+
315
+ if (!remoteHead) return false;
316
+ if (localHead === remoteHead) return true;
317
+
318
+ try {
319
+ const { exitCode } = await execa("git", ["merge-base", "--is-ancestor", "--", remoteHead, localHead], {
320
+ ...execaOptions,
321
+ reject: false,
322
+ });
323
+
324
+ /**
325
+ * Exit code 0 means remote is BEHIND local (local is AHEAD) - return true
326
+ * Any other exit code means local is either BEHIND or DIVERGED of remote - return false
327
+ */
328
+ return exitCode === 0;
329
+ } catch (error) {
330
+ debug(error);
331
+ return false;
332
+ }
303
333
  }
304
334
 
305
335
  /**
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": "26.0.0-beta.1",
4
+ "version": "26.0.0-beta.3",
5
5
  "type": "module",
6
6
  "author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
7
7
  "ava": {
@@ -27,11 +27,11 @@
27
27
  "Matt Travi <npm@travi.org> (https://matt.travi.org/)"
28
28
  ],
29
29
  "dependencies": {
30
- "@semantic-release/commit-analyzer": "^13.0.1",
30
+ "@semantic-release/commit-analyzer": "^14.0.0-beta.4",
31
31
  "@semantic-release/error": "^4.0.0",
32
32
  "@semantic-release/github": "^12.0.0",
33
33
  "@semantic-release/npm": "^13.1.1",
34
- "@semantic-release/release-notes-generator": "^14.1.0",
34
+ "@semantic-release/release-notes-generator": "^15.0.0-beta.3",
35
35
  "aggregate-error": "^5.0.0",
36
36
  "cosmiconfig": "^9.0.0",
37
37
  "debug": "^4.0.0",
@@ -57,7 +57,7 @@
57
57
  "yargs": "^18.0.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/node": "24.13.3",
60
+ "@types/node": "24.13.4",
61
61
  "@types/signale": "1.4.7",
62
62
  "ava": "8.0.1",
63
63
  "c8": "12.0.0",
@@ -65,20 +65,20 @@
65
65
  "cz-conventional-changelog": "3.3.0",
66
66
  "file-url": "4.0.0",
67
67
  "fs-extra": "11.4.0",
68
- "got": "15.1.0",
69
- "js-yaml": "4.3.1",
70
- "lockfile-lint": "5.0.0",
68
+ "got": "16.0.0",
69
+ "js-yaml": "4.3.2",
70
+ "lockfile-lint": "5.0.1",
71
71
  "ls-engines": "0.10.1",
72
- "mockserver-client": "7.5.0",
72
+ "mockserver-client": "7.6.0",
73
73
  "nock": "14.0.17",
74
74
  "npm-run-all2": "9.0.3",
75
- "p-retry": "8.0.0",
75
+ "p-retry": "8.0.1",
76
76
  "prettier": "3.8.5",
77
- "publint": "0.3.22",
77
+ "publint": "0.3.24",
78
78
  "sinon": "22.1.0",
79
79
  "stream-buffers": "3.0.3",
80
80
  "tempy": "3.2.0",
81
- "testcontainers": "12.0.4",
81
+ "testcontainers": "12.1.0",
82
82
  "testdouble": "3.20.2"
83
83
  },
84
84
  "engines": {