Compare commits

..
307 Commits
Author SHA1 Message Date
Matt TraviandGitHub 18730e824f Merge pull request #2826 from semantic-release/renovate/major-semantic-release-monorepo 2023-06-09 16:32:02 -05:00
Matt Travi 4bf763f264 test(semantic-release-error): switched instanceof check to the native version
since the check provided by the ava assertion seems to fail beyond the context of the test
2023-06-09 16:14:46 -05:00
renovate[bot]andGitHub d259350c3e fix(deps): update dependency @semantic-release/error to v4 2023-06-07 21:29:33 +00:00
286bd67de5 chore(deps): lock file maintenance (#2825)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-05 04:23:37 +00:00
95551a0df8 chore(deps): update dependency ava to v5.3.0 (#2809)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-02 15:30:01 -05:00
4e80bab563 chore(deps): lock file maintenance (#2816)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-02 15:25:29 -05:00
5145268539 chore(deps): update dependency got to v13 (#2813)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-02 15:18:21 -05:00
Matt TraviandGitHub dd352f1044 Merge pull request #2823 from semantic-release/beta 2023-06-02 15:09:44 -05:00
Matt Travi 39410186df fix(deps): updated the beta plugins to stable versions 2023-06-02 14:30:32 -05:00
Matt Travi 4a6b31f57e fix: bump @semantic-release/commit-analyzer to v10.0.0-beta.1 2023-05-29 22:03:54 -05:00
6f19d77e54 fix: bump @semantic-release/github to 9.0.0-beta.2 (#2818)
Co-authored-by: Matt Travi <programmer@travi.org>
2023-05-29 20:47:17 -05:00
6ef4cee971 chore(deps): update dependency c8 to v7.14.0 (#2815)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-28 19:00:28 +00:00
18bd0c4904 chore(deps): lock file maintenance (#2797)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-23 07:05:08 +00:00
Matt Travi ab4fe4c3d4 refactor: leverage native async setTimeout rather than delay 2023-05-22 22:25:22 -05:00
42385d0f96 chore(deps): update dependency sinon to v15.1.0 (#2801)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-21 15:39:53 -07:00
57db31ad97 chore(deps): update dependency delay to v6 (#2803)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-21 20:14:15 +00:00
Matt TraviandGitHub fa133f2a9d ci(release): pinned the version of semantic-release (#2796) 2023-05-12 17:17:04 -05:00
4af49f3c87 chore(deps): update dependency nock to v13.3.1 (#2777)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-10 16:01:22 -05:00
Joram van den BoezemandGitHub 0d5e717fa6 docs(extending): add semantic-release-yarn to community plugins (#2790) 2023-05-10 08:40:17 -05:00
Matt Travi ee250a04db docs(gitbook): fixed reference to the installation page 2023-05-09 09:07:50 -05:00
85a31fb612 docs(npx-version): mentioned using a renovate regex manager to update the version (#2786)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2023-05-09 08:02:45 -05:00
8826e524e4 chore(deps): update dependency testdouble to v3.18.0 (#2787)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-09 06:35:20 +00:00
Liran TalandGitHub f1b0801157 docs: Update README.md with npm package provenance (#2789) 2023-05-08 21:06:39 -05:00
214a376342 ci(action): pin dependencies (#2781)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-06 10:09:56 +00:00
0c6c20ee96 chore(deps): lock file maintenance (#2763)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-06 08:06:29 +00:00
420211c806 chore(deps): update dependency prettier to v2.8.8 (#2771)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-06 04:19:59 +00:00
Eric KandGitHub 0476ae58a0 docs(extending): add link to semantic-release-major-tag (#2776) 2023-05-05 16:55:09 -05:00
ac40804dc4 fix(deps): update dependency @semantic-release/release-notes-generator to v11 (#2778)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-28 17:01:24 -05:00
Matt Travi e046ece3cb ci(signatures): moved the audit step to the non-matrix stage
since older versions of npm dont support `npm audit signatures` and instead simply audit for vulnerabilities
2023-04-28 16:33:03 -05:00
Matt Travi ef998acd4d ci(dependencies): audited signatures and provenance attestations of installed packages 2023-04-21 16:41:27 -05:00
Matt Travi 278d8e6bec docs(gh-actions): captured details about publishing with provenance from an actions workflow 2023-04-21 16:01:08 -05:00
ddf4065b4e chore(deps): update dependency sinon to v15.0.4 (#2769)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-20 17:40:03 +00:00
4bddb37de2 fix(deps): update dependency env-ci to v9 (#2757)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-01 08:18:03 -05:00
aa90774738 chore(deps): update dependency testdouble to v3.17.2 (#2751)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-01 01:53:55 +00:00
Matt Travi d7e14f6d02 docs(artifactory): removed details about using artifactory with legacy auth
since we no longer support legacy auth in the npm plugin and artifcatory can use modern auth with more recent versions
2023-03-31 15:09:10 -05:00
4a943a5651 chore(deps): pin dependencies (#2744)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-27 19:16:38 +00:00
f47a5102d6 chore(deps): lock file maintenance (#2737)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-27 14:50:11 +00:00
05596bce72 chore(deps): update dependency prettier to ^2.8.4 (#2746)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-27 08:52:21 +00:00
c6e84efc28 chore(deps): update dependency sinon to v15.0.3 (#2748)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-27 03:27:20 +00:00
0cbe8046af chore(deps): update dependency fs-extra to ^11.1.0 (#2745)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-25 01:36:14 +00:00
ea32d10fa6 chore(deps): update dependency testdouble to v3.17.1 (#2740)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-24 20:51:08 +00:00
Matt TraviandGitHub deb1b7f9cb Merge pull request #2741 from semantic-release/beta
upgraded to next major version of the npm plugin
2023-03-24 14:30:48 -05:00
Matt Travi 2d7f607649 chore(lint): ran prettier against the release workflow file 2023-03-21 22:18:42 -05:00
Matt Travi 91eae117ed ci(release): enabled provenance for publishing to npm 2023-03-21 22:12:37 -05:00
Matt Travi 050412eab8 Merge branch 'master' of github.com:semantic-release/semantic-release into beta 2023-03-21 21:46:58 -05:00
Matt Travi d647433c20 fix(deps): updated to the latest version of the npm plugin 2023-03-21 21:13:25 -05:00
f1d6e65d9a chore(deps): update dependency dockerode to v3.3.5
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-17 13:36:34 -07:00
c38b53a321 fix(deps): update dependency execa to v7.1.1
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-17 13:36:13 -07:00
fbede54388 fix(deps): update dependency cosmiconfig to v8.1.2
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-17 13:33:58 -07:00
6d286cd5d6 chore(deps): update dependency sinon to v15.0.2 (#2730)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-14 05:05:34 +00:00
bc6d8b4411 chore(deps): update dependency testdouble to v3.17.0 (#2731)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-14 01:22:13 +00:00
9986f6fe20 chore(deps): lock file maintenance
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-06 21:15:28 -08:00
Justin MartinandGitHub 6bd6afd8f7 docs: add new to create WritableStreamBuffer instances (#2724) 2023-03-06 23:10:48 -06:00
00714c0fc8 chore(deps): lock file maintenance (#2684)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-04 14:40:56 -06:00
Chris. WebsterandGitHub c71d5d94ce test: Windows support in integration tests (#2722)
* ci: win32 escape slash as doubleslash for test

Pathing in stderr output has double backslash in the filename.  The test
will now use double backslash in the existence test.

Signed-off-by: Chris. Webster <chris@webstech.net>

* ci: avoid Windows pop-up in credential tests

Windows uses a `credential.helper` that will open a pop-up for
credentials if they are missing.  A git config parameter will now be set
to avoid the pop-up.

Signed-off-by: Chris. Webster <chris@webstech.net>

---------

Signed-off-by: Chris. Webster <chris@webstech.net>
2023-03-04 12:37:05 -06:00
Chris. WebsterandGitHub c04e827757 test: update docker config for windows support (#2721
There is legacy support for PortBindings and Binds at the root level of
the config.  Currently (including Windows) these reside under the
HostConfig.  ExposedPorts is now used to identify the externally
available ports.

Signed-off-by: Chris. Webster <chris@webstech.net>
2023-03-03 17:09:19 -06:00
Chris. WebsterandGitHub 6ead75bf73 test: index test should reset testdouble (#2723) 2023-03-03 15:58:42 -06:00
ab3dfe4aba chore(deps): update dependency c8 to v7.13.0 (#2716)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-28 23:29:06 -06:00
Matt Travi df6dbf0295 docs(navigation): removed the hash from the configuration usage page 2023-02-28 22:59:01 -06:00
Matt Travi ea8ed80e71 docs(navigation): removed the hash from the ci usage page 2023-02-28 22:57:29 -06:00
Matt Travi e47ea08255 docs(ci-configurations): removed hash from the links 2023-02-28 22:27:15 -06:00
Matt Travi 4e5b181ffb docs(node-version): linked to proper recipe page for ci-configurations 2023-02-28 22:23:21 -06:00
Matt Travi 5acdaabaaf docs(ci-configuration): further fixed the format of links to recipes 2023-02-28 22:15:15 -06:00
Matt Travi 724dc823fa docs(ci-configuration): fixed the format of links to recipes 2023-02-28 22:09:16 -06:00
31d9bfe00a fix(deps): update dependency execa to v7 (#2709)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-27 23:18:19 -06:00
7bbaaf9a48 chore(deps): update dependency ava to v5.2.0 (#2702)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-27 23:05:07 -06:00
42b67ce994 ci: set test workflow timeout to 10 minutes (#2720)
Co-authored-by: Matt Travi <programmer@travi.org>
2023-02-27 22:17:40 -06:00
Chris. WebsterandGitHub f991a599f5 test(integration): fix package name conflict (#2719) 2023-02-27 22:01:57 -06:00
Matt Travi bef1d48114 fix(deps): updated to the latest beta of the npm plugin, which updates npm to v9
BREAKING CHANGE: the npm plugin has updated the npm dependency to v9
2023-02-17 16:05:27 -06:00
Lars TrieloffandGitHub 1775ed80b9 docs(extending): add link to semantic-release-coralogix (#2710) 2023-02-16 00:45:54 -06:00
1beeb84c90 build(deps): bump http-cache-semantics from 4.1.0 to 4.1.1
Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/kornelski/http-cache-semantics/releases)
- [Commits](https://github.com/kornelski/http-cache-semantics/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-03 10:08:15 -08:00
Matt Travi 5d1e5a0dd9 fix(deps): updated to the latest beta of the npm plugin 2023-01-27 16:13:03 -06:00
Matt Travi d3aae0752c Merge branch 'master' of github.com:semantic-release/semantic-release into beta 2023-01-27 16:09:41 -06:00
d170f73e0b feat(plugins): add support for loading ESM plugins (#2688)
Co-authored-by: Matt Travi <programmer@travi.org>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2023-01-24 23:24:02 -06:00
Chris. WebsterandGitHub 5df624c6e5 fix(windows): fixed issues preventing execution from windows (#2672) 2023-01-23 20:38:37 -06:00
Matt TraviandGitHub 914b0a2642 Revert "chore(deps): update dependency ava to v5.1.1" (#2682)
This reverts commit 3f3b286fb8.
2023-01-22 21:39:16 -06:00
Khaled BadenjkiandGitHub 140e36d60f docs(workflow-configuration): improved sentence structure (#2679) 2023-01-20 13:49:17 -06:00
Anton OvechkinandGitHub e9efbc7a52 docs(pre-releases): Correct @latest version in semantic-release (#2668)
There is a tiny typo in the version mentioned in `Working on another future release` section. It says that installing with `npm install example-module` will still receive version `1.0.0`, but in fact, there was a bug fix made on the default distribution channel one step before.
2023-01-18 03:08:40 +00:00
3f3b286fb8 chore(deps): update dependency ava to v5.1.1
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-15 15:27:52 -08:00
Gregor Martynus 15092ad276 breaking: legacy authentication using NPM_USERNAME and NPM_PASSWORD is no longer supported. Use NPM_TOKEN instead.
BREAKING CHANGE: legacy authentication using `NPM_USERNAME` and `NPM_PASSWORD` is no longer supported. Use `NPM_TOKEN` instead.
2023-01-14 15:52:59 -08:00
Gregor MartynusandGitHub 6a83cb53e5 fix(deps): bump @semantic-release/npm to ^10.0.0-beta.1 (#2670) 2023-01-14 14:14:04 -08:00
4db048423d chore(deps): lock file maintenance
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-14 11:54:27 -08:00
AlexandGitHub be2e1965ae ci(permissions): provided only the necessary permissions to the GITHUB_TOKEN 2023-01-14 08:11:42 -06:00
Gregor Martynus e607e234f3 build(release.yml): set node-version to lts/* 2023-01-13 12:51:39 -08:00
Shane O'GradyandGitHub c7b8e10bd1 docs: update node LTS version for npx command (#2669)
The [lts tag](https://www.npmjs.com/package/node?activeTab=versions) refers to Node.js 16.13.2. To use v18 of Node you need to use the tag `v18-lts`.
2023-01-13 09:24:31 -08:00
ac1371470d chore(deps): update dependency mockserver-client to v5.15.0
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-12 13:51:24 -08:00
7e6d9226fa chore(deps): update dependency nock to v13.3.0 (#2665)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-11 01:38:21 +00:00
Ben LimmerandGitHub 63073d64c0 docs: update GH Actions recipe actions to v3 (#2652) 2023-01-10 12:32:29 -08:00
cb45d27726 fix(deps): update dependency semver-diff to v4 (#1915)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-08 00:57:59 -06:00
f914c1ed86 fix(deps): update dependency cosmiconfig to v8
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-07 15:40:20 -08:00
c4da008e29 fix(deps): update dependency hosted-git-info to v6
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-07 15:39:59 -08:00
b707475b85 chore(deps): update dependency sinon to v15 (#2653)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-07 11:27:44 +00:00
b9579349ca chore(deps): update dependency fs-extra to v11 (#2650)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-07 08:39:35 +00:00
4b74f005c4 chore(deps): update dependency ava to v5 (#2649)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-07 05:49:16 +00:00
bbb5e5ade6 chore(deps): update dependency testdouble to v3.16.8 (#2646)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-07 02:25:38 +00:00
a1e0467f04 chore(deps): update dependency sinon to v14.0.2 (#2645)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-06 23:31:08 +00:00
Matt TraviandGitHub b9b5c7689f Merge pull request #2607 from semantic-release/beta 2023-01-06 13:54:06 -06:00
Matt Travi 91bcb6b988 Merge branch 'master' of github.com:semantic-release/semantic-release into beta 2023-01-06 13:49:45 -06:00
0716d62fd1 build(deps): bump json5 and tsconfig-paths (#2643)
Bumps [json5](https://github.com/json5/json5) and [tsconfig-paths](https://github.com/dividab/tsconfig-paths). These dependencies needed to be updated together.

Updates `json5` from 2.2.0 to 2.2.3
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3)

Updates `tsconfig-paths` from 3.9.0 to 3.10.1
- [Release notes](https://github.com/dividab/tsconfig-paths/releases)
- [Changelog](https://github.com/dividab/tsconfig-paths/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dividab/tsconfig-paths/compare/v3.9.0...v3.10.1)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
- dependency-name: tsconfig-paths
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 21:52:25 -06:00
Matt Travi caa8b95f7b test(integration): used token auth for registry interactions rather than legacy auth 2022-12-17 22:53:11 -06:00
Matt Travi 097351304e Merge branch 'master' of github.com:semantic-release/semantic-release into beta 2022-12-16 16:47:35 -06:00
fa241a2a06 build(deps): bump minimatch from 3.0.4 to 3.1.2
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-12 08:25:54 -08:00
Matt Travi ba05e08303 docs(node-version): raised the minimum version to align with engines.node 2022-12-11 08:57:02 -06:00
Matt Travi eddbbb812b Merge branch 'master' of github.com:semantic-release/semantic-release into beta 2022-12-09 14:40:09 -06:00
aa0c9d6a75 build(deps): bump decode-uri-component from 0.2.0 to 0.2.2
Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-07 15:33:53 -08:00
Matt TraviandGitHub 7365012002 chore(overrides): removed the overrides definition (#2634) 2022-12-06 21:47:11 -06:00
Matt TraviandGitHub 918eb59bc5 fix(env-ci): updated to the stable esm-only version (#2632) 2022-12-06 21:20:25 -06:00
Matt Travi c4cd63929a Merge branch 'master' of github.com:semantic-release/semantic-release into beta 2022-12-02 16:43:22 -06:00
Matt Travi 6051fae63f Revert "test(integration): ran tests serially in hope of avoiding conflicts in the ci environment"
This reverts commit 71f45f97b1.
2022-12-02 16:42:21 -06:00
Matt Travi 62846a110b test(integration): omitted the GITHUB_ACTION env var as well 2022-12-02 16:35:57 -06:00
Matt Travi 71f45f97b1 test(integration): ran tests serially in hope of avoiding conflicts in the ci environment 2022-12-02 14:44:29 -06:00
Matt Travi f32fd5889a test(integration): updated the simulated environment to omit the GITHUB_ACTIONS variable from the test env 2022-12-02 14:20:04 -06:00
Gregor MartynusandGitHub d13ea9280e style: prettier (#2624) 2022-11-23 16:02:51 -08:00
Matt TraviandGitHub 8a0d8be51f feat(node-versions): raised the minimum required node version to v18 (#2620) 2022-11-20 21:23:50 -08:00
Matt TraviandGitHub cf6befa2e8 fix(secrets-masking): used the proper named import from hook-std to enable masking for stderr (#2619) 2022-11-20 21:22:32 -08:00
Matt TraviandGitHub 0ab8d9a4bc Merge pull request #2610 from semantic-release/index-test 2022-11-15 21:59:01 -06:00
Matt TraviandGitHub 27b105337b Merge pull request #2613 from kyletsang/patch-1
docs(plugins): fix typo
2022-11-15 13:24:25 -06:00
Kyle TsangandGitHub 60f3bb03d1 docs(plugins): fix typo 2022-11-15 09:39:36 -08:00
Matt Travi 1b6254880c test: aligned pluginName with naming for functions 2022-11-13 00:43:46 -06:00
Matt TraviandGitHub 78ea3ba966 Merge pull request #2606 from semantic-release/travi/esm 2022-11-11 12:03:25 -06:00
Matt Travi f7c85e3fff test(index): forced plugins to use semantic-release beta
which deduped env-ci to the esm-only version, allowing test double to stub properly
2022-11-11 11:01:16 -06:00
Matt TraviandGitHub 9eab1adb9d feat(esm): convert to esm (#2569)
for #2543

BREAKING CHANGE: semantic-release is now ESM-only. since it is used through its own executable, the impact on consuming projects should be minimal

BREAKING CHANGE: references to plugin files in configs need to include the file extension because of executing in an ESM context
2022-11-11 09:24:06 -06:00
Christoph BühlerandGitHub 4012f75386 docs(plugins list): add semantic release cargo community plugin (#2590) 2022-10-10 09:35:15 -05:00
e675b79ea0 chore(deps): update dependency ava to v4 (#2574)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-25 07:22:02 +00:00
ca495c99fe build(deps): bump ansi-regex from 4.1.0 to 5.0.1 (#2571)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-24 19:29:00 -05:00
16795ed543 chore(deps): update dependency sinon to v14 (#2570)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-24 17:54:08 +00:00
Matt TraviandGitHub 4cd3641dbf refactor(plugins): switched from require to await import() when loading plugins (#2558) 2022-09-17 14:10:05 -07:00
Filip TammergårdandGitHub 466898b3b4 docs: fix typo (#2559) 2022-09-13 07:50:34 -07:00
Moe ShaabanandGitHub 7b7728c33c docs: fix troubleshooting git delete remote tag command (#2551) 2022-09-02 12:30:14 -05:00
Matt CookandGitHub 866e8ca4f7 docs: fix typo (#2550) 2022-09-02 09:42:21 -05:00
David GossandGitHub e5167489be docs: document that .cjs extensions are supported for config files (#2547) 2022-09-01 20:45:16 -05:00
762d0f531b chore(deps): update actions/checkout action to v3 (#2546)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-29 21:58:55 +00:00
0bd223835f chore(deps): update dependency p-retry to v4.6.2 (#2545)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-29 21:50:01 +00:00
0916886872 chore(deps): update actions/setup-node action to v3
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-29 11:14:29 -07:00
2832bbffef chore(deps): update dependency nock to v13.2.9 (#2544)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-29 18:10:06 +00:00
3bb4aec454 chore(deps): update dependency mockserver-client to v5.14.0 (#2540)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-27 04:22:03 +00:00
ee841a47c4 chore(deps): update dependency dockerode to v3.3.4 (#2539)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-27 04:13:08 +00:00
2a2db0c99d test(coverage): switched from nyc to c8 (#2538)
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2022-08-26 09:38:09 -07:00
9a513a38f7 test: replaced proxyquire with testdouble (#2537)
for #2133

Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2022-08-26 09:32:52 -07:00
Matt TraviandGitHub 5eea7c948e test(mockserver): switched to the modern mockserver/mockserver image to get multi-arch support (#2536)
fixes #2478
2022-08-26 09:26:09 -07:00
Matt TraviandGitHub 8f075227eb Revert "fix(deps): update dependency yargs to v17" (#2534)
Reverts #1912, fixes #2533

This reverts commit f419080fbf.
2022-08-23 09:48:08 -05:00
Alexander MendesandGitHub 2f4bcef33a docs: add semantic-release-react-native to plugin list (#2523) 2022-08-22 09:17:18 -05:00
f419080fbf fix(deps): update dependency yargs to v17 (#1912)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-08-22 09:15:51 -05:00
Matt TraviandGitHub 3bbf08c9d0 test(integration): upgrade the gitbox image to support arm architecture in addition to x86 (#2516) 2022-07-26 16:21:09 -05:00
846f4c23b9 build(deps): bump terser from 5.14.0 to 5.14.2 (#2513)
Bumps [terser](https://github.com/terser/terser) from 5.14.0 to 5.14.2.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-21 08:21:50 -05:00
Florian KostenzerandGitHub bd294eb63e docs(plugin-list): add semantic-release-space plugin (#2502) 2022-07-12 20:16:56 +00:00
iczellionandGitHub c69445ebea docs: remove deprecated keyword in gitlab-ci.md (#2498) 2022-07-06 02:54:22 +00:00
d80e2eab27 build(deps-dev): bump got from 11.8.3 to 11.8.5 (#2485)
Bumps [got](https://github.com/sindresorhus/got) from 11.8.3 to 11.8.5.
- [Release notes](https://github.com/sindresorhus/got/releases)
- [Commits](https://github.com/sindresorhus/got/compare/v11.8.3...v11.8.5)

---
updated-dependencies:
- dependency-name: got
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-22 23:54:31 -04:00
HonkingGooseandGitHub 9589a96239 docs: fix typos (#2476) 2022-06-16 12:57:37 -07:00
HonkingGooseandGitHub ec89babb95 docs: replace issue templates with forms (#2474)
Fix #2215
2022-06-16 11:37:04 -07:00
HonkingGooseandGitHub db620aa799 docs: fix typo (#2473) 2022-06-16 11:35:02 -07:00
HonkingGooseandGitHub dd77f1f603 docs: fix typo (#2472) 2022-06-16 11:34:41 -07:00
HonkingGooseandGitHub e66b4b59c0 docs: drop duplicate word (#2471) 2022-06-16 11:34:25 -07:00
HonkingGooseandGitHub 3387fb756d docs: fix typo (#2468) 2022-06-16 11:34:11 -07:00
Cesar SandGitHub 587bb91c9a docs(configuration.md): addChannel step is skipped when dryRun is enabled (#2465)
Add `addChannel` to the list of steps that are skipped by dryRun=true
2022-06-13 22:08:53 -07:00
05c9360475 build(deps): bump semantic-release from 19.0.0 to 19.0.3
Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 19.0.0 to 19.0.3.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](https://github.com/semantic-release/semantic-release/compare/v19.0.0...v19.0.3)

---
updated-dependencies:
- dependency-name: semantic-release
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-09 20:04:35 -07:00
f1d7ad4e35 build(deps): bump semver-regex from 3.1.3 to 3.1.4 (#2451)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-08 21:47:22 -05:00
Matt TraviandGitHub 58a226f29c fix(log-repo): use the original form of the repo url to remove the need to mask credentials (#2459)
fixes #2449
2022-06-08 21:09:47 -05:00
17d60d310e build(deps): bump npm from 8.3.1 to 8.12.0 (#2447)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matt Travi <programmer@travi.org>
2022-06-08 21:00:46 -05:00
Matt TraviandGitHub ab45ab1f8d chore(lint): disabled rules that dont apply to this project (#2408)
the performance and readability of reduce is not a concern in this project since maintainers are
familiar with the idiom and are iterating over small lists. the filter rule is disabled selectively
since the filter being identified is not Array.filter

closes #2403
2022-04-02 15:33:08 -07:00
ea389c3c88 chore(deps): update dependency yargs-parser to 13.1.2 [security] (#2402)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-29 13:34:52 -07:00
fa994db054 build(deps): bump node-fetch from 2.6.1 to 2.6.7 (#2399)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-29 09:50:40 -05:00
b79116bf6d build(deps): bump trim-off-newlines from 1.0.1 to 1.0.3
Bumps [trim-off-newlines](https://github.com/stevemao/trim-off-newlines) from 1.0.1 to 1.0.3.
- [Release notes](https://github.com/stevemao/trim-off-newlines/releases)
- [Commits](https://github.com/stevemao/trim-off-newlines/compare/v1.0.1...v1.0.3)

---
updated-dependencies:
- dependency-name: trim-off-newlines
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-29 07:33:18 -07:00
6fd7e56eb8 build(deps): bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-29 07:29:26 -07:00
Bolaji AyodejiandGitHub 2b94bb4e09 docs: update broken link to CI config recipes (#2378) 2022-02-23 11:34:41 -06:00
hong-jen kaoandGitHub b4bc1918cb docs: Correct circleci workflow (#2365) 2022-02-17 20:12:26 +00:00
Matt TraviandGitHub 2c30e268f9 Merge pull request #2333 from semantic-release/next 2022-01-17 23:37:31 -06:00
Matt Travi 0eca144bad fix(npm-plugin): upgraded to the stable version 2022-01-17 23:26:02 -06:00
Matt Travi 8097afb423 fix(npm-plugin): upgraded to the latest beta version 2022-01-17 20:16:08 -06:00
Matt TraviandGitHub 95af1e40f9 Merge pull request #2332 from semantic-release/beta 2022-01-17 19:50:06 -06:00
Matt Travi f634b8c3ca fix(npm-plugin): upgraded to the beta, which upgrades npm to v8
BREAKING CHANGE: `@semantic-release/npm` has also dropped support for node v15
2022-01-17 12:52:51 -06:00
Rich TrottandGitHub d9e5bc0604 fix: upgrade marked to resolve ReDos vulnerability (#2330)
BREAKING CHANGE: node v15 has been removed from our defined supported versions of node. this was done to upgrade to compatible versions of `marked` and `marked-terminal` that resolved the ReDoS vulnerability. removal of support of this node version should be low since it was not an LTS version and has been EOL for several months already.
2022-01-17 11:17:27 -06:00
Jaime Gómez-ObregónandGitHub dd7d664aa1 docs: fix a broken link (#2318) 2022-01-07 17:28:12 +00:00
Federico D'EreditàandGitHub cd6136d67e docs: wrong prerelease example (#2307)
The documentation says:

> If the `prerelease` property is set to `true` the `name` value will be used.

But then the example referring to this behaviour has the the `prerelease` value set to `'beta'` instead of `true`.
2021-12-21 09:24:12 -08:00
Rommy GustiawanandGitHub e62c83d805 docs: remove repeated 'with' word (#2289) 2021-12-07 16:38:58 +00:00
Matt TraviandGitHub 5d78fa4045 docs(breaking-change): highlighted the need for BREAKING CHANGE: to be in the commit footer (#2283)
since this is a common confusion point for new folks
2021-12-02 10:06:37 -08:00
Matt TraviandGitHub b64855fc57 docs(badge): mentioned referencing the commit convention (#2269) 2021-11-26 11:13:26 -08:00
Takuya FukujuandGitHub 09bcf7a86d docs: update badges to include preset names (#2266) 2021-11-25 23:31:49 -06:00
Matt TraviandGitHub 8e96b23a60 docs(issue-templates): fixed links to templates for opening issues (#2264)
and broke lines after sentences
2021-11-24 10:27:50 -08:00
Eric CrossonandGitHub 5535268ad0 docs: fix typo (#2262) 2021-11-24 10:05:42 -06:00
Alex BabelandGitHub 7f971f3a4c fix: bump @semantic-release/commit-analyzer to 9.0.2 (#2258) 2021-11-23 23:51:53 -06:00
Takuya FukujuandGitHub e6366211bb docs(troubleshooting): typo (#2254) 2021-11-21 09:09:29 -08:00
Max BrauerandGitHub f2a2deffc1 docs(recipes): fix path to recipes (#2253)
* removes link to unknown “package managers and languages” recipes
2021-11-20 14:45:06 +00:00
628e29e413 chore(deps): update dependency got to v11.8.3 (#2251)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-18 09:47:32 +00:00
Matt TraviandGitHub 8fda7fd423 docs(recipes): moved recipes to sub-directories to align with gitbook expectations (#2246) 2021-11-14 10:35:20 -08:00
Justin DietzandGitHub 52d76a2a97 docs(plugin-list): updates semantic-release-plus/docker with updated lifecycle hook. (#2243) 2021-11-12 16:07:34 -08:00
f092dd1e44 chore(deps): update dependency nock to v13.2.1 (#2242)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-12 10:37:08 +00:00
Matt TraviandGitHub 03aa7d0d50 docs(badge): switched to proper semantic-release logo (#2235) 2021-11-08 13:48:25 -06:00
Matt TraviandGitHub bc146e49b1 docs(gitbook): updated the summary document so that missing pages are rendered by gitbook (#2234) 2021-11-07 20:50:14 -08:00
5f9d1d17ab chore(deps): update dependency nock to v13.2.0 (#2233)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-08 03:28:04 +00:00
7ff71ad55f chore(deps): update dependency sinon to v12.0.1 (#2231)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-04 16:11:34 +00:00
Matt TraviandGitHub d3958b80bf Revert "chore(deps): update dependency p-retry to v5" (#2230) 2021-11-03 15:36:35 -05:00
4ae9209b1c chore(deps): update dependency p-retry to v5 (#2229)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-03 20:24:23 +00:00
32d0ab3003 chore(deps): update dependency sinon to v12 (#2227)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-03 18:14:23 +00:00
0e0705937d chore(deps): update dependency clear-module to v4.1.2 (#2226)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-03 18:06:13 +00:00
Ievgenii ShepeliukandGitHub b2b07bfc00 docs(plugins): add @eshepelyuk/semantic-release-helm-oci to plugins list (#2211)
Signed-off-by: Ievgenii Shepeliuk <eshepelyuk@gmail.com>
2021-10-30 20:32:38 +00:00
Justin PoehneltandGitHub 2ef403eb98 docs: add semantic-release-npm-deprecate plugin (#2210) 2021-10-29 12:52:53 -07:00
Matt TraviandGitHub 0d0e0a1d8f docs(node-version): consolidated and clarified the details about the required node version (#2170) 2021-10-24 02:27:16 -05:00
1e54e9e79a chore(deps): update dependency ansi-regex to 5.0.1 [security] (#2197)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-19 19:49:14 +00:00
aa866838a8 chore(deps): update dependency nock to v13.1.4
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-19 12:44:44 -07:00
Justin DietzandGitHub 8db804b7dc docs: fix plugin example (export verifyConditions, not verify) (#2192)
plugin example was exporting `verify`, not `verifyConditions`
2021-10-18 11:50:50 -07:00
askoropadandGitHub a50dc996b5 docs(plugins): add telegram-bot plugin to the plugin list (#2190) 2021-10-14 19:31:45 +00:00
Nitzan OhanaandGitHub 0495cb67b2 docs: add semantic-release-github-milestones plugin (#2181) 2021-10-11 20:26:03 +00:00
HonkingGooseandGitHub 74671f809c docs(github-actions): update workflow version, update node-version (#2175) 2021-10-05 09:20:34 -05:00
Matt TraviandGitHub 7faa7993eb docs(readme): minor updates, including formating and minor clarification (#2168) 2021-10-01 16:55:07 +00:00
ttrobischandGitHub f79e27f588 docs: add semantic-release-mattermost to the plugin list (#2163) 2021-10-01 16:47:58 +00:00
685d2b5455 chore(deps): update dependency ssh2 to 1.4.0 [security] (#2147)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-21 21:01:14 -05:00
Justin PoehneltandGitHub 0ce4846b68 docs: add section on logger usage for plugins (#2139) 2021-09-21 15:52:17 -07:00
eb32d79ce4 chore(deps): update dependency semver-regex to 3.1.3 [security] (#2144)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-21 11:48:01 -05:00
Gregor Martynus 20034829d9 build(release.yml): set node-version to 16 2021-09-17 16:53:36 -07:00
Matt TraviandGitHub 66cc2b4c7f feat(node-version): raised the minimum required version to v14.17 (#2132)
BREAKING CHANGE: the minimum required version of node is now v14.17
2021-09-17 13:05:32 -07:00
1632e1adac chore(deps): update dependency dockerode to v3.3.1 (#2113)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-07 07:02:37 +00:00
0390af32b6 chore(deps): update dependency sinon to v11.1.2 (#2108)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-04 23:46:49 +00:00
e58b76e700 chore(deps): update dependency nock to v13.1.3 (#2107)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-04 23:29:44 +00:00
5e228a1cd1 chore(deps): update dependency codecov to v3.8.3 (#2106)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-04 23:11:33 +00:00
RozandGitHub 23d2bc2842 docs: fix broken link on github actions recipe (#2102)
The link to the secrets and environment variables was broken since the documentation changed.
I pointed the link to the URL that made most sense, since users can choose to create the secret wherever they want.
2021-09-03 16:40:59 +00:00
Gregor MartynusandGitHub b4200b05cd ci(test): set node version explicitly in test job (#2092) 2021-08-25 12:14:40 -07:00
Matt TraviandGitHub ea52e1775a fix(engines): fixed defined node version to account for the higher requirement from the npm plugin (#2088) 2021-08-25 12:01:16 -07:00
Matt TraviandGitHub 5edff69580 fix(marked): reverted upgrade to v3 (#2087)
since marked v3 requires node v12
2021-08-23 15:34:58 -05:00
6e4beb8314 fix(deps): update dependency marked to v3
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-08-15 22:58:06 -07:00
ebad322318 chore(deps): update dependency path-parse to 1.0.7 [security] (#2072)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-08-11 23:11:48 -05:00
88e423b828 chore(deps): update dependency p-retry to v4.6.1 (#2042)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-07-19 13:17:04 -07:00
Oscar DominguezandGitHub a4f0ff70fe ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows (#2038) 2021-07-19 10:39:55 -07:00
ee3068eb6a chore(deps): update dependency nock to v13.1.1 (#2034)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-07-18 10:06:40 -07:00
Hugh RawlinsonandGitHub 04b6046e1f docs(branches): minor typo fixes (#2033) 2021-07-17 14:53:43 -07:00
fa847e2b87 chore(deps): update dependency p-retry to v4.6.0 (#2004)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-07-08 21:39:19 +00:00
Kyle TandGitHub 413ffd2a4b docs(circleci): Update CircleCI recipes config (#2018)
Updates the included CircleCI config file example.

* Now uses 2.1 style config
* Uses Node Orb
* Use pre-defined node/test job
* Uses Matrix jobs to test multiple node versions.
* Updated Node versions
* Using new CircleCI docker images (from node executor)
* Updated language/terminology in description
2021-07-08 13:14:29 -07:00
143c8981bf chore(deps): update dependency js-yaml to v4 (#1752)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Matt Travi <programmer@travi.org>
2021-07-02 00:07:46 -05:00
Moritz WiesingerandGitHub cf000687c4 docs(recipes): fix some typos (#1999)
Signed-off-by: Moritz Wiesinger <moritz.wiesinger@dynatrace.com>
2021-07-01 09:17:34 -07:00
Fernando RojoandGitHub 1463eb42cb docs(plugins): clarify order of execution (#1989) 2021-06-25 14:06:57 -05:00
AxieumandGitHub 80e1665037 fix: corrected spelling of invalid plugin config error (#1979) 2021-06-15 09:52:19 -05:00
37765ef36d chore(deps): update dependency dockerode to v3.3.0 (#1977)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-06-11 08:56:45 -07:00
a7a1e6d28f chore(deps): update dependency sinon to v11 (#1976)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-06-11 13:38:45 +00:00
59bf862d4a chore(deps): update dependency nock to v13.1.0 (#1975)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-06-10 12:45:53 -07:00
78a63a7de0 chore(deps): update dependency trim-newlines to 3.0.1 [security] (#1974)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-06-08 22:31:00 -05:00
61f94c00ab build(deps): bump normalize-url from 4.5.0 to 4.5.1 (#1973)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-08 22:03:00 -05:00
Justin DietzandGitHub 7452eaf2cd docs: adds updated docker plugin that supports major, minor tagging (#1963) 2021-06-03 09:31:49 -07:00
c229888cc0 chore(deps): update dependency fs-extra to v10 (#1955)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-06-01 22:14:25 +00:00
HonkingGooseandGitHub 29d34788ff docs(README): improve sentence (#1962) 2021-06-01 13:48:53 -07:00
Aki MäkinenandGitHub fe0ac417cf docs(plugin developer guide): correction, additional details / advanced (#1961)
A correction to the earlier documentation: the "nextRelease" object is NOT similar to the
lastRelease and there are some differences. Because of this, the object is now documented as a
separate entry. Added also information on how the error handling should be done so that
semantic-release would be able to handle errors from plugins properly and call "fail" lifecycle
plugins. Included some more advanced information on how the analyzeCommits-lifecycle plugins work
and how the result of the initial analyzer can be overridden. This is an edge case, but could happen
and is good to understand.
2021-05-31 10:15:47 -07:00
3edc917c7c chore(deps): update dependency tempy to v1.0.1 (#1946)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-05-27 02:54:20 +00:00
8bc98c33c9 chore(deps): update dependency browserslist to 4.16.5 [security] (#1954)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-05-26 20:46:59 -05:00
Josh SullivanandGitHub 6427210b83 docs(workflow-configurator): fix single typo (#1892) 2021-05-26 10:57:54 -07:00
4c1c992869 chore(deps): update dependency sinon to v10 (#1941)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-05-22 01:06:53 +00:00
a3a9907368 chore(deps): update dependency codecov to v3.8.2 (#1940)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-05-21 23:16:45 +00:00
7fbab56a98 docs: add semantic-release-telegram to the list of community plugins (#1945)
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2021-05-21 14:30:44 -07:00
Dmytro PustovitandGitHub 7dae2a9f43 docs: add heroku to list of community plugins (#1920) 2021-05-21 14:29:28 -07:00
Ryan SonshineandGitHub 13f6a725a1 docs(plugins-list): add semantic-release-codeartifact (#1939) 2021-05-17 07:50:18 -07:00
Gregor MartynusandGitHub 55194c106e fix: bump minimal version of lodash to address CVE-2021-23337 (#1931) 2021-05-12 11:37:06 -07:00
mhagnumdwandGitHub e24ef71e33 docs(distribution-channels): fix branch name (#1925) 2021-05-09 22:40:32 -05:00
Aki MäkinenandGitHub 0435e35fee docs(Plugin Developer Guide): More detailed lifecycle list and context descriptions (#1880)
* docs(Plugin Developer Guide): More detailed lifecycle list and context descriptions

This commit will improve the following in the Plugin developer guide:
  * Lifecyle list more complete (previous was missing some lifecycles)
  * Context object has been now described in more detail per lifecycle
  * Some readability/maintainability fixes to the markdown file itself
    to make it easier to edit and read in an editor.

* docs(Plugin Developer Guide): Added missing context field to analyzeCommits lifecycle documentation

analyzeCommits lifecycle context was missing documentation for "commits" list.

* docs(developer-guide): remove line breaks added in an earlier commit

As per requested in the code review, the line breaks that were added in an earlier commit are now
removed. While this does make reading the text just slightly more difficult (to see the whole
picture), the benefit of making code reviews easier does outweight the admittedly small benefit.
2021-04-25 15:14:03 -07:00
1d1b52a7dc chore(deps): update dependency p-retry to v4.5.0 (#1885)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-04-10 14:57:32 +00:00
Aki MäkinenandGitHub 72522c3570 docs(Plugin Developer Guide): Update lifecycle list (#1874)
The old list was missing analyzeCommits lifecycle and the verification lifecycle was incorrectly listed as "verify", when it should currently be "verifyConditions" in order to properly load.
2021-04-07 14:47:41 -07:00
Oscar DominguezandGitHub 5489489dda docs(github-actions): example suggests using ubuntu-latest (#1867)
instead of a concrete version of Ubuntu
2021-03-31 10:39:08 -07:00
Mohammed ragab aliandGitHub 12337175c6 docs: Add article to explain semantic release (#1856) 2021-03-30 10:32:07 -07:00
8fa4f9a750 chore(deps): lock file maintenance (#1861)
* chore(deps): lock file maintenance

* build(package): lock file

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2021-03-30 10:12:16 -07:00
f668935993 chore(deps): update dependency got to v11.8.2 (#1858)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-03-24 15:42:59 -07:00
0f3c4148c7 chore(deps): lock file maintenance (#1848)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-03-24 19:52:13 +00:00
Kristian HeljasandGitHub 2e4b901c4f docs: use consistent version number for tag recovery (#1857) 2021-03-24 09:19:06 -07:00
971a5e0d16 chore(deps): update dependency nock to v13.0.11 (#1844)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-03-11 15:09:05 -08:00
44b3344b91 fix(deps): update dependency hosted-git-info to v4 (#1838)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-03-11 12:01:43 -08:00
renovate[bot]andGitHub 046a845a9e chore(deps): lock file maintenance (#1835) 2021-03-08 10:23:39 -08:00
LukasandGitHub 48def0c4cc docs: fix links to gitlab releases documentation (#1834) 2021-03-07 12:44:08 -08:00
2b6c9ba093 docs: update documentation for addNote function (#1833)
Co-Authored-By: Virgil <virgilwashere@users.noreply.github.com>
2021-03-04 16:19:31 -08:00
thislooksfunandGitHub 07f12b9df2 fix(deps): peer dependecy error with marked-terminal (#1829) 2021-03-03 12:09:32 -08:00
2272ce3059 chore(deps): lock file maintenance (#1826)
* chore(deps): lock file maintenance

* build(package): lock file

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2021-03-01 10:07:51 -08:00
NickandGitHub 3ecc196d8a feat(config): Use cosmiconfig defaults to support .cjs config files (#1815)
This change adds support for `*.cjs` config files by removing the
explicit use of `searchPlaces` options and relying and the default
search places generated by `cosmicconfig`.  As per the docs for
[`cosmicconfig`][cc], the defaults include all the extensions/formats
previously supported by semantic-release in addition to the new .cjs
variants.

Resolves [#1814][issue].

[issue]: https://github.com/semantic-release/semantic-release/issues/1814
[cc]: https://github.com/davidtheclark/cosmiconfig#searchplaces
2021-02-25 21:04:04 -06:00
Micael JarniacandGitHub acf8bc4d21 docs: fix missing whitespace (#1821) 2021-02-24 16:20:35 -08:00
Kiran KoiralaandGitHub 67dfb676bc docs(README): change link to Angular's Contribution guidelines instead of Angular.js's Developers guide (#1817) 2021-02-23 10:42:30 -08:00
f25c3527df chore(deps): lock file maintenance (#1813)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-22 06:51:31 +00:00
6013a5633e chore(deps): update dependency p-retry to v4.4.0 (#1803)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-15 19:43:36 +00:00
d2782484c8 chore(deps): lock file maintenance (#1800)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-15 04:18:03 +00:00
34e5ddad12 chore(deps): update dependency js-yaml to v3.14.1 (#1797)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-13 10:17:05 +00:00
mcnesiumandGitHub a9be97b56b fix: update link to GitLab CI introduction (#1794) 2021-02-12 13:45:36 -08:00
Alexis SaettlerandGitHub 85bc213f04 docs: add semantic-release-github-pullrequest to list of community plugins (#1790) 2021-02-11 09:09:58 -08:00
Matt TraviandGitHub 8e3a6cbef2 docs(discussions): updated spectrum references to point to discussions instead (#1782)
for #1764
2021-02-09 08:22:21 -08:00
a2eaed086f fix(deps): update dependency marked to v2
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-08 07:45:59 -08:00
b22e591c96 chore(deps): lock file maintenance (#1779)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-08 02:04:34 +00:00
Matt TraviandGitHub fc32afa776 build(engine-strict): strictly enforced node version compatibility for dependencies (#1763) 2021-02-04 09:26:18 -08:00
8ea81ae6c9 chore(deps): update dependency delay to v5 (#1771)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-01 10:01:31 -08:00
e4002c8bd7 chore(deps): lock file maintenance (#1770)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-01 04:03:39 +00:00
d738dd0fb7 chore(deps): lock file maintenance (#1769)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-01 01:56:15 +00:00
4c7222d648 chore(deps): update dependency delay to v4.4.1 (#1768)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-30 10:47:21 +00:00
54bf761f7e chore(deps): update dependency nock to v13.0.7 (#1767)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-30 06:05:46 +00:00
ea5e813192 chore(deps): lock file maintenance (#1761)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-25 23:26:59 +00:00
Gregor Martynus a7f008253c style: prettier 2021-01-25 13:48:03 -08:00
Gregor Martynus ece7275743 test: bump retries in gitbox.createRepo() helper, see https://github.com/semantic-release/semantic-release/pull/1761\#issuecomment-767122221 2021-01-25 13:27:20 -08:00
16a9fb00e9 chore(deps): update dependency sinon to v9.2.4 (#1760)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-23 13:28:47 +00:00
854d643bed chore(deps): update dependency p-retry to v4.3.0 (#1759)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-23 11:16:17 +00:00
969e460948 fix(deps): update dependency get-stream to v6 (#1748)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-22 12:43:10 -08:00
ab227451fa docs: clarify renovate/** branches (#1757)
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2021-01-22 11:44:54 -08:00
0f37fc3aa6 chore(deps): update dependency tempy to v1 (#1755)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-21 08:33:15 +00:00
fa7080e0d4 chore(deps): update dependency nock to v13 (#1754)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-21 07:00:55 +00:00
0a86d61a00 chore(deps): update dependency sinon to v9.2.3 (#1750)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-21 04:05:41 +00:00
d53e2066cc chore(deps): update dependency got to v11.8.1 (#1749)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-21 03:06:00 +00:00
47450fb3b1 chore(deps): update dependency fs-extra to v9.1.0 (#1747)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-20 17:04:51 -08:00
fb5db83adc chore(deps): update dependency ava to v3.15.0 (#1746)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-20 17:04:39 -08:00
8262832cda fix(deps): update dependency execa to v5 (#1745)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-20 17:00:27 -08:00
cc74a4c890 fix(deps): update dependency cosmiconfig to v7 (#1742)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-20 16:59:32 -08:00
a3c49428e3 chore(deps): pin dependencies (#1744)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-20 15:42:59 -08:00
d95d80a0aa chore(deps): update actions/setup-node action to v2 (#1741)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-01-20 14:19:25 -08:00
b5aa853b22 ci: replace travis with actions, setup renovate (#1699)
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2021-01-20 14:07:16 -08:00
Josh SorefandGitHub 32a2c91d7c fix: pin initial branch to master (#1740) 2021-01-20 11:20:48 -08:00
Roland WeissandGitHub d2ec8931bc fix(deps): update to yargs 16.2.0 (#1739)
Signed-off-by: Roland Weiss <roland.weiss@mobi.ch>
2021-01-19 08:46:14 -08:00
Thomas ZimmermannandGitHub 9f57b84aaa fix: add logging for top-level errors (#1736) 2021-01-15 14:31:07 -08:00
Vegard ØklandandGitHub c5719101cc docs: clarify node vs npm in FAQ (#1731) thanks @vegardok 2021-01-15 11:50:33 -08:00
Mo SattlerandGitHub 7581aa8584 docs: fix a typo in github-actions.md (#1735) 2021-01-15 09:35:05 -06:00
122 changed files with 21650 additions and 5105 deletions
+2
View File
@@ -0,0 +1,2 @@
# style: prettier (#2670)
b06c9bbe4c6be121c5561b356d8c465c1cadffba
-21
View File
@@ -1,21 +0,0 @@
---
name: Bug report
about: Something not working as expected
---
## Current behavior
<!-- Describe how the issue manifests. -->
## Expected behavior
<!-- Describe what the desired behavior would be. -->
## Environment
- **semantic-release** version: <!-- Version set in package.json devDpendencies -->
- CI environment: <!-- CI service name -->
- Plugins used: <!-- List semantic-release plugin used if any -->
- **semantic-release** configuration: <!-- link to your repository or relevant part of the semantic-release config -->
- CI logs: <!-- link to your CI logs or semantic-release logs -->
+51
View File
@@ -0,0 +1,51 @@
name: Bug Report
description: Something not working as expected
body:
- type: textarea
attributes:
label: Current behavior
description: Describe how the issue manifests.
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: Describe what the desired behavior would be.
validations:
required: true
- type: input
attributes:
label: "`semantic-release` version"
description: Version set in `package.json` `devDpendencies`.
validations:
required: true
- type: input
attributes:
label: CI environment
description: CI service name.
validations:
required: true
- type: textarea
attributes:
label: Plugins used
description: List `semantic-release` plugin used, if any.
validations:
required: false
- type: textarea
attributes:
label: "`semantic-release` configuration"
description: Link to your repository or relevant part of the `semantic-release` config.
validations:
required: true
- type: textarea
attributes:
label: CI logs
description: Link to your CI logs or `semantic-release` logs.
validations:
required: true
@@ -1,17 +0,0 @@
---
name: Feature request
about: Wouldnt it be nice if semantic-release could ...
---
## New feature motivation
<!-- Describe the context, the use-case and the advantages of the feature request. -->
## New feature description
<!-- Describe the functional changes that would have to be made in semantic-release or its plugins. -->
## New feature implementation
<!-- Optionally describe the technical changes to be made in semantic-release or its plugins. -->
@@ -0,0 +1,23 @@
name: Feature request
description: Wouldn't it be nice if `semantic-release` could ...
body:
- type: textarea
attributes:
label: New feature motivation
description: Describe the context, the use-case and the advantages of the feature request.
validations:
required: true
- type: textarea
attributes:
label: New feature description
description: Describe the functional changes that would have to be made in `semantic-release` or its plugins.
validations:
required: true
- type: textarea
attributes:
label: New feature implementation
description: Optionally describe the technical changes to be made in `semantic-release` or its plugins.
validations:
required: false
@@ -1,13 +0,0 @@
---
name: New plugin suggestion
about: Integrate with a new platform, etc
---
## New plugin motivation
<!-- Describe the reasons to create a new plugin and why it's not covered by the existing ones. -->
## Third-party documentation
<!-- Provide explanation and documentation links for the platform to integrate with. -->
@@ -0,0 +1,16 @@
name: New plugin suggestion
description: Integrate with a new platform, etc
body:
- type: textarea
attributes:
label: New plugin motivation
description: Describe the reasons to create a new plugin and why it's not covered by the existing ones.
validations:
required: true
- type: textarea
attributes:
label: Third-party documentation
description: Provide explanation and documentation links for the platform to integrate with.
validations:
required: true
+33
View File
@@ -0,0 +1,33 @@
name: Release
"on":
push:
branches:
- master
- next
- beta
- "*.x"
permissions:
contents: read # for checkout
jobs:
release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
cache: npm
node-version: lts/*
- run: npm clean-install
- run: npm audit signatures
# pinned version updated automatically by Renovate.
# details at https://semantic-release.gitbook.io/semantic-release/usage/installation#global-installation
- run: npx semantic-release@21.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_NPM_TOKEN }}
+56
View File
@@ -0,0 +1,56 @@
name: Test
on:
push:
branches:
- master
# renovate/** branches are generated by https://github.com/apps/renovate
- renovate/**
pull_request:
types:
- opened
- synchronize
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
test_matrix:
strategy:
matrix:
node-version:
- 18.0.0
- 19
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- run: git config --global user.name github-actions
- run: git config --global user.email github-actions@github.com
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm clean-install
- name: Ensure dependencies are compatible with the version of node
run: npx ls-engines
- run: npm run test:ci
# separate job to set as required in branch protection,
# as the build names above change each time Node versions change
test:
runs-on: ubuntu-latest
needs: test_matrix
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: lts/*
cache: npm
- run: npm clean-install
- run: npm audit signatures
- run: npm run lint
-4
View File
@@ -125,10 +125,6 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
# Lockfiles
package-lock.json
yarn.lock
# Gitbook
_book
-1
View File
@@ -1 +0,0 @@
package-lock=false
-11
View File
@@ -1,11 +0,0 @@
version: ~> 1.0
services:
- docker
import:
- .travis/node.yml
- .travis/node-versions.yml
- .travis/semantic-release.yml
- .travis/greenkeeper.yml
- .travis/codecov.yml
-2
View File
@@ -1,2 +0,0 @@
after_success:
- npm run codecov
-3
View File
@@ -1,3 +0,0 @@
branches:
only:
- /^greenkeeper.*$/
-3
View File
@@ -1,3 +0,0 @@
node_js:
- 12
- 10.18
-11
View File
@@ -1,11 +0,0 @@
language: node_js
cache:
npm: false
# Retry install on fail to avoid failing a build on network/disk/external errors
install:
- travis_retry npm install
script:
- npm run test
-15
View File
@@ -1,15 +0,0 @@
branches:
only:
- master
- next
- beta
- /^\d+\.(\d+|x)(\.x)?$/
jobs:
include:
- stage: release
node_js: lts/*
install:
- travis_retry npm install
script:
- npm run semantic-release
-1
View File
@@ -1 +0,0 @@
--install.no-lockfile true
+10 -10
View File
@@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
+48 -17
View File
@@ -3,6 +3,7 @@
✨ Thanks for contributing to **semantic-release**! ✨
As a contributor, here are the guidelines we would like you to follow:
- [Code of conduct](#code-of-conduct)
- [How can I contribute?](#how-can-i-contribute)
- [Using the issue tracker](#using-the-issue-tracker)
@@ -20,76 +21,96 @@ Help us keep **semantic-release** open and inclusive. Please read and follow our
### Improve documentation
As a **semantic-release** user, you are the perfect candidate to help us improve our documentation: typo corrections, clarifications, more examples, new [recipes](docs/recipes/README.md), etc. Take a look at the [documentation issues that need help](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Asemantic-release+archived%3Afalse+label%3A%22help+wanted%22+label%3Adocs+).
As a **semantic-release** user, you are the perfect candidate to help us improve our documentation: typo corrections, clarifications, more examples, new [recipes](docs/recipes), etc. Take a look at the [documentation issues that need help](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Asemantic-release+archived%3Afalse+label%3A%22help+wanted%22+label%3Adocs+).
Please follow the [Documentation guidelines](#documentation).
### Give feedback on issues
Some issues are created without information requested in the [Bug report guideline](#bug-report). Help make them easier to resolve by adding any relevant information.
Some issues are created without information requested in the [Bug report guideline](#bug-report).
Help make them easier to resolve by adding any relevant information.
Issues with the [design label](https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Asemantic-release+archived%3Afalse+label%3Adesign) are meant to discuss the implementation of new features. Participating in the discussion is a good opportunity to get involved and influence the future direction of **semantic-release**.
Issues with the [design label](https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Asemantic-release+archived%3Afalse+label%3Adesign) are meant to discuss the implementation of new features.
Participating in the discussion is a good opportunity to get involved and influence the future direction of **semantic-release**.
### Fix bugs and implement features
Confirmed bugs and ready-to-implement features are marked with the [help wanted label](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Asemantic-release+archived%3Afalse+label%3A%22help+wanted%22). Post a comment on an issue to indicate you would like to work on it and to request help from the [@semantic-release/maintainers](https://github.com/orgs/semantic-release/teams/contributors) and the community.
Confirmed bugs and ready-to-implement features are marked with the [help wanted label](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Asemantic-release+archived%3Afalse+label%3A%22help+wanted%22).
Post a comment on an issue to indicate you would like to work on it and to request help from the [@semantic-release/maintainers](https://github.com/orgs/semantic-release/teams/contributors) and the community.
## Using the issue tracker
The issue tracker is the channel for [bug reports](#bug-report), [features requests](#feature-request) and [submitting pull requests](#submitting-a-pull-request) only. Please use the [Support](docs/support/README.md) and [Get help](README.md#get-help) sections for support, troubleshooting and questions.
The issue tracker is the channel for [bug reports](#bug-report), [features requests](#feature-request) and [submitting pull requests](#submitting-a-pull-request) only.
Please use the [Support](docs/support/README.md) and [Get help](README.md#get-help) sections for support, troubleshooting and questions.
Before opening an issue or a Pull Request, please use the [GitHub issue search](https://github.com/issues?utf8=%E2%9C%93&q=user%3Asemantic-release) to make sure the bug or feature request hasn't been already reported or fixed.
### Bug report
A good bug report shouldn't leave others needing to chase you for more information. Please try to be as detailed as possible in your report and fill the information requested in the [Bug report template](https://github.com/semantic-release/semantic-release/issues/new?template=bug-report.md).
A good bug report shouldn't leave others needing to chase you for more information.
Please try to be as detailed as possible in your report and fill the information requested in the [bug report template](https://github.com/semantic-release/semantic-release/issues/new?template=01_bug_report.md).
### Feature request
Feature requests are welcome, but take a moment to find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible and fill the information requested in the [Feature request template](https://github.com/semantic-release/semantic-release/issues/new?template=feature-request.md).
Feature requests are welcome, but take a moment to find out whether your idea fits with the scope and aims of the project.
It's up to you to make a strong case to convince the project's developers of the merits of this feature.
Please provide as much detail and context as possible and fill the information requested in the [feature request template](https://github.com/semantic-release/semantic-release/issues/new?template=02_feature_request.md).
### New plugin request
[Plugins](docs/usage/plugins.md) are a great way to extend **semantic-release** capabilities, integrate with other systems and support new project type. Please provide as much detail and context as possible and fill the information requested in the [New plugin request template](https://github.com/semantic-release/semantic-release/issues/new?template=plugin-request.md).
[Plugins](docs/usage/plugins.md) are a great way to extend **semantic-release** capabilities, integrate with other systems and support new project type.
Please provide as much detail and context as possible and fill the information requested in the [plugin suggestion template](https://github.com/semantic-release/semantic-release/issues/new?template=03_plugin_suggestion.md).
## Submitting a Pull Request
Good pull requests, whether patches, improvements, or new features, are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.
Good pull requests, whether patches, improvements, or new features, are a fantastic help.
They should remain focused in scope and avoid containing unrelated commits.
**Please ask first** before embarking on any significant pull requests (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
**Please ask first** before embarking on any significant pull requests (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's maintainers might not want to merge into the project.
If you have never created a pull request before, welcome 🎉 😄. [Here is a great tutorial](https://opensource.guide/how-to-contribute/#opening-a-pull-request) on how to send one :)
If you have never created a pull request before, welcome 🎉 😄.
[Here is a great tutorial](https://opensource.guide/how-to-contribute/#opening-a-pull-request) on how to send one :)
Here is a summary of the steps to follow:
1. [Set up the workspace](#set-up-the-workspace)
2. If you cloned a while ago, get the latest changes from upstream and update dependencies:
```bash
$ git checkout master
$ git pull upstream master
$ rm -rf node_modules
$ npm install
```
3. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix:
```bash
$ git checkout -b <topic-branch-name>
```
4. Make your code changes, following the [Coding rules](#coding-rules)
5. Push your topic branch up to your fork:
```bash
$ git push origin <topic-branch-name>
```
6. [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request) with a clear title and description.
**Tips**:
- For ambitious tasks, open a Pull Request as soon as possible with the `[WIP]` prefix in the title, in order to get feedback and help from the community.
- [Allow semantic-release maintainers to make changes to your Pull Request branch](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork). This way, we can rebase it and make some minor changes if necessary. All changes we make will be done in new commit and we'll ask for your approval before merging them.
- [Allow semantic-release maintainers to make changes to your Pull Request branch](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
This way, we can rebase it and make some minor changes if necessary.
All changes we make will be done in new commit, and we'll ask for your approval before merging them.
## Coding rules
### Source code
To ensure consistency and quality throughout the source code, all code modifications must have:
- No [linting](#lint) errors
- A [test](#tests) for every possible case introduced by your code change
- **100%** test coverage
@@ -100,6 +121,7 @@ To ensure consistency and quality throughout the source code, all code modificat
### Documentation
To ensure consistency and quality, all documentation modifications must:
- Refer to brand in [bold](https://help.github.com/articles/basic-writing-and-formatting-syntax/#styling-text) with proper capitalization, i.e. **GitHub**, **semantic-release**, **npm**
- Prefer [tables](https://help.github.com/articles/organizing-information-with-tables) over [lists](https://help.github.com/articles/basic-writing-and-formatting-syntax/#lists) when listing key values, i.e. List of options with their description
- Use [links](https://help.github.com/articles/basic-writing-and-formatting-syntax/#links) when you are referring to:
@@ -121,6 +143,7 @@ To ensure consistency and quality, all documentation modifications must:
#### Atomic commits
If possible, make [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit), which means:
- a commit should contain exactly one self-contained functional change
- a functional change should be contained in exactly one commit
- a commit should not create an inconsistent state (such as test errors, linting errors, partial fix, feature with documentation etc...)
@@ -129,7 +152,8 @@ A complex feature can be broken down into multiple commits as long as each one m
#### Commit message format
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**:
Each commit message consists of a **header**, a **body** and a **footer**.
The header has a special format that includes a **type**, a **scope** and a **subject**:
```commit
<type>(<scope>): <subject>
@@ -145,14 +169,15 @@ The **footer** can contain a [closing reference to an issue](https://help.github
#### Revert
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit.
In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
#### Type
The type must be one of the following:
| Type | Description |
|--------------|-------------------------------------------------------------------------------------------------------------|
| ------------ | ----------------------------------------------------------------------------------------------------------- |
| **build** | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
| **ci** | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) |
| **docs** | Documentation only changes |
@@ -172,13 +197,16 @@ The subject contains succinct description of the change:
- no dot (.) at the end
#### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.
#### Footer
The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**.
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines.
The rest of the commit message is then used for this.
#### Examples
@@ -219,11 +247,13 @@ $ npm install
### Lint
All the [semantic-release](https://github.com/semantic-release) repositories use [XO](https://github.com/sindresorhus/xo) for linting and [Prettier](https://prettier.io) for formatting. Prettier formatting will be automatically verified and fixed by XO.
All the [semantic-release](https://github.com/semantic-release) repositories use [XO](https://github.com/sindresorhus/xo) for linting and [Prettier](https://prettier.io) for formatting.
Prettier formatting will be automatically verified and fixed by XO.
Before pushing your code changes make sure there are no linting errors with `npm run lint`.
**Tips**:
- Most linting errors can be automatically fixed with `npm run lint -- --fix`.
- Install the [XO plugin](https://github.com/sindresorhus/xo#editor-plugins) for your editor to see linting errors directly in your editor and automatically fix them on save.
@@ -240,6 +270,7 @@ $ npm run test
```
**Tips:** During development you can:
- run only a subset of test files with `ava <glob>`, for example `ava test/mytestfile.test.js`
- run in watch mode with `ava -w` to automatically run a test file when you modify it
- run only the test you are working on by adding [`.only` to the test definition](https://github.com/avajs/ava#running-specific-tests)
+40 -41
View File
@@ -1,20 +1,14 @@
<h1 align="center" style="border-bottom: none;">📦🚀 semantic-release</h1>
<h3 align="center">Fully automated version management and package publishing</h3>
<p align="center">
<a href="https://spectrum.chat/semantic-release">
<img alt="Join the community on Spectrum" src="https://withspectrum.github.io/badge/badge.svg">
<a href="https://github.com/semantic-release/semantic-release/discussions">
<img alt="Join the community on GitHub Discussions" src="https://img.shields.io/badge/Join%20the%20community-on%20GitHub%20Discussions-blue">
</a>
<a href="https://travis-ci.org/semantic-release/semantic-release">
<img alt="Travis" src="https://img.shields.io/travis/semantic-release/semantic-release/master.svg">
</a>
<a href="https://codecov.io/gh/semantic-release/semantic-release">
<img alt="Codecov" src="https://img.shields.io/codecov/c/github/semantic-release/semantic-release/master.svg">
</a>
<a href="https://greenkeeper.io">
<img alt="Greenkeeper" src="https://badges.greenkeeper.io/semantic-release/semantic-release.svg">
<a href="https://github.com/semantic-release/semantic-release/actions?query=workflow%3ATest+branch%3Amaster">
<img alt="Build states" src="https://github.com/semantic-release/semantic-release/workflows/Test/badge.svg">
</a>
<a href="#badge">
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
<img alt="semantic-release: angular" src="https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release">
</a>
</p>
<p align="center">
@@ -29,9 +23,9 @@
</a>
</p>
**semantic-release** automates the whole package release workflow including: determining the next version number, generating the release notes and publishing the package.
**semantic-release** automates the whole package release workflow including: determining the next version number, generating the release notes, and publishing the package.
This removes the immediate connection between human emotions and version numbers, strictly following the [Semantic Versioning](http://semver.org) specification.
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.
> 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)
@@ -43,48 +37,54 @@ This removes the immediate connection between human emotions and version numbers
- Notify maintainers and users of new releases
- Use formalized commit message convention to document changes in the codebase
- Publish on different distribution channels (such as [npm dist-tags](https://docs.npmjs.com/cli/dist-tag)) based on git merges
- Integrate with your [continuous integration workflow](docs/recipes/README.md#ci-configurations)
- Integrate with your [continuous integration workflow](docs/recipes/release-workflow/README.md#ci-configurations)
- Avoid potential errors associated with manual releases
- Support any [package managers and languages](docs/recipes/README.md#package-managers-and-languages) via [plugins](docs/usage/plugins.md)
- Support any [package managers and languages](docs/recipes/release-workflow/README.md#package-managers-and-languages) via [plugins](docs/usage/plugins.md)
- Simple and reusable configuration via [shareable configurations](docs/usage/shareable-configurations.md)
- Support for [npm package provenance](https://github.com/semantic-release/npm#npm-provenance) that promotes increased supply-chain security via signed attestations on GitHub Actions
## How does it work?
### Commit message format
**semantic-release** uses the commit messages to determine the type of changes in the codebase. Following formalized conventions for commit messages, **semantic-release** automatically determines the next [semantic version](https://semver.org) number, generates a changelog and publishes the release.
**semantic-release** uses the commit messages to determine the consumer impact of changes in the codebase.
Following formalized conventions for commit messages, **semantic-release** automatically determines the next [semantic version](https://semver.org) number, generates a changelog and publishes the release.
By default **semantic-release** uses [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines). The commit message format can be changed with the [`preset` or `config` options](docs/usage/configuration.md#options) of the [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer#options) and [@semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator#options) plugins.
By default, **semantic-release** uses [Angular Commit Message Conventions](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format).
The commit message format can be changed with the [`preset` or `config` options](docs/usage/configuration.md#options) of the [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer#options) and [@semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator#options) plugins.
Tools such as [commitizen](https://github.com/commitizen/cz-cli) or [commitlint](https://github.com/conventional-changelog/commitlint) can be used to help contributors and enforce valid commit messages.
Here is an example of the release type that will be done based on a commit messages:
The table below shows which commit message gets you which release type when `semantic-release` runs (using the default configuration):
| Commit message | Release type |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| `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 |
| Commit message | Release type |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
| `fix(pencil): stop graphite breaking when too much pressure applied` | ~~Patch~~ Fix Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| `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) |
### Automation with CI
**semantic-release** is meant to be executed on the CI environment after every successful build on the release branch. This way no human is directly involved in the release process and the releases are guaranteed to be [unromantic and unsentimental](http://sentimentalversioning.org).
**semantic-release** is meant to be executed on the CI environment after every successful build on the release branch.
This way no human is directly involved in the release process and the releases are guaranteed to be [unromantic and unsentimental](http://sentimentalversioning.org).
### Triggering a release
For each new commits added to one of the release branches (for example `master`, `next`, `beta`), with `git push` or by merging a pull request or merging from another branch, a CI build is triggered and runs the `semantic-release` command to make a release if there are codebase changes since the last release that affect the package functionalities.
For each new commit added to one of the release branches (for example: `master`, `next`, `beta`), with `git push` or by merging a pull request or merging from another branch, a CI build is triggered and runs the `semantic-release` command to make a release if there are codebase changes since the last release that affect the package functionalities.
**semantic-release** offers various ways to control the timing, the content and the audience of published releases. See example workflows in the following recipes:
- [Using distribution channels](docs/recipes/distribution-channels.md#publishing-on-distribution-channels)
- [Maintenance releases](docs/recipes/maintenance-releases.md#publishing-maintenance-releases)
- [Pre-releases](docs/recipes/pre-releases.md#publishing-pre-releases)
**semantic-release** offers various ways to control the timing, the content and the audience of published releases.
See example workflows in the following recipes:
- [Using distribution channels](docs/recipes/release-workflow/distribution-channels.md#publishing-on-distribution-channels)
- [Maintenance releases](docs/recipes/release-workflow/maintenance-releases.md#publishing-maintenance-releases)
- [Pre-releases](docs/recipes/release-workflow/pre-releases.md#publishing-pre-releases)
### Release steps
After running the tests, the command `semantic-release` will execute the following steps:
| Step | Description |
|-------------------|---------------------------------------------------------------------------------------------------------------------------------|
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Verify Conditions | Verify all the conditions to proceed with the release. |
| Get last release | Obtain the commit corresponding to the last release by analyzing [Git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). |
| Analyze commits | Determine the type of release based on the commits added since the last release. |
@@ -98,10 +98,11 @@ After running the tests, the command `semantic-release` will execute the followi
## Requirements
In order to use **semantic-release** you need:
- To host your code in a [Git repository](https://git-scm.com)
- Use a Continuous Integration service that allows you to [securely set up credentials](docs/usage/ci-configuration.md#authentication)
- Git CLI version [2.7.1 or higher](docs/support/FAQ.md#why-does-semantic-release-require-git-version--271) installed in your Continuous Integration environment
- [Node.js](https://nodejs.org) version [10.18 or higher](docs/support/FAQ.md#why-does-semantic-release-require-node-version--1018) installed in your Continuous Integration environment
- A Git CLI version that meets [our version requirement](docs/support/git-version.md) installed in your Continuous Integration environment
- A [Node.js](https://nodejs.org) version that meets [our version requirement](docs/support/node-version.md) installed in your Continuous Integration environment
## Documentation
@@ -117,10 +118,9 @@ In order to use **semantic-release** you need:
- [Plugins](docs/extending/plugins-list.md)
- [Shareable configuration](docs/extending/shareable-configurations-list.md)
- Recipes
- [CI configurations](docs/recipes/README.md)
- [Git hosted services](docs/recipes/README.md)
- [Release workflow](docs/recipes/README.md)
- [Package managers and languages](docs/recipes/README.md)
- [CI configurations](docs/recipes/ci-configurations/README.md)
- [Git hosted services](docs/recipes/git-hosted-services/README.md)
- [Release workflow](docs/recipes/release-workflow/README.md)
- Developer guide
- [JavaScript API](docs/developer-guide/js-api.md)
- [Plugins development](docs/developer-guide/plugin.md)
@@ -134,18 +134,18 @@ In order to use **semantic-release** you need:
## Get help
- [GitHub Discussions](https://github.com/semantic-release/semantic-release/discussions)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/semantic-release)
- [Spectrum community](https://spectrum.chat/semantic-release)
- [Twitter](https://twitter.com/SemanticRelease)
## Badge
Let people know that your package is published using **semantic-release** by including this badge in your readme.
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.
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
```md
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
```
## Team
@@ -160,7 +160,6 @@ Let people know that your package is published using **semantic-release** by inc
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| [Stephan Bönnemann](https://github.com/boennemann) | [Rolf Erik Lekang](https://github.com/relekang) | [Johannes Jörg Schmidt](https://github.com/jo) | [Finn Pauls](https://github.com/finnp) | [Christoph Witzko](https://github.com/christophwitzko) |
<p align="center">
<img alt="Kill all humans" src="media/bender.png">
</p>
+21 -10
View File
@@ -1,35 +1,46 @@
# Summary
## Usage
- [Getting started](docs/usage/getting-started.md#getting-started)
- [Installation](docs/usage/installation.md#installation)
- [CI Configuration](docs/usage/ci-configuration.md#ci-configuration)
- [Configuration](docs/usage/configuration.md#configuration)
- [Installation](docs/usage/installation.md)
- [CI Configuration](docs/usage/ci-configuration.md)
- [Configuration](docs/usage/configuration.md)
- [Plugins](docs/usage/plugins.md)
- [Workflow configuration](docs/usage/workflow-configuration.md)
- [Shareable configurations](docs/usage/shareable-configurations.md)
## Extending
- [Plugins](docs/extending/plugins-list.md)
- [Shareable configuration](docs/extending/shareable-configurations-list.md)
## Recipes
- [CI configurations](docs/recipes/README.md#ci-configurations)
- [CircleCI 2.0](docs/recipes/circleci-workflows.md)
- [Travis CI](docs/recipes/travis.md)
- [GitLab CI](docs/recipes/gitlab-ci.md)
- [Git hosted services](docs/recipes/README.md#git-hosted-services)
- [Git authentication with SSH keys](docs/recipes/git-auth-ssh-keys.md)
- [Package managers and languages](docs/recipes/README.md#package-managers-and-languages)
- [CI configurations](docs/recipes/ci-configurations/README.md)
- [CircleCI 2.0](docs/recipes/ci-configurations/circleci-workflows.md)
- [Travis CI](docs/recipes/ci-configurations/travis.md)
- [GitLab CI](docs/recipes/ci-configurations/gitlab-ci.md)
- [GitHub Actions](docs/recipes/ci-configurations/github-actions.md)
- [Jenkins CI](docs/recipes/ci-configurations/jenkins-ci.md)
- [Git hosted services](docs/recipes/git-hosted-services/README.md)
- [Git authentication with SSH keys](docs/recipes/git-hosted-services/git-auth-ssh-keys.md)
- [Release Workflow](docs/recipes/release-workflow/README.md)
- [Publishing on distribution channels](docs/recipes/release-workflow/distribution-channels.md)
- [Publishing maintenance releases](docs/recipes/release-workflow/maintenance-releases.md)
- [Publishing pre-releases](docs/recipes/release-workflow/pre-releases.md)
## Developer guide
- [JavaScript API](docs/developer-guide/js-api.md)
- [Plugin development](docs/developer-guide/plugin.md)
- [Shareable configuration development](docs/developer-guide/shareable-configuration.md)
## Support
- [Resources](docs/support/resources.md)
- [Frequently Asked Questions](docs/support/FAQ.md)
- [Troubleshooting](docs/support/troubleshooting.md)
- [Node version requirement](docs/support/node-version.md)
- [Node Support Policy](docs/support/node-support-policy.md)
- [Git version requirement](docs/support/git-version.md)
+19 -17
View File
@@ -1,30 +1,32 @@
#!/usr/bin/env node
// Bad news: We have to write plain ES5 in this file
// Good news: It's the only file of the entire project
/* eslint-disable no-var */
var semver = require('semver');
var execa = require('execa');
var findVersions = require('find-versions');
var pkg = require('../package.json');
import semver from "semver";
import { execa } from "execa";
import findVersions from "find-versions";
import cli from "../cli.js";
import { createRequire } from "node:module";
var MIN_GIT_VERSION = '2.7.1';
const require = createRequire(import.meta.url);
const { engines } = require("../package.json");
const { satisfies, lt } = semver;
if (!semver.satisfies(process.version, pkg.engines.node)) {
const MIN_GIT_VERSION = "2.7.1";
if (!satisfies(process.version, engines.node)) {
console.error(
`[semantic-release]: node version ${pkg.engines.node} is required. Found ${process.version}.
`[semantic-release]: node version ${engines.node} is required. Found ${process.version}.
See https://github.com/semantic-release/semantic-release/blob/master/docs/support/node-version.md for more details and solutions.`
);
process.exit(1);
}
execa('git', ['--version'])
.then(({stdout}) => {
var gitVersion = findVersions(stdout)[0];
if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
execa("git", ["--version"])
.then(({ stdout }) => {
const gitVersion = findVersions(stdout, { loose: true })[0];
if (lt(gitVersion, MIN_GIT_VERSION)) {
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
process.exit(1);
}
@@ -35,11 +37,11 @@ execa('git', ['--version'])
process.exit(1);
});
// Node 10+ from this point on
require('../cli')()
cli()
.then((exitCode) => {
process.exitCode = exitCode;
})
.catch(() => {
.catch((error) => {
console.error(error);
process.exitCode = 1;
});
+32 -32
View File
@@ -1,47 +1,47 @@
const {argv, env, stderr} = require('process'); // eslint-disable-line node/prefer-global/process
const util = require('util');
const hideSensitive = require('./lib/hide-sensitive');
import util from "node:util";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import hideSensitive from "./lib/hide-sensitive.js";
const stringList = {
type: 'string',
type: "string",
array: true,
coerce: (values) =>
values.length === 1 && values[0].trim() === 'false'
values.length === 1 && values[0].trim() === "false"
? []
: values.reduce((values, value) => values.concat(value.split(',').map((value) => value.trim())), []),
: values.reduce((values, value) => values.concat(value.split(",").map((value) => value.trim())), []),
};
module.exports = async () => {
const cli = require('yargs')
.command('$0', 'Run automated package publishing', (yargs) => {
export default async () => {
const cli = yargs(hideBin(process.argv))
.command("$0", "Run automated package publishing", (yargs) => {
yargs.demandCommand(0, 0).usage(`Run automated package publishing
Usage:
semantic-release [options] [plugins]`);
})
.option('b', {alias: 'branches', describe: 'Git branches to release from', ...stringList, group: 'Options'})
.option('r', {alias: 'repository-url', describe: 'Git repository URL', type: 'string', group: 'Options'})
.option('t', {alias: 'tag-format', describe: 'Git tag format', type: 'string', group: 'Options'})
.option('p', {alias: 'plugins', describe: 'Plugins', ...stringList, group: 'Options'})
.option('e', {alias: 'extends', describe: 'Shareable configurations', ...stringList, group: 'Options'})
.option('ci', {describe: 'Toggle CI verifications', type: 'boolean', group: 'Options'})
.option('verify-conditions', {...stringList, group: 'Plugins'})
.option('analyze-commits', {type: 'string', group: 'Plugins'})
.option('verify-release', {...stringList, group: 'Plugins'})
.option('generate-notes', {...stringList, group: 'Plugins'})
.option('prepare', {...stringList, group: 'Plugins'})
.option('publish', {...stringList, group: 'Plugins'})
.option('success', {...stringList, group: 'Plugins'})
.option('fail', {...stringList, group: 'Plugins'})
.option('debug', {describe: 'Output debugging information', type: 'boolean', group: 'Options'})
.option('d', {alias: 'dry-run', describe: 'Skip publishing', type: 'boolean', group: 'Options'})
.option('h', {alias: 'help', group: 'Options'})
.option('v', {alias: 'version', group: 'Options'})
.option("b", { alias: "branches", describe: "Git branches to release from", ...stringList, group: "Options" })
.option("r", { alias: "repository-url", describe: "Git repository URL", type: "string", group: "Options" })
.option("t", { alias: "tag-format", describe: "Git tag format", type: "string", group: "Options" })
.option("p", { alias: "plugins", describe: "Plugins", ...stringList, group: "Options" })
.option("e", { alias: "extends", describe: "Shareable configurations", ...stringList, group: "Options" })
.option("ci", { describe: "Toggle CI verifications", type: "boolean", group: "Options" })
.option("verify-conditions", { ...stringList, group: "Plugins" })
.option("analyze-commits", { type: "string", group: "Plugins" })
.option("verify-release", { ...stringList, group: "Plugins" })
.option("generate-notes", { ...stringList, group: "Plugins" })
.option("prepare", { ...stringList, group: "Plugins" })
.option("publish", { ...stringList, group: "Plugins" })
.option("success", { ...stringList, group: "Plugins" })
.option("fail", { ...stringList, group: "Plugins" })
.option("debug", { describe: "Output debugging information", type: "boolean", group: "Options" })
.option("d", { alias: "dry-run", describe: "Skip publishing", type: "boolean", group: "Options" })
.option("h", { alias: "help", group: "Options" })
.strict(false)
.exitProcess(false);
try {
const {help, version, ...options} = cli.parse(argv.slice(2));
const { help, version, ...options } = cli.parse(process.argv.slice(2));
if (Boolean(help) || Boolean(version)) {
return 0;
@@ -49,14 +49,14 @@ Usage:
if (options.debug) {
// Debug must be enabled before other requires in order to work
require('debug').enable('semantic-release:*');
(await import("debug")).default.enable("semantic-release:*");
}
await require('.')(options);
await (await import("./index.js")).default(options);
return 0;
} catch (error) {
if (error.name !== 'YError') {
stderr.write(hideSensitive(env)(util.inspect(error, {colors: true})));
if (error.name !== "YError") {
process.stderr.write(hideSensitive(process.env)(util.inspect(error, { colors: true })));
}
return 1;
+2 -2
View File
@@ -1,7 +1,7 @@
# semantic-release documentation
- [Usage](usage/README.md) - **semantic-release** installation and configuration
- [Extending](extending/README.md)- Extending **semantic-release** with plugins and shareable configurations
- [Recipes](recipes/README.md) - Community written recipes for common **semantic-release** use-cases
- [Extending](extending/README.md) - Extending **semantic-release** with plugins and shareable configurations
- [Recipes](recipes/release-workflow/README.md) - Community written recipes for common **semantic-release** use-cases
- [Developer Guide](developer-guide/README.md) - The essentials of writing a **semantic-release** plugin or shareable configurations
- [Support](support/README.md) - FAQ and troubleshooting
+49 -40
View File
@@ -3,43 +3,48 @@
## Usage
```js
const semanticRelease = require('semantic-release');
const {WritableStreamBuffer} = require('stream-buffers');
const semanticRelease = require("semantic-release");
const { WritableStreamBuffer } = require("stream-buffers");
const stdoutBuffer = WritableStreamBuffer();
const stderrBuffer = WritableStreamBuffer();
const stdoutBuffer = new WritableStreamBuffer();
const stderrBuffer = new WritableStreamBuffer();
try {
const result = await semanticRelease({
// Core options
branches: [
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
],
repositoryUrl: 'https://github.com/me/my-package.git',
// Shareable config
extends: 'my-shareable-config',
// Plugin options
githubUrl: 'https://my-ghe.com',
githubApiPathPrefix: '/api-prefix'
}, {
// Run semantic-release from `/path/to/git/repo/root` without having to change local process `cwd` with `process.chdir()`
cwd: '/path/to/git/repo/root',
// Pass the variable `MY_ENV_VAR` to semantic-release without having to modify the local `process.env`
env: {...process.env, MY_ENV_VAR: 'MY_ENV_VAR_VALUE'},
// Store stdout and stderr to use later instead of writing to `process.stdout` and `process.stderr`
stdout: stdoutBuffer,
stderr: stderrBuffer
});
const result = await semanticRelease(
{
// Core options
branches: [
"+([0-9])?(.{+([0-9]),x}).x",
"master",
"next",
"next-major",
{ name: "beta", prerelease: true },
{ name: "alpha", prerelease: true },
],
repositoryUrl: "https://github.com/me/my-package.git",
// Shareable config
extends: "my-shareable-config",
// Plugin options
githubUrl: "https://my-ghe.com",
githubApiPathPrefix: "/api-prefix",
},
{
// Run semantic-release from `/path/to/git/repo/root` without having to change local process `cwd` with `process.chdir()`
cwd: "/path/to/git/repo/root",
// Pass the variable `MY_ENV_VAR` to semantic-release without having to modify the local `process.env`
env: { ...process.env, MY_ENV_VAR: "MY_ENV_VAR_VALUE" },
// Store stdout and stderr to use later instead of writing to `process.stdout` and `process.stderr`
stdout: stdoutBuffer,
stderr: stderrBuffer,
}
);
if (result) {
const {lastRelease, commits, nextRelease, releases} = result;
const { lastRelease, commits, nextRelease, releases } = result;
console.log(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);
console.log(
`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`
);
if (lastRelease.version) {
console.log(`The last release was "${lastRelease.version}".`);
@@ -49,14 +54,14 @@ try {
console.log(`The release was published with plugin "${release.pluginName}".`);
}
} else {
console.log('No release published.');
console.log("No release published.");
}
// Get stdout and stderr content
const logs = stdoutBuffer.getContentsAsString('utf8');
const errors = stderrBuffer.getContentsAsString('utf8');
const logs = stdoutBuffer.getContentsAsString("utf8");
const errors = stderrBuffer.getContentsAsString("utf8");
} catch (err) {
console.error('The automated release failed with %O', err)
console.error("The automated release failed with %O", err);
}
```
@@ -131,15 +136,16 @@ Type: `Object`
Information related to the last release found:
| Name | Type | Description |
|---------|----------|-------------------------------------------------------------------------------------------------------------------------------------|
| ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| version | `String` | The version of the last release. |
| gitHead | `String` | The sha of the last commit being part of the last release. |
| gitTag | `String` | The [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) associated with the last release. |
| channel | `String` | The distribution channel on which the last release was initially made available (`undefined` for the default distribution channel). |
**Notes**: If no previous release is found, `lastRelease` will be an empty `Object`.
**Note**: If no previous release is found, `lastRelease` will be an empty `Object`.
Example:
```js
{
gitHead: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
@@ -157,7 +163,7 @@ The list of commit included in the new release.<br>
Each commit object has the following properties:
| Name | Type | Description |
|-----------------|----------|-------------------------------------------------|
| --------------- | -------- | ----------------------------------------------- |
| commit | `Object` | The commit abbreviated and full hash. |
| commit.long | `String` | The commit hash. |
| commit.short | `String` | The commit abbreviated hash. |
@@ -179,6 +185,7 @@ Each commit object has the following properties:
| committerDate | `String` | The committer date. |
Example:
```js
[
{
@@ -216,7 +223,7 @@ Type: `Object`
Information related to the newly published release:
| Name | Type | Description |
|---------|----------|-------------------------------------------------------------------------------------------------------------------------------|
| ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| type | `String` | The [semver](https://semver.org) type of the release (`patch`, `minor` or `major`). |
| version | `String` | The version of the new release. |
| gitHead | `String` | The sha of the last commit being part of the new release. |
@@ -225,6 +232,7 @@ Information related to the newly published release:
| channel | `String` | The distribution channel on which the next release will be made available (`undefined` for the default distribution channel). |
Example:
```js
{
type: 'minor',
@@ -244,7 +252,7 @@ The list of releases published or made available to a distribution channel.<br>
Each release object has the following properties:
| Name | Type | Description |
|------------|----------|----------------------------------------------------------------------------------------------------------------|
| ---------- | -------- | -------------------------------------------------------------------------------------------------------------- |
| name | `String` | **Optional.** The release name, only if set by the corresponding `publish` plugin. |
| url | `String` | **Optional.** The release URL, only if set by the corresponding `publish` plugin. |
| type | `String` | The [semver](https://semver.org) type of the release (`patch`, `minor` or `major`). |
@@ -256,6 +264,7 @@ Each release object has the following properties:
| channel | `String` | The distribution channel on which the release is available (`undefined` for the default distribution channel). |
Example:
```js
[
{
+195 -17
View File
@@ -1,16 +1,20 @@
# Plugin Developer Guide
To create a plugin for `semantic-release`, you need to decide which parts of the release lifecycle are important to that plugin. For example, it is best to always have a `verify` step because you may be receiving inputs from a user and want to make sure they exist. A plugin can abide by any of the following lifecycles:
To create a plugin for `semantic-release`, you need to decide which parts of the release lifecycle are important to that plugin. For example, it is best to always have a `verifyConditions` step because you may be receiving inputs from a user and want to make sure they exist. A plugin can abide by any of the following lifecycles:
- `verify`
- `verifyConditions`
- `analyzeCommits`
- `verifyRelease`
- `generateNotes`
- `addChannel`
- `prepare`
- `publish`
- `success`
- `fail`
`semantic-release` will require the plugin via `node` and look through the required object for methods named like the lifecyles stated above. For example, if your plugin only had a `verify` and `success` step, the `main` file for your object would need to `export` an object with `verify` and `success` functions.
`semantic-release` will require the plugin via `node` and look through the required object for methods named like the lifecycles stated above. For example, if your plugin only had a `verifyConditions` and `success` step, the `main` file for your object would need to `export` an object with `verifyConditions` and `success` functions.
In addition to the lifecycle methods, each lifecyle is passed two objects:
In addition to the lifecycle methods, each lifecycle is passed two objects:
1. `pluginConfig` - an object containing the options that a user may pass in via their `release.config.js` file (or similar)
2. `context` - provided by `semantic-release` for access to things like `env` variables set on the running process.
@@ -30,7 +34,7 @@ We recommend you setup a linting system to ensure good javascript practices are
In your `index.js` file, you can start by writing the following code
```javascript
const verifyConditions = require('./src/verify');
const verify = require("./src/verify");
let verified;
@@ -39,18 +43,18 @@ let verified;
* @param {*} pluginConfig The semantic-release plugin config
* @param {*} context The context provided by semantic-release
*/
async function verify(pluginConfig, context) {
await verifyConditions(pluginConfig, context);
async function verifyConditions(pluginConfig, context) {
await verify(pluginConfig, context);
verified = true;
}
module.exports = { verify };
module.exports = { verifyConditions };
```
Then, in your `src` folder, create a file called `verify.js` and add the following
```javascript
const AggregateError = require('aggregate-error');
const AggregateError = require("aggregate-error");
/**
* A method to verify that the user has given us a slack webhook url to post to
@@ -76,10 +80,10 @@ Let's say we want to verify that an `option` is passed. An `option` is a configu
```js
{
prepare: {
path: "@semantic-release/my-special-plugin"
message: "My cool release message"
}
prepare: {
path: "@semantic-release/my-special-plugin";
message: "My cool release message";
}
}
```
@@ -89,11 +93,141 @@ This `message` option will be passed to the `pluginConfig` object mentioned earl
const { message } = pluginConfig;
if (message.length) {
//...
//...
}
```
## Supporting Environment Variables
## Context
### Common context keys
- `stdout`
- `stderr`
- `logger`
### Context object keys by lifecycle
#### verifyConditions
Initially the context object contains the following keys (`verifyConditions` lifecycle):
- `cwd`
- Current working directory
- `env`
- Environment variables
- `envCi`
- Information about CI environment
- Contains (at least) the following keys:
- `isCi`
- Boolean, true if the environment is a CI environment
- `commit`
- Commit hash
- `branch`
- Current branch
- `options`
- Options passed to `semantic-release` via CLI, configuration files etc.
- `branch`
- Information on the current branch
- Object keys:
- `channel`
- `tags`
- `type`
- `name`
- `range`
- `accept`
- `main`
- `branches`
- Information on branches
- List of branch objects (see above)
#### analyzeCommits
Compared to the verifyConditions, `analyzeCommits` lifecycle context has keys
- `commits` (List)
- List of commits taken into account when determining the new version.
- Keys:
- `commit` (Object)
- Keys:
- `long` (String, Commit hash)
- `short` (String, Commit hash)
- `tree` (Object)
- Keys:
- `long` (String, Commit hash)
- `short` (String, Commit hash)
- `author` (Object)
- Keys:
- `name` (String)
- `email` (String)
- `date` (String, ISO 8601 timestamp)
- `committer` (Object)
- Keys:
- `name` (String)
- `email` (String)
- `date` (String, ISO 8601 timestamp)
- `subject` (String, Commit message subject)
- `body` (String, Commit message body)
- `hash` (String, Commit hash)
- `committerDate` (String, ISO 8601 timestamp)
- `message` (String)
- `gitTags` (String, List of git tags)
- `releases` (List)
- `lastRelease` (Object)
- Keys
- `version` (String)
- `gitTag` (String)
- `channels` (List)
- `gitHead` (String, Commit hash)
- `name` (String)
#### verifyRelease
Additional keys:
- `nextRelease` (Object)
- `type` (String)
- `channel` (String)
- `gitHead` (String, Git hash)
- `version` (String, version without `v`)
- `gitTag` (String, version with `v`)
- `name` (String)
#### generateNotes
No new content in the context.
#### addChannel
_This is run only if there are releases that have been merged from a higher branch but not added on the channel of the current branch._
Context content is similar to lifecycle `verifyRelease`.
#### prepare
Only change is that `generateNotes` has populated `nextRelease.notes`.
#### publish
No new content in the context.
#### success
Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
Additional keys:
- `releases`
- Populated by `publish` lifecycle
#### fail
Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
Additional keys:
- `errors`
### Supporting Environment Variables
Similar to `options`, environment variables exist to allow users to pass tokens and set special URLs. These are set on the `context` object instead of the `pluginConfig` object. Let's say we wanted to check for `GITHUB_TOKEN` in the environment because we want to post to GitHub on the user's behalf. To do this, we can add the following to our `verify` command:
@@ -101,6 +235,50 @@ Similar to `options`, environment variables exist to allow users to pass tokens
const { env } = context;
if (env.GITHUB_TOKEN) {
//...
//...
}
```
```
## Logger
Use `context.logger` to provide debug logging in the plugin.
```js
const { logger } = context;
logger.log('Some message from plugin.').
```
The above usage yields the following where `PLUGIN_PACKAGE_NAME` is automatically inferred.
```
[3:24:04 PM] [semantic-release] [PLUGIN_PACKAGE_NAME] Some message from plugin.
```
## Execution order
For the lifecycles, the list at the top of the readme contains the order. If there are multiple plugins for the same lifecycle, then the order of the plugins determines the order in which they are executed.
## Handling errors
In order to be able to detect and handle errors properly, the errors thrown from the must be of type [SemanticReleaseError](https://github.com/semantic-release/error) or extend it as described in the package readme. This way the errors are handled properly and plugins using the `fail` lifecycle receive the errors correctly. For any other types of errors the internal error handling does nothing, lets them through up until the final catch and does not call any `fail` plugins.
## Advanced
Knowledge that might be useful for plugin developers.
### Multiple analyzeCommits plugins
While it may be trivial that multiple analyzeCommits (or any lifecycle plugins) can be defined, it is not that self-evident that the plugins executed AFTER the first one (for example, the default one: `commit-analyzer`) can change the result. This way it is possible to create more advanced rules or situations, e.g. if none of the commits would result in new release, then a default can be defined.
The commit must be a known release type, for example the commit-analyzer has the following default types:
- major
- premajor
- minor
- preminor
- patch
- prepatch
- prerelease
If the analyzeCommits-lifecycle plugin does not return anything, then the earlier result is used, but if it returns a supported string value, then that overrides the previous result.
+66 -8
View File
@@ -1,6 +1,7 @@
# Plugins list
## Official plugins
- [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer)
- **Note**: this is already part of semantic-release and does not have to be installed separately
- `analyzeCommits`: Determine the type of release by analyzing commits with [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog)
@@ -20,7 +21,7 @@
- `publish`: Publish the package on the npm registry
- [@semantic-release/gitlab](https://github.com/semantic-release/gitlab)
- `verifyConditions`: Verify the presence and the validity of the GitLab authentication and release configuration
- `publish`: Publish a [GitLab release](https://docs.gitlab.com/ce/workflow/releases.html)
- `publish`: Publish a [GitLab release](https://docs.gitlab.com/ee/user/project/releases/)
- [@semantic-release/git](https://github.com/semantic-release/git)
- `verifyConditions`: Verify the presence and the validity of the Git authentication and release configuration
- `prepare`: Push a release commit and tag, including configurable files
@@ -52,11 +53,15 @@
- [semantic-release-docker](https://github.com/felixfbecker/semantic-release-docker)
- `verifyConditions`: Verify that all needed configuration is present and login to the Docker registry.
- `publish`: Tag the image specified by `name` with the new version, push it to Docker Hub and update the latest tag
- [@semantic-release-plus/docker](https://github.com/semantic-release-plus/semantic-release-plus/tree/master/packages/plugins/docker)
- `verifyConditions`: Verify that all needed configuration is present and login to the configured docker registry.
- `publish`: Tag the image specified by `name` with the new version and channel and push it to the configured docker registry.
- `addChannel`: Updates a release published on one channel with the destinations channel tag and pushes to the registry i.e.: next to latest.
- [semantic-release-gcr](https://github.com/carlos-cubas/semantic-release-gcr)
- `verifyConditions`: Verify that all needed configuration is present and login to the Docker registry
- `publish`: Tag the image specified by `name` with the new version, push it to Docker Hub and update the latest tag
- [semantic-release-vsce](https://github.com/raix/semantic-release-vsce)
- `verifyConditions`: Verify the presence and the validity of the vsce authentication and release configuration
- `verifyConditions`: Verify the presence and the validity of the "VS Code extension" authentication and release configuration
- `prepare`: Create a `.vsix` for distribution
- `publish`: Publish the package to the Visual Studio Code marketplace
- [semantic-release-verify-deps](https://github.com/piercus/semantic-release-verify-deps)
@@ -80,7 +85,7 @@
- `prepare`: Changes the version number in the `pom.xml` (or all `pom.xml` files in maven projects with multiple `pom.xml` files) and optionally creates a commit with this version number and pushes it to `master`
- `publish`: Runs `mvn deploy` to deploy to maven central and optionally will update to next snapshot version and merge changes to development branch
- [semantic-release-ado](https://github.com/lluchmk/semantic-release-ado)
- `prepare`: Stores the version number as an Azure DevOps pipeline variable availabe to downstream steps on the job
- `prepare`: Stores the version number as an Azure DevOps pipeline variable available to downstream steps on the job
- [gradle-semantic-release](https://github.com/KengoTODA/gradle-semantic-release-plugin)
- `verifyConditions`: Verify that project has a Gradle wrapper script, and `build.gradle` contains a task to publish artifacts.
- `prepare`: Changes the version number in the `gradle.properties`
@@ -91,6 +96,9 @@
- [semantic-release-github-pages](https://github.com/qiwi/semantic-release-gh-pages-plugin)
- `verifyConditions`: Verify the presence of the auth token set via environment variables.
- `publish`: Pushes commit to the documentation branch.
- [semantic-release-github-pullrequest](https://github.com/asbiin/semantic-release-github-pullrequest)
- `verifyConditions`: Verify the presence and the validity of the GitHub authentication and other configuration.
- `publish`: Create a branch to upload all assets and create the pull request on the base branch on GitHub.
- [leiningen-semantic-release](https://github.com/NoxHarmonium/leiningen-semantic-release)
- `verifyConditions`: Checks the project.clj is syntactically valid.
- `prepare`: Update the project.clj version and package the output jar file.
@@ -104,10 +112,10 @@
- [semantic-release-rubygem](https://github.com/Gusto/semantic-release-rubygem)
- `verifyConditions`: Locate and validate a `.gemspec` file, locate and validate a `lib/**/version.rb` file, verify the presence of the `GEM_HOST_API_KEY` environment variable, and create a credentials file with the API key.
- `prepare`: Update the version in the `lib/**/version.rb` version file and [build](https://guides.rubygems.org/command-reference/#gem-build) the gem.
- `publish`: [Push the Ruby gem](https://guides.rubygems.org/command-reference/#gem-push) to the gem server.
- `publish`: [Push the Ruby gem](https://guides.rubygems.org/command-reference/#gem-push) to the gem server.
- [semantic-release-npm-deprecate-old-versions](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions)
- `verifyConditions`: Validates configuration.
- `publish`: Deprecates old versions, based on the declaration of supported versions in the config.
- `publish`: Deprecates old versions, based on the declaration of supported versions in the config.
- [amanda-mitchell/semantic-release-npm-multiple](https://github.com/amanda-mitchell/semantic-release-npm-multiple)
- **Note**: this is a thin wrapper around the built-in npm plugin that can target multiple registries
- `verifyConditions`: Verify the presence and the validity of the npm authentication and release configuration for multiple registries
@@ -117,10 +125,60 @@
- `verifyConditions`: Verify the presence of a license file
- `prepare`: Update the license file based on its type
- [semantic-release-pypi](https://github.com/abichinger/semantic-release-pypi)
- `verifyConditions`: Verify the environment variable ```PYPI_TOKEN``` and installation of build tools
- `prepare`: Update the version in ```setup.cfg``` and create the distribution packages
- `verifyConditions`: Verify the environment variable `PYPI_TOKEN` and installation of build tools
- `prepare`: Update the version in `setup.cfg` and create the distribution packages
- `publish`: Publish the python package to a repository (default: pypi)
- [semantic-release-helm](https://github.com/m1pl/semantic-release-helm)
- `verifyConditions`: Validate configuration and (if present) credentials
- `prepare`: Update version and appVersion in ```Chart.yaml```
- `prepare`: Update version and appVersion in `Chart.yaml`
- `publish`: Publish the chart to a registry (if configured)
- [semantic-release-codeartifact](https://github.com/ryansonshine/semantic-release-codeartifact)
- `verifyConditions`: Validate configuration, get AWS CodeArtifact authentication and repository, validate `publishConfig` or `.npmrc` (if they exist), then pass the configuration to the associated plugins.
- [semantic-release-telegram](https://github.com/pustovitDmytro/semantic-release-telegram)
- `verifyConditions`: Validate configuration and verify `TELEGRAM_BOT_ID` and `TELEGRAM_BOT_TOKEN`
- `success`: Publish a message about the successful release to a telegram chat
- `fail`: publish a message about failure to a telegram chat
- [semantic-release-heroku](https://github.com/pustovitDmytro/semantic-release-heroku)
- `verifyConditions`: Validate configuration and verify `HEROKU_API_KEY`
- `prepare`: Update the package.json version and create release tarball
- `publish`: Publish version to heroku
- [semantic-release-mattermost](https://github.com/ttrobisch/semantic-release-mattermost)
- `verifyConditions`: Verify that the webhook is setup and release-notes-generator is present.
- `success`: Send a message about the new release and its notes to a [mattermost](https://mattermost.com/) webhook.
- [semantic-release-github-milestones](https://github.com/nitzano/semantic-release-github-milestones)
- `verifyConditions`: Verify github tokens are present and valid.
- `verifyRelease`: Display information regarding the matching github milestone.
- [semantic-release-telegram-bot](https://github.com/skoropadas/semantic-release-telegram-bot)
- `verifyConditions`: Validate configuration and verify `TELEGRAM_BOT_TOKEN` and package name
- `success`: Publish a success message to certain telegram chats
- `fail`: Publish a fail message to certain telegram chats
- [semantic-release-npm-deprecate](https://github.com/jpoehnelt/semantic-release-npm-deprecate)
- `publish`: Automatically mark old versions as deprecated.
- [@eshepelyuk/semantic-release-helm-oci](https://github.com/eshepelyuk/semantic-release-helm-oci)
- `verifyConditions`: Verify plugin configuration and login to Helm registry
- `prepare`: Package Helm chart to local folder
- `publish`: Publish Helm chart to OCI registry
- [semantic-release-space](https://github.com/123FLO321/semantic-release-space)
- `verifyConditions` Verifies that all required options are set.
- `prepare` Creates a JetBrains Space Deployment Target if it does not yet exist.
- `publish` Starts a JetBrains Space Deployment.
- `success` Marks the JetBrains Space Deployment as completed.
- `fail` Marks the JetBrains Space Deployment as failed.
- [semantic-release-react-native](https://github.com/alexandermendes/semantic-release-react-native)
- `verifyConditions` Validate configuration.
- `prepare` Version native iOS and Android files.
- [semantic-release-cargo](https://github.com/buehler/semantic-release-cargo)
- `verifyConditions` Validate configuration, `Cargo.toml`, and local cargo executable. Also, logs in into `crates.io`.
- `prepare` Write the new version number into `Cargo.toml` file and perform `cargo check` if configured.
- `publish` Publish the Rust crate to `crates.io`
- [semantic-release-coralogix](https://github.com/adobe/semantic-release-coralogix)
- `verifyConditions` Verified that required credentials are provided and API is accessible
- `publish` add a release tag to Coralogix
- [semantic-release-major-tag](https://github.com/doteric/semantic-release-major-tag)
- `success` Create major version tag, for example `v1`.
- [semantic-release-yarn](https://github.com/hongaar/semantic-release-yarn)
- **Note**: this is an alternative to the default `@semantic-release/npm` plugin and adds support for monorepos.
- `verifyConditions` Verify Yarn 2 or higher is installed, verify the presence of a NPM auth token (either in an environment variable or a `.yarnrc.yml` file) and verify the authentication method is valid.
- `prepare` Update the `package.json` version and create the package tarball.
- `addChannel` Add a tag for the release.
- `publish` Publish to the npm registry.
@@ -1,12 +1,14 @@
# Shareable configurations list
## Official configurations
- [@semantic-release/apm-config](https://github.com/semantic-release/apm-config) - semantic-release shareable configuration for releasing atom packages
- [@semantic-release/gitlab-config](https://github.com/semantic-release/gitlab-config) - semantic-release shareable configuration for GitLab
## Community configurations
- [@jedmao/semantic-release-npm-github-config](https://github.com/jedmao/semantic-release-npm-github-config)
- Provides an informative [git](https://github.com/semantic-release/git) commit message for the release commit that does not trigger continuous integration and conforms to the [conventional commits specification](https://www.conventionalcommits.org/) (e.g., "chore(release): 1.2.3 [skip ci]\n\nnotes").
- Provides an informative [Git](https://github.com/semantic-release/git) commit message for the release commit that does not trigger continuous integration and conforms to the [conventional commits specification](https://www.conventionalcommits.org/) (e.g., `chore(release): 1.2.3 [skip ci]\n\nnotes`).
- Creates a tarball that gets uploaded with each [GitHub release](https://github.com/semantic-release/github).
- Publishes the same tarball to [npm](https://github.com/semantic-release/npm).
- Commits the version change in `package.json`.
@@ -18,4 +20,3 @@
- Updates GitHub release with release-notes.
- Bumps a version in package.json.
- Publishes the new version to [NPM](https://npmjs.org).
-18
View File
@@ -1,18 +0,0 @@
# Recipes
## CI configurations
- [CircleCI 2.0 workflows](circleci-workflows.md)
- [Travis CI](travis.md)
- [GitLab CI](gitlab-ci.md)
- [GitHub Actions](github-actions.md)
- [Jenkins CI](jenkins-ci.md)
## Git hosted services
- [Git authentication with SSH keys](git-auth-ssh-keys.md)
## Release workflow
- [Publishing on distribution channels](distribution-channels.md)
- [Publishing maintenance releases](maintenance-releases.md)
- [Publishing pre-releases](pre-releases.md)
## Package managers and languages
+7
View File
@@ -0,0 +1,7 @@
# CI configurations
- [CircleCI 2.0 workflows](circleci-workflows.md)
- [Travis CI](travis.md)
- [GitLab CI](gitlab-ci.md)
- [GitHub Actions](github-actions.md)
- [Jenkins CI](jenkins-ci.md)
@@ -0,0 +1,49 @@
# Using semantic-release with [CircleCI 2.0 workflows](https://circleci.com/docs/2.0/workflows)
## Environment variables
The [Authentication](../../usage/ci-configuration.md#authentication) environment variables can be configured in [CircleCi Project Settings](https://circleci.com/docs/2.0/env-vars/#adding-environment-variables-in-the-app)..
Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../../usage/getting-started.md#getting-started).
## Multiple Node jobs configuration
### `.circleci/config.yml` configuration for multiple Node jobs
This example is a minimal configuration for **semantic-release** with tests running against Node 16 and 14.
See [CircleCI documentation](https://circleci.com/docs/2.0) for additional configuration options.
In this example, the [`circleci/node`](https://circleci.com/developer/orbs/orb/circleci/node) orb is imported (Which makes some node operations easier), then a `release` job is defined which will run `semantic-release`.
To run our `release` job, we have created a workflow named `test_and_release` which will run two jobs, `node/test`, which comes from the node orb and will test our application, and our release job.
Here, we are actually making use of [matrix jobs](https://circleci.com/blog/circleci-matrix-jobs/) so that our single `node/test` job will actually be executed twice, once for Node version 16, and once for version 14.
Finally, we call our release job with a `requires` parameter so that `release` will run against the latest LTS version of node, only after `node/test` has successfully tested against v14 and v16.
```yaml
version: 2.1
orbs:
node: circleci/node@5.0.0
jobs:
release:
executor: node/default
steps:
- checkout
- node/install-packages # Install and automatically cache packages
# Run optional required steps before releasing
# - run: npm run build-script
- run: npx semantic-release
workflows:
test_and_release:
# Run the test jobs first, then the release only when all the test jobs are successful
jobs:
- node/test:
matrix:
parameters:
version:
- 16.1.0
- 14.17.0
- release:
requires:
- node/test
```
@@ -2,19 +2,25 @@
## Environment variables
The [Authentication](../usage/ci-configuration.md#authentication) environment variables can be configured with [Secret Variables](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables).
The [Authentication](../../usage/ci-configuration.md#authentication) environment variables can be configured with [Secret Variables](https://docs.github.com/en/actions/reference/encrypted-secrets).
In this example a publish type [`NPM_TOKEN`](https://docs.npmjs.com/creating-and-viewing-authentication-tokens) is required to publish a package to the npm registry. GitHub Actions [automatically populate](https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret) a [`GITHUB_TOKEN`](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) environment variable which can be used in Workflows.
## npm provenance
Since GitHub Actions is a [supported provider](https://docs.npmjs.com/generating-provenance-statements#provenance-limitations) for [npm provenance](https://docs.npmjs.com/generating-provenance-statements), it is recommended to enable this to increase supply-chain security for your npm packages.
Find more detail about configuring npm to publish with provenance through semantic-release [in the documentation for our npm plugin](https://github.com/semantic-release/npm#npm-provenance).
## Node project configuration
[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.
**Note**: The publish pipeline must run on [Node version >= 10.18](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
**Note**: The publish pipeline must run on a [Node version that meets our version requirement](../../support/node-version.md).
### `.github/workflows/release.yml` configuration for Node projects
The following is a minimal configuration for [`semantic-release`](https://github.com/semantic-release/semantic-release) with a build running on Node 12 when a new commit is pushed to a `master` branch. See [Configuring a Workflow](https://help.github.com/en/articles/configuring-a-workflow) for additional configuration options.
The following is a minimal configuration for [`semantic-release`](https://github.com/semantic-release/semantic-release) with a build running on the latest LTS version of Node when a new commit is pushed to a `master` branch.
See [Configuring a Workflow](https://help.github.com/en/articles/configuring-a-workflow) for additional configuration options.
```yaml
name: Release
@@ -22,21 +28,32 @@ on:
push:
branches:
- master
permissions:
contents: read # for checkout
jobs:
release:
name: Release
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 12
node-version: "lts/*"
- name: Install dependencies
run: npm ci
run: npm clean-install
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -50,7 +67,7 @@ To keep `package.json` updated in the `master` branch, [`@semantic-release/git`]
**Note**: Automatically populated `GITHUB_TOKEN` cannot be used if branch protection is enabled for the target branch. It is **not** advised to mitigate this limitation by overriding an automatically populated `GITHUB_TOKEN` variable with a [Personal Access Tokens](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line), as it poses a security risk. Since Secret Variables are available for Workflows triggered by any branch, it becomes a potential vector of attack, where a Workflow triggered from a non-protected branch can expose and use a token with elevated permissions, yielding branch protection insignificant. One can use Personal Access Tokens in trusted environments, where all developers should have the ability to perform administrative actions in the given repository and branch protection is enabled solely for convenience purposes, to remind about required reviews or CI checks.
If the risk is acceptible, some extra configuration is needed. The [actions/checkout `persist-credentials`](https://github.com/marketplace/actions/checkout#usage) option needs to be `false`, otherwise the generated `GITHUB_TOKEN` will interfere with the custom one. Example:
If the risk is acceptable, some extra configuration is needed. The [actions/checkout `persist-credentials`](https://github.com/marketplace/actions/checkout#usage) option needs to be `false`, otherwise the generated `GITHUB_TOKEN` will interfere with the custom one. Example:
```yaml
- name: Checkout
@@ -63,9 +80,11 @@ If the risk is acceptible, some extra configuration is needed. The [actions/chec
## Trigger semantic-release on demand
### Using GUI:
You can use [Manual Triggers](https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/) for GitHub Actions.
### Using HTTP:
Use [`repository_dispatch`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch) event to have control on when to generate a release by making an HTTP request, e.g.:
```yaml
@@ -84,7 +103,8 @@ $ curl -v -H "Accept: application/vnd.github.everest-preview+json" -H "Authoriza
```
### Using 3rd party apps:
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:
* [Actions Panel](https://www.actionspanel.app/) - A declaratively configured way for triggering GitHub Actions
* [Action Button](https://github-action-button.web.app/#details) - A simple badge based mechanism for triggering GitHub Actions
- [Actions Panel](https://www.actionspanel.app/) - A declaratively configured way for triggering GitHub Actions
- [Action Button](https://github-action-button.web.app/#details) - A simple badge based mechanism for triggering GitHub Actions
@@ -2,7 +2,7 @@
## Environment variables
The [Authentication](../usage/ci-configuration.md#authentication) environment variables can be configured with [Protected variables](https://docs.gitlab.com/ce/ci/variables/README.html#protected-environment-variables).
The [Authentication](../../usage/ci-configuration.md#authentication) environment variables can be configured with [Protected variables](https://docs.gitlab.com/ce/ci/variables/README.html#protected-environment-variables).
**Note**: Make sure to configure your release branch as [protected](https://docs.gitlab.com/ce/user/project/protected_branches.html) in order for the CI/CD build to access the protected variables.
@@ -10,19 +10,19 @@ The [Authentication](../usage/ci-configuration.md#authentication) environment va
GitLab CI supports [Pipelines](https://docs.gitlab.com/ee/ci/pipelines.html) allowing to test on multiple Node versions and publishing a release only when all test pass.
**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
**Note**: The publish pipeline must run a [Node version that meets our version requirement](../../support/node-version.md).
### `.gitlab-ci.yml` configuration for Node projects
This example is a minimal configuration for **semantic-release** with a build running Node 10 and 12. See [GitLab CI - Configuration of your jobs with .gitlab-ci.yml](https://docs.gitlab.com/ee/ci/yaml/README.html) for additional configuration options.
This example is a minimal configuration for **semantic-release** with a build running Node 10 and 12. See [GitLab CI - Configuration of your jobs with `.gitlab-ci.yml`](https://docs.gitlab.com/ee/ci/yaml/README.html) for additional configuration options.
**Note**: The`semantic-release` execution command varies depending if you are using a [local](../usage/installation.md#local-installation) or [global](../usage/installation.md#global-installation) **semantic-release** installation.
**Note**: The`semantic-release` execution command varies depending on whether you are using a [local](../../usage/installation.md#local-installation) or [global](../../usage/installation.md#global-installation) **semantic-release** installation.
```yaml
# The release pipeline will run only if all jobs in the test pipeline are successful
stages:
- test
- release
- test
- release
before_script:
- npm install
@@ -48,13 +48,12 @@ publish:
### `.gitlab-ci.yml` configuration for all projects
This example is a minimal configuration for **semantic-release** with a build running Node 10 and 12. See [GitLab CI - Configuration of your jobs with .gitlab-ci.yml](https://docs.gitlab.com/ee/ci/yaml/README.html) for additional configuration options.
**Note**: The`semantic-release` execution command varies depending if you are using a [local](../usage/installation.md#local-installation) or [global](../usage/installation.md#global-installation) **semantic-release** installation.
This example is a minimal configuration for **semantic-release** with a build running Node 10 and 12. See [GitLab CI - Configuration of your jobs with `.gitlab-ci.yml`](https://docs.gitlab.com/ee/ci/yaml/README.html) for additional configuration options.
**Note**: The`semantic-release` execution command varies depending if you are using a [local](../../usage/installation.md#local-installation) or [global](../../usage/installation.md#global-installation) **semantic-release** installation.
```yaml
# The release pipeline will run only on the master branch a commit is triggered
# The release pipeline will run only on the master branch a commit is triggered
stages:
- release
@@ -66,8 +65,8 @@ release:
- npm install -g semantic-release @semantic-release/gitlab
script:
- semantic-release
only:
- master
rules:
- if: $CI_COMMIT_BRANCH == "master"
release:
image: node:12-buster-slim
@@ -77,13 +76,13 @@ release:
- npm install -g semantic-release @semantic-release/gitlab
script:
- semantic-release
only:
- master
rules:
- if: $CI_COMMIT_BRANCH == "master"
```
### `package.json` configuration
A `package.json` is required only for [local](../usage/installation.md#local-installation) **semantic-release** installation.
A `package.json` is required only for [local](../../usage/installation.md#local-installation) **semantic-release** installation.
```json
{
@@ -2,24 +2,24 @@
## Environment variables
The [Authentication](../usage/ci-configuration.md#authentication) environment variables can be configured in [Jenkins Project Settings](https://www.jenkins.io/doc/pipeline/tour/environment/)..
The [Authentication](../../usage/ci-configuration.md#authentication) environment variables can be configured in [Jenkins Project Settings](https://www.jenkins.io/doc/pipeline/tour/environment/)..
Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../usage/getting-started.md#getting-started).
Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../../usage/getting-started.md#getting-started).
## Node.js project configuration
### `Jenkinsfile (Declarative Pipeline)` configuration for a Node.js job
**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
**Note**: The publish pipeline must run a Node version that [meets our requirement](../../support/node-version.md).
This example is a minimal configuration for **semantic-release** with a build running Node 10.18. See [Jenkins documentation](https://www.jenkins.io/doc/) for additional configuration options.
The`semantic-release` execution command varies depending if you are using a [local](../usage/installation.md#local-installation) or [global](../usage/installation.md#global-installation) **semantic-release** installation.
This example is a minimal configuration for **semantic-release** with a build running a version of Node labelled as "node LTS".
Since versions of Node are manually downloaded and labelled, we recommend keeping the version used for the release steps up-to-date with the latest LTS version.
See the [Jenkins documentation](https://www.jenkins.io/doc/) for additional configuration options.
```yaml
// The release stage in the pipeline will run only if the test stage in the pipeline is successful
pipeline {
agent any
agent any
environment {
GH_TOKEN = credentials('some-id')
}
@@ -31,18 +31,18 @@ pipeline {
npm install
npm test
'''
}
}
}
stage('Release') {
tools {
nodejs "node 10.18"
nodejs "node LTS"
}
steps {
sh '''
# Run optional required steps before releasing
npx semantic-release
'''
}
}
}
}
}
@@ -50,12 +50,12 @@ pipeline {
### `package.json` configuration for a Node job
A `package.json` is required only for [local](../usage/installation.md#local-installation) **semantic-release** installation.
A `package.json` is required only for [local](../../usage/installation.md#local-installation) **semantic-release** installation.
```json
{
"devDependencies": {
"semantic-release": "^15.0.0"
"semantic-release": "^18.0.0"
}
}
```
```
@@ -2,17 +2,17 @@
## Environment variables
The [Authentication](../usage/ci-configuration.md#authentication) environment variables can be configured in [Travis Repository Settings](https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-Settings) or with the [travis env set CLI](https://github.com/travis-ci/travis.rb#env).
The [Authentication](../../usage/ci-configuration.md#authentication) environment variables can be configured in [Travis Repository Settings](https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-Settings) or with the [travis env set CLI](https://github.com/travis-ci/travis.rb#env).
Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../usage/getting-started.md#getting-started).
Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../../usage/getting-started.md#getting-started).
## Node.js projects configuration
### `.travis.yml` configuration for multiple Node.js jobs
This example is a minimal configuration for **semantic-release** with a build running Node 6 and 8. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
This example is a minimal configuration for **semantic-release** with a build running Node 14 and 16. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
It's recommended to run the `semantic-release` command in the [Travis `deploy` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error occurs the build will fail and Travis will send a notification.
@@ -24,8 +24,8 @@ It's recommended to run the `semantic-release` command in the [Travis `deploy` s
language: node_js
node_js:
- 8
- 6
- 14
- 16
jobs:
include:
@@ -43,12 +43,12 @@ jobs:
### `package.json` configuration for multiple Node jobs
A `package.json` is required only for [local](../usage/installation.md#local-installation) **semantic-release** installation.
A `package.json` is required only for [local](../../usage/installation.md#local-installation) **semantic-release** installation.
```json
{
"devDependencies": {
"semantic-release": "^15.0.0"
"semantic-release": "^18.0.0"
}
}
```
@@ -57,13 +57,13 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
For projects that require to be tested with one or multiple version of a Non-JavaScript [language](https://docs.travis-ci.com/user/languages), optionally on multiple [Operating Systems](https://docs.travis-ci.com/user/multi-os).
This recipe cover the Travis specifics only. See [Non JavaScript projects recipe](../support/FAQ.md#can-i-use-semantic-release-to-publish-non-javascript-packages) for more information on the **semantic-release** configuration.
This recipe cover the Travis specifics only. See [Non JavaScript projects recipe](../../support/FAQ.md#can-i-use-semantic-release-to-publish-non-javascript-packages) for more information on the **semantic-release** configuration.
### `.travis.yml` configuration for non-JavaScript projects
This example is a minimal configuration for **semantic-release** with a build running [Go 1.6 and 1.7](https://docs.travis-ci.com/user/languages/go). See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
It's recommended to run the `semantic-release` command in the [Travis `deploy` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error occurs the build will fail and Travis will send a notification.
-65
View File
@@ -1,65 +0,0 @@
# Using semantic-release with [CircleCI 2.0 workflows](https://circleci.com/docs/2.0/workflows)
## Environment variables
The [Authentication](../usage/ci-configuration.md#authentication) environment variables can be configured in [CircleCi Project Settings](https://circleci.com/docs/2.0/env-vars/#adding-environment-variables-in-the-app)..
Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../usage/getting-started.md#getting-started).
## Multiple Node jobs configuration
### `.circleci/config.yml` configuration for multiple Node jobs
This example is a minimal configuration for **semantic-release** with a build running Node 6 and 8. See [CircleCI documentation](https://circleci.com/docs/2.0) for additional configuration options.
This example create the workflows `test_node_4`, `test_node_6`, `test_node_8` and `release`. The release workflows will [run `semantic-release` only after the all the `test_node_*` are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
```yaml
version: 2
jobs:
test_node_6:
docker:
- image: circleci/node:6
steps:
# Configure your test steps here (checkout, npm install, cache management, tests etc...)
test_node_8:
docker:
- image: circleci/node:8
steps:
# Configure your test steps here (checkout, npm install, cache management, tests etc...)
release:
docker:
- image: circleci/node:8
steps:
- checkout
- run: npm install
# Run optional required steps before releasing
# - run: npm run build-script
- run: npx semantic-release
workflows:
version: 2
test_and_release:
# Run the test jobs first, then the release only when all the test jobs are successful
jobs:
- test_node_6
- test_node_8
- release:
requires:
- test_node_6
- test_node_8
```
### `package.json` configuration for multiple Node jobs
A `package.json` is required only for [local](../usage/installation.md#local-installation) **semantic-release** installation.
```json
{
"devDependencies": {
"semantic-release": "^15.0.0"
}
}
```
@@ -0,0 +1,3 @@
# Git hosted services
- [Git authentication with SSH keys](git-auth-ssh-keys.md)
@@ -1,6 +1,6 @@
# Git authentication with SSH keys
When using [environment variables](../usage/ci-configuration.md#authentication) to set up the Git authentication, the remote Git repository will automatically be accessed via [https](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#_the_http_protocols), independently of the [`repositoryUrl`](../usage/configuration.md#repositoryurl) format configured in the **semantic-release** [Configuration](../usage/configuration.md#configuration) (the format will be automatically converted as needed).
When using [environment variables](../../usage/ci-configuration.md#authentication) to set up the Git authentication, the remote Git repository will automatically be accessed via [https](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#_the_http_protocols), independently of the [`repositoryUrl`](../../usage/configuration.md#repositoryurl) format configured in the **semantic-release** [Configuration](../../usage/configuration.md#configuration) (the format will be automatically converted as needed).
Alternatively the Git repository can be accessed via [SSH](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#_the_ssh_protocol) by creating SSH keys, adding the public one to your Git hosted account and making the private one available on the CI environment.
@@ -21,6 +21,7 @@ This will generate a public key in `git_deploy_key.pub` and a private key in `gi
## Adding the SSH public key to the Git hosted account
Step by step instructions are provided for the following Git hosted services:
- [GitHub](#adding-the-ssh-public-key-to-github)
### Adding the SSH public key to GitHub
@@ -44,6 +45,7 @@ See [Adding a new SSH key to your GitHub account](https://help.github.com/articl
In order to be available on the CI environment, the SSH private key must be encrypted, committed to the Git repository and decrypted by the CI service.
Step by step instructions are provided for the following environments:
- [Travis CI](#adding-the-ssh-private-key-to-travis-ci)
- [Circle CI](#adding-the-ssh-private-key-to-circle-ci)
@@ -109,7 +111,7 @@ $ git push
### Adding the SSH private key to Circle CI
First we encrypt the `git_deploy_key` (private key) using a symmetric encryption (AES-256). Run the following `openssl` command and *make sure to note the output which we'll need later*:
First we encrypt the `git_deploy_key` (private key) using a symmetric encryption (AES-256). Run the following `openssl` command and _make sure to note the output which we'll need later_:
```bash
$ openssl aes-256-cbc -e -p -in git_deploy_key -out git_deploy_key.enc -K `openssl rand -hex 32` -iv `openssl rand -hex 16`
@@ -119,6 +121,7 @@ iv =VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
```
Add the following [environment variables](https://circleci.com/docs/2.0/env-vars/#adding-environment-variables-in-the-app) to Circle CI:
- `SSL_PASSPHRASE` - the value set during the [SSH keys generation](#generating-the-ssh-keys) step.
- `REPO_ENC_KEY` - the `key` (KKK) value from the `openssl` step above.
- `REPO_ENC_IV` - the `iv` (VVV) value from the `openssl` step above.
+5
View File
@@ -0,0 +1,5 @@
# Release workflow
- [Publishing on distribution channels](distribution-channels.md)
- [Publishing maintenance releases](maintenance-releases.md)
- [Publishing pre-releases](pre-releases.md)
@@ -1,10 +1,11 @@
# Publishing on distribution channels
This recipe will walk you through a simple example that uses distribution channels to make releases available only to a subset of users, in order to collect feedbacks before distributing the release to all users.
This recipe will walk you through a simple example that uses distribution channels to make releases available only to a subset of users, in order to collect feedback before distributing the release to all users.
This example uses the **semantic-release** default configuration:
- [branches](../usage/configuration.md#branches): `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`
- [plugins](../usage/configuration.md#plugins): `['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/npm', '@semantic-release/github']`
- [branches](../../usage/configuration.md#branches): `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`
- [plugins](../../usage/configuration.md#plugins): `['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/npm', '@semantic-release/github']`
## Initial release
@@ -97,7 +98,7 @@ The Git history of the repository is now:
After a period of feedback from our users using the `@next` dist-tag we feel confident to make our big feature available to all users. To do so we merge the `next` branch into `master`. There should be no conflict as `next` is strictly ahead of `master`.
Once the merge commit is pushed to `next`, **semantic-release** will add the version `2.1.0` to the dist-tag `@latest` so all users will receive it when installing out module with `npm install example-module`.
Once the merge commit is pushed to `master`, **semantic-release** will add the version `2.1.0` to the dist-tag `@latest` so all users will receive it when installing out module with `npm install example-module`.
The Git history of the repository is now:
@@ -3,8 +3,9 @@
This recipe will walk you through a simple example that uses Git branches and distribution channels to publish fixes and features for old versions of a package.
This example uses the **semantic-release** default configuration:
- [branches](../usage/configuration.md#branches): `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`
- [plugins](../usage/configuration.md#plugins): `['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/npm', '@semantic-release/github']`
- [branches](../../usage/configuration.md#branches): `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`
- [plugins](../../usage/configuration.md#plugins): `['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/npm', '@semantic-release/github']`
## Initial release
@@ -18,7 +19,7 @@ The Git history of the repository is:
## Releasing a breaking change
We now decide to drop Node.js 6 support for our package, and require Node.js 8 or higher, which is a breaking change.
We now decide to drop Node.js 6 support for our package, and require Node.js 8 or higher, which is a breaking change.
We commit that change with the message `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required` to `master`. When pushing that commit, **semantic-release** will release the version `2.0.0` on the dist-tag `@latest`.
@@ -33,7 +34,7 @@ The Git history of the repository is now:
One of our users request a new feature, however they cannot migrate to Node.js 8 or higher due to corporate policies.
If we were to push that feature on `master` and release it, the new version would require Node.js 8 or higher as the release would also contains the commit `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required`.
If we were to push that feature on `master` and release it, the new version would require Node.js 8 or higher as the release would also contain the commit `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required`.
Instead, we create the branch `1.x` from the tag `v1.0.0` with the command `git checkout -b 1.x v1.0.0` and we commit that feature with the message `feat: a feature` to the branch `1.x`. When pushing that commit, **semantic-release** will release the version `1.1.0` on the dist-tag `@release-1.x` so users who can't migrate to Node.js 8 or higher can benefit from it.
@@ -48,7 +49,7 @@ The Git history of the repository is now:
## Releasing a bug fix for version 1.0.x users
Another user currently using version `1.0.0` reports a bug. They cannot migrate to Node.js 8 or higher and they also cannot migrate to `1.1.0` as they do not use the feature developed in `feat: a feature` and their corporate policies require to go through a costly quality insurance process for each `minor` upgrades.
Another user currently using version `1.0.0` reports a bug. They cannot migrate to Node.js 8 or higher and they also cannot migrate to `1.1.0` as they do not use the feature developed in `feat: a feature` and their corporate policies require to go through a costly quality assurance process for each `minor` upgrades.
In order to deliver the bug fix in a `patch` release, we create the branch `1.0.x` from the tag `v1.0.0` with the command `git checkout -b 1.0.x v1.0.0` and we commit that fix with the message `fix: a fix` to the branch `1.0.x`. When pushing that commit, **semantic-release** will release the version `1.0.1` on the dist-tag `@release-1.0.x` so users who can't migrate to `1.1.x` or `2.x` can benefit from it.
@@ -3,8 +3,9 @@
This recipe will walk you through a simple example that uses pre-releases to publish beta versions while working on a future major release and then make only one release on the default distribution.
This example uses the **semantic-release** default configuration:
- [branches](../usage/configuration.md#branches): `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`
- [plugins](../usage/configuration.md#plugins): `['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/npm', '@semantic-release/github']`
- [branches](../../usage/configuration.md#branches): `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`
- [plugins](../../usage/configuration.md#plugins): `['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/npm', '@semantic-release/github']`
## Initial release
@@ -61,7 +62,7 @@ The Git history of the repository is now:
We now decide to work on another future major release, in parallel of the beta one, which will also be composed of multiple features, some of them being breaking changes.
To implement that workflow we can create the branch `alpha` from the branch `beta` and commit our first feature there. When pushing that commit, **semantic-release** will publish the pre-release version `3.0.0-alpha.1` on the dist-tag `@alpha`. That allow us to run integration tests by installing our module with `npm install example-module@alpha`. Other users installing with `npm install example-module` will still receive the version `1.0.0`.
To implement that workflow we can create the branch `alpha` from the branch `beta` and commit our first feature there. When pushing that commit, **semantic-release** will publish the pre-release version `3.0.0-alpha.1` on the dist-tag `@alpha`. That allow us to run integration tests by installing our module with `npm install example-module@alpha`. Other users installing with `npm install example-module` will still receive the version `1.0.1`.
The Git history of the repository is now:
+37 -74
View File
@@ -4,11 +4,11 @@
[`@semantic-release/npm`](https://github.com/semantic-release/npm) takes care of updating the `package.json`s version before publishing to [npm](https://www.npmjs.com).
By default, only the published package will contain the version, which is the only place where it is *really* required, but the updated `package.json` will not be pushed to the Git repository
By default, only the published package will contain the version, which is the only place where it is _really_ required, but the updated `package.json` will not be pushed to the Git repository
However, the [`@semantic-release/git`](https://github.com/semantic-release/git) plugin can be used to push the updated `package.json` as well as other files to the Git repository.
If you wish to only update the `package.json` and push via Git you can set the project to `"private": true,` within your `package.json` to prevent publishing to [npm](https://www.npmjs.com). This can be useful for using **semantic-release** with a non-node project.
If you wish to only update the `package.json` and push via Git you can set the project to `"private": true,` within your `package.json` to prevent publishing to [the npm registry](https://www.npmjs.com).
## How can I use a npm build script that requires the `package.json`s version ?
@@ -17,19 +17,24 @@ The `package.json`s version will be updated by the `semantic-release` command
As the [`@semantic-release/npm`](https://github.com/semantic-release/npm) plugin uses the [npm CLI](https://docs.npmjs.com/cli/npm) to update the `package.json` version and publish the package, all [npm hook scripts](https://docs.npmjs.com/misc/scripts#description) will be executed.
You can run your build script in:
- the `prepublishOnly` or `prepack` hook so it will be executed during the `publish` step of `@semantic-release/npm`
- the `postversion` hook so it will be executed during the `prepare` step of `@semantic-release/npm`, which allow for example to update files before committing them with the [`@semantic-release/git`](https://github.com/semantic-release/git) plugin
If using npm hook scripts is not possible, and alternative solution is to [`@semantic-release/exec`](https://github.com/semantic-release/exec) plugin to run your script in the `prepare` step:
```json
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
["@semantic-release/exec", {
"prepareCmd": "./my-build-script.sh ${nextRelease.version}",
}],
[
"@semantic-release/exec",
{
"prepareCmd": "./my-build-script.sh ${nextRelease.version}"
}
]
]
}
```
@@ -38,48 +43,19 @@ If using npm hook scripts is not possible, and alternative solution is to [`@sem
Yes with the [dry-run options](../usage/configuration.md#dryrun) which prints to the console the next version to be published and the release notes.
## Can I use semantic-release with Yarn?
If you are using a [local](../usage/installation.md#local-installation) **semantic-release** installation and run multiple CI jobs with different versions, the `yarn install` command will fail on jobs running with Node < 8 as **semantic-release** requires [Node >= 10.18](#why-does-semantic-release-require-node-version--1018) and specifies it in its `package.json`s [`engines`](https://docs.npmjs.com/files/package.json#engines) key.
The recommended solution is to use the [Yarn](https://yarnpkg.com) [--ignore-engines](https://yarnpkg.com/en/docs/cli/install#toc-yarn-install-ignore-engines) option to install the project dependencies on the CI environment, so Yarn will ignore the **semantic-release**'s `engines` key:
```bash
$ yarn install --ignore-engines
```
**Note**: Several CI services use Yarn by default if your repository contains a `yarn.lock` file. So you should override the install step to specify `yarn install --ignore-engines`.
Alternatively you can use a [global](../usage/installation.md#global-installation) **semantic-release** installation and make sure to install and run the `semantic-release` command only in a CI jobs running with Node >= 10.18.
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can switch to Node 8 before installing and running the `semantic-release` command:
```bash
$ nvm install 8 && yarn global add semantic-release && semantic-release
```
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
As `semantic-release` is recommended to be executed with [`npx`](https://www.npmjs.com/package/npx) an alternative is required for usage with Yarn. Even though it is possible to install npx with Yarn, it's not recommended. Yarn and npx would be using different cache locations.
For [local installation](../usage/installation.md#local-installation) replace
`npx semantic-release` with `yarn run semantic-release`.
For [global installation](../usage/installation.md#global-installation) replace
`npx semantic-release` with `yarn global add semantic-release && semantic-release`.
## Can I use semantic-release to publish non-JavaScript packages?
Yes, **semantic-release** is a Node CLI application but it can be used to publish any type of packages.
Yes, **semantic-release** is a Node CLI application, but it can be used to publish any type of packages.
To publish a non-Node package (without a `package.json`) you would need to:
- Use a [global](../usage/installation.md#global-installation) **semantic-release** installation
- Set **semantic-release** [options](../usage/configuration.md#options) via [CLI arguments or rc file](../usage/configuration.md#configuration)
- Make sure your CI job executing the `semantic-release` command has access to [Node >= 10.18](#why-does-semantic-release-require-node-version--1018) to execute the `semantic-release` command
- Set **semantic-release** [options](../usage/configuration.md#options) via [CLI arguments or `.rc` file](../usage/configuration.md#configuration)
- Make sure your CI job executing the `semantic-release` command has access to a version of Node that [meets our version requirement](./node-version.md) to execute the `semantic-release` command
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
See the [CI configuration recipes](../recipes/release-workflow/README.md#ci-configurations) for more details on specific CI environments.
In addition you will need to configure the **semantic-release** [plugins](../usage/plugins.md#plugins) to disable the [`@semantic-release/npm`](https://github.com/semantic-release/npm) plugin which is used by default and use a plugin for your project type.
In addition, you will need to configure the **semantic-release** [plugins](../usage/plugins.md#plugins) to disable the [`@semantic-release/npm`](https://github.com/semantic-release/npm) plugin which is used by default and use a plugin for your project type.
If there is no specific plugin for your project type you can use the [`@semantic-release/exec`](https://github.com/semantic-release/exec) plugin to publish the release with a shell command.
@@ -91,25 +67,29 @@ Here is a basic example to create [GitHub releases](https://help.github.com/arti
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
["@semantic-release/exec", {
"prepareCmd" : "set-version ${nextRelease.version}",
"publishCmd" : "publish-package"
}]
[
"@semantic-release/exec",
{
"prepareCmd": "set-version ${nextRelease.version}",
"publishCmd": "publish-package"
}
]
]
}
```
**Note**: This is a theoretical example where the command `set-version` update the project version with the value passed as its first argument and `publish-package` publishes the package to a registry.
See the [package managers and languages recipes](../recipes/README.md#package-managers-and-languages) for more details on specific project types.
See the [package managers and languages recipes](../recipes/release-workflow/README.md#package-managers-and-languages) for more details on specific project types.
## Can I use semantic-release with any CI service?
Yes, **semantic-release** can be used with any CI service, as long as it provides:
- A way to set [authentication](../usage/ci-configuration.md#authentication) via environment variables
- A way to guarantee that the `semantic-release` command is [executed only after all the tests of all the jobs in the CI build pass](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded)
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
See the [CI configuration recipes](../recipes/release-workflow/README.md#ci-configurations) for more details on specific CI environments.
## Can I run semantic-release on my local machine rather than on a CI server?
@@ -125,11 +105,11 @@ However this is not the recommended approach, as running unit and integration te
Yes, with the [`@semantic-release/gitlab-config`](https://github.com/semantic-release/gitlab-config) shareable configuration.
See the [GitLab CI recipes](../recipes/gitlab-ci.md#using-semantic-release-with-gitlab-ci) for the CI configuration.
See the [GitLab CI recipes](../recipes/ci-configurations/gitlab-ci.md#using-semantic-release-with-gitlab-ci) for the CI configuration.
## Can I use semantic-release with any Git hosted environment?
By default **semantic-release** uses the [`@semantic-release/github`](https://github.com/semantic-release/github) plugin to publish a [GitHub release](https://help.github.com/articles/about-releases). For other Git hosted environment the [`@semantic-release/git`](https://github.com/semantic-release/git) and [`@semantic-release/changelog`](https://github.com/semantic-release/changelog) plugins can be used via [plugins configuration](../usage/plugins.md).
By default **semantic-release** uses the [`@semantic-release/github`](https://github.com/semantic-release/github) plugin to publish a [GitHub release](https://help.github.com/articles/about-releases). For other Git hosted environment the [`@semantic-release/git`](https://github.com/semantic-release/git) and [`@semantic-release/changelog`](https://github.com/semantic-release/changelog) plugins can be used via [plugins configuration](../usage/plugins.md).
See the [`@semantic-release/git`](https://github.com/semantic-release/git#semantic-releasegit) [`@semantic-release/changelog`](https://github.com/semantic-release/changelog#semantic-releasechangelog) plugins documentation for more details.
@@ -142,6 +122,7 @@ See the [`@semantic-release/npm`](https://github.com/semantic-release/npm#semant
## How can I revert a release?
If you have introduced a breaking bug in a release you have 2 options:
- If you have a fix immediately ready, commit and push it (or merge it via a pull request) to the release branch
- Otherwise, [revert the commit](https://git-scm.com/docs/git-revert) that introduced the bug and push the revert commit (or merge it via a pull request) to the release branch
@@ -151,7 +132,7 @@ Depending on the package manager you are using, you might be able to un-publish
In any case **do not remove the Git tag associated with the buggy version**, otherwise **semantic-release** will later try to republish that version. Publishing a version after un-publishing is not supported by most package managers.
**Note**: If you are using the default [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) be aware that it uses a different revert commit format than the standard one created by [git revert](https://git-scm.com/docs/git-revert), contrary to what is [claimed in the convention](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#revert). Therefore, if you revert a commit with [`git revert`](https://git-scm.com/docs/git-revert), use the [`--edit` option](https://git-scm.com/docs/git-revert#git-revert---edit) to format the message according to the [Angular revert commit message format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#revert). See [conventional-changelog/conventional-changelog#348](https://github.com/conventional-changelog/conventional-changelog/issues/348) for more details.
**Note**: If you are using the default [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) be aware that it uses a different revert commit format than the standard one created by [git revert](https://git-scm.com/docs/git-revert), contrary to what is [claimed in the convention](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#revert). Therefore, if you revert a commit with [`git revert`](https://git-scm.com/docs/git-revert), use the [`--edit` option](https://git-scm.com/docs/git-revert#git-revert---edit) to format the message according to the [Angular revert commit message format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#revert). See [conventional-changelog/conventional-changelog#348](https://github.com/conventional-changelog/conventional-changelog/issues/348) for more details.
## Can I use `.npmrc` options?
@@ -177,17 +158,9 @@ Or with the `publishConfig.access` key in your project's `package.json`:
}
```
## Can I use semantic-release to publish a package on Artifactory?
Any npm compatible registry is supported with the [`@semantic-release/npm`](https://github.com/semantic-release/npm) plugin. For Artifactory versions prior to 5.4, the legacy authentication has to be used (with `NPM_USERNAME`, `NPM_PASSWORD` and `NPM_EMAIL` [environment variables](https://github.com/semantic-release/npm#environment-variables)).
See [npm registry authentication](https://github.com/semantic-release/npm#npm-registry-authentication) for more details.
See [Artifactory - npm Registry](https://www.jfrog.com/confluence/display/RTF/Npm+Registry#NpmRegistry-AuthenticatingthenpmClient) documentation for Artifactiry configuration.
## Can I manually trigger the release of a specific version?
You can trigger a release by pushing to your Git repository. You deliberately cannot trigger a *specific* version release, because this is the whole point of semantic-release.
You can trigger a release by pushing to your Git repository. You deliberately cannot trigger a _specific_ version release, because this is the whole point of semantic-release.
## Can I exclude commits from the analysis?
@@ -198,7 +171,7 @@ Yes, every commits that contains `[skip release]` or `[release skip]` in their m
By default **semantic-release** uses the [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) and triggers releases based on the following rules:
| Commit | Release type |
|-----------------------------|----------------------------|
| --------------------------- | -------------------------- |
| Commit with breaking change | ~~Major~~ Breaking release |
| Commit with type `feat` | ~~Minor~~ Feature release |
| Commit with type `fix` | Patch release |
@@ -208,9 +181,9 @@ See the [`@semantic-release/npm`](https://github.com/semantic-release/npm#npm-co
This is fully customizable with the [`@semantic-release/commit-analyzer`](https://github.com/semantic-release/commit-analyzer) plugin's [`release-rules` option](https://github.com/semantic-release/commit-analyzer#release-rules).
## Is it *really* a good idea to release on every push?
## Is it _really_ a good idea to release on every push?
It is indeed a great idea because it *forces* you to follow best practices. If you dont feel comfortable releasing every feature or fix on your `master` you might not treat your `master` branch as intended.
It is indeed a great idea because it _forces_ you to follow best practices. If you dont feel comfortable releasing every feature or fix on your `master` you might not treat your `master` branch as intended.
From [Understanding the GitHub Flow](https://guides.github.com/introduction/flow/index.html):
@@ -224,25 +197,15 @@ If you need more control over the timing of releases, see [Triggering a release]
This is not supported by **semantic-release** as it's not considered a good practice, mostly because [Semantic Versioning](https://semver.org) rules applies differently to major version zero.
If your project is under heavy development, with frequent breaking changes, and is not production ready yet we recommend [publishing pre-releases](../recipes/pre-releases.md#publishing-pre-releases).
If your project is under heavy development, with frequent breaking changes, and is not production ready yet we recommend [publishing pre-releases](../recipes/release-workflow/pre-releases.md#publishing-pre-releases).
See [“Introduction to SemVer” - Irina Gebauer](https://blog.greenkeeper.io/introduction-to-semver-d272990c44f2) for more details on [Semantic Versioning](https://semver.org) and the recommendation to start at version `1.0.0`.
## Can I trust semantic-release with my releases?
**semantic-release** has a full unit and integration test suite that tests `npm` publishes against the [npm-registry-couchapp](https://github.com/npm/npm-registry-couchapp).
**semantic-release** has a full unit and integration test suite that tests `npm` publishes against the [verdaccio](https://www.npmjs.com/package/verdaccio).
In addition the [verify conditions step](../../README.md#release-steps) verifies that all necessary conditions for proceeding with a release are met, and a new release will be performed [only if all your tests pass](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
## Why does semantic-release require Node version >= 10.18?
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which **requires Node version 10.18 or higher**.
See [Node version requirement](./node-version.md#node-version-requirement) for more details and solutions.
## Why does semantic-release require Git version >= 2.7.1?
**semantic-release** uses Git CLI commands to read information about the repository such as branches, commit history and tags. Certain commands and options (such as [the `--merged` option of the `git tag` command](https://git-scm.com/docs/git-tag/2.7.0#git-tag---no-mergedltcommitgt) or bug fixes related to `git ls-files`) used by **semantic-release** are only available in Git version 2.7.1 and higher.
In addition, the [verify conditions step](../../README.md#release-steps) verifies that all necessary conditions for proceeding with a release are met, and a new release will be performed [only if all your tests pass](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
## What is npx?
+4
View File
@@ -0,0 +1,4 @@
# Git version requirement
**semantic-release** uses Git CLI commands to read information about the repository such as branches, commit history and tags.
Certain commands and options (such as [the `--merged` option of the `git tag` command](https://git-scm.com/docs/git-tag/2.7.0#git-tag---no-mergedltcommitgt) or bug fixes related to `git ls-files`) used by **semantic-release** are only available in Git version 2.7.1 and higher.
+13 -5
View File
@@ -1,13 +1,21 @@
# Node Support Policy
We only support [Long-Term Support](https://github.com/nodejs/Release) versions of Node starting with [Node 8.9.0 (LTS)](https://nodejs.org/en/blog/release/v8.9.0).
We will always support at least the latest [Long-Term Support](https://github.com/nodejs/Release) version of Node, but provide no promise of support for older versions.
The supported range will always be defined in the `engines.node` property of the `package.json` of our packages.
We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.
It's possible this package will work correctly on newer versions of Node. It may even be possible to use this package on older versions of Node, though that's more unlikely as we'll make every effort to take advantage of features available in the oldest LTS version we support.
It's possible this package will work correctly on newer versions of Node.
It may even be possible to use this package on older versions of Node, though that's more unlikely as we'll make every effort to take advantage of features available in the oldest LTS version we support.
As each Node LTS version reaches its end-of-life we will remove that version from the node engines property of our package's package.json file. Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package. We will not accept any requests to support an end-of-life version of Node. Any merge requests or issues supporting an end-of-life version of Node will be closed.
As new Node LTS versions become available we may remove previous versions from the `engines.node` property of our package's `package.json` file.
Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package.
We will not accept any requests to support an end-of-life version of Node.
Any merge requests or issues supporting an end-of-life version of Node will be closed.
We will accept code that allows this package to run on newer, non-LTS, versions of Node. Furthermore, we will attempt to ensure our own changes work on the latest version of Node. To help in that commitment, our continuous integration setup runs against all LTS versions of Node in addition the most recent Node release; called current.
We will accept code that allows this package to run on newer, non-LTS, versions of Node.
Furthermore, we will attempt to ensure our own changes work on the latest version of Node.
To help in that commitment, our continuous integration setup runs against all LTS versions of Node in addition the most recent Node release; called current.
JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our node engines property. If you encounter issues installing this package, please report the issue to your package manager.
JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our node engines property.
If you encounter issues installing this package, please report the issue to your package manager.
+14 -11
View File
@@ -1,35 +1,38 @@
# Node version requirement
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which requires **requires Node version 10 or higher**.
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which **requires Node version 18.0.0 or higher**.
**semantic-release** is meant to be used in a CI environment as a development support tool, not as a production dependency. Therefore the only constraint is to run the `semantic-release` in a CI environment providing Node 8 or higher.
**semantic-release** is meant to be used in a CI environment as a development support tool, not as a production dependency.
Therefore, the only constraint is to run the `semantic-release` in a CI environment providing version of Node that meets our version requirement.
See our [Node Support Policy](node-support-policy.md) for our long-term promise regarding Node version support.
## Recommended solution
### Run at least one CI job with Node >= 10.18
### Run at least one CI job with a version of Node that meets our version requirement
The recommended approach is to run the `semantic-release` command from a CI job running on Node 10.18 or higher. This can either be a job used by your project to test on Node >= 10.18 or a dedicated job for the release steps.
The recommended approach is to run the `semantic-release` command from a CI job running on the latest available LTS version of node.
This can either be a job used by your project to test on the latest Node LTS version or a dedicated job for the release steps.
See [CI configuration](../usage/ci-configuration.md) and [CI configuration recipes](../recipes/README.md#ci-configurations) for more details.
See [CI configuration](../usage/ci-configuration.md) and [CI configuration recipes](../recipes/ci-configurations/README.md#ci-configurations) for more details.
## Alternative solutions
### Use `npx`
### Use `npx` to execute in the latest LTS version of Node
`npx` is included with npm >= 5.2 and can be used to download the latest [Node 8 package published on npm](https://www.npmjs.com/package/node). Use it to execute the `semantic-release` command.
`npx` is included with npm >= 5.2 and can be used to download the latest [Node LTS package published on npm](https://www.npmjs.com/package/node).
Use it to execute the `semantic-release` command.
```bash
$ npx -p node@8 -c "npx semantic-release"
$ npx -p node@v18-lts -c "npx semantic-release"
```
**Note:**: See [What is npx](./FAQ.md#what-is-npx) for more details.
**Note**: See [What is npx](./FAQ.md#what-is-npx) for more details.
### Use `nvm`
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can use it to switch to Node 8 before running the `semantic-release` command.
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can use it to switch to the latest LTS version of Node before running the `semantic-release` command.
```bash
$ nvm install 8 && npx semantic-release
$ nvm install 'lts/*' && npx semantic-release
```
+1
View File
@@ -15,6 +15,7 @@
- ["Introduction to SemVer" - Irina Gebauer](https://blog.greenkeeper.io/introduction-to-semver-d272990c44f2)
- ["Introduction to Semantic Release" - liv](https://blog.greenkeeper.io/introduction-to-semantic-release-33f73b117c8)
- ["Series - Semantic Release Automation" - Abdelrahman Wahdan](https://dev.to/abdelrahmanahmed/semantic-release-and-how-to-automate-it-part-1-4pa2)
- ["Explain semantic release and how to use it on GitLab pipeline"](https://regoo707.medium.com/auto-bump-apps-versions-and-releases-using-gitlab-pipeline-e32f1d7fa3ee)
## Tutorials
+4 -3
View File
@@ -15,6 +15,7 @@ This is most likely related to a misconfiguration of the [npm registry authentic
It might also happen if the package name you are trying to publish already exists (in the case of npm, you may be trying to publish a new version of a package that is not yours, hence the permission error).
To verify if your package name is available you can use [npm-name-cli](https://github.com/sindresorhus/npm-name-cli):
```bash
$ npm install --global npm-name-cli
$ npm-name <package-name>
@@ -30,7 +31,7 @@ When [squashing commits](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-Hist
When squashing commits make sure to rewrite the resulting commit message to be compliant with the project's commit message convention.
**Note**: if the resulting squashed commit would encompasses multiple changes (for example multiple unrelated features or fixes) then it's probably not a good idea to squash those commits together. A commit should contain exactly one self-contained functional change and a functional change should be contained in exactly one commit. See [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit).
**Note**: if the resulting squashed commit encompasses multiple changes (for example multiple unrelated features or fixes) then it's probably not a good idea to squash those commits together. A commit should contain exactly one self-contained functional change and a functional change should be contained in exactly one commit. See [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit).
## `reference already exists` error when pushing tag
@@ -63,7 +64,7 @@ After a git history rewrite due to a `git push --force`, the git tags and notes
To recover from that situation, do the following:
1. Delete the tag(s) for the release(s) that have been lost from the git history. You can delete each tag from remote using `git push origin :[TAG NAME]`, e.g. `git push origin :v2.0.0-beta.1`. You can delete tags locally using `git tag -d [TAG NAME]`, e.g. `git tag -d v2.0.0-beta.1`.
1. Delete the tag(s) for the release(s) that have been lost from the git history. You can delete each tag from remote using `git push origin -d :[TAG NAME]`, e.g. `git push origin -d :v2.0.0-beta.1`. You can delete tags locally using `git tag -d [TAG NAME]`, e.g. `git tag -d v2.0.0-beta.1`.
2. Re-create the tags locally: `git tag [TAG NAME] [COMMIT HASH]`, where `[COMMIT HASH]` is the new commit that created the release for the lost tag. E.g. `git tag v2.0.0-beta.1 abcdef0`
3. Re-create the git notes for each release tag, e.g. `git notes --ref semantic-release add -f -m '{"channels":["beta"]}' v3.0.0-beta.1`. If the release was also published in the default channel (usually `master`), then set the first channel to `null`, e.g. `git notes --ref semantic-release add -f -m '{"channels":[null, "beta"]}'
3. Re-create the git notes for each release tag, e.g. `git notes --ref semantic-release add -f -m '{"channels":["beta"]}' v2.0.0-beta.1`. If the release was also published in the default channel (usually `master`), then set the first channel to `null`, e.g. `git notes --ref semantic-release add -f -m '{"channels":[null, "beta"]}'`
4. Push the local notes: `git push --force origin refs/notes/semantic-release`. The `--force` is needed after the rebase. Be careful.
+9 -8
View File
@@ -3,17 +3,18 @@
## Run `semantic-release` only after all tests succeeded
The `semantic-release` command must be executed only after all the tests in the CI build pass. If the build runs multiple jobs (for example to test on multiple Operating Systems or Node versions) the CI has to be configured to guarantee that the `semantic-release` command is executed only after all jobs are successful.
Here is a few example of the CI services that can be used to achieve this:
Here are a few examples of the CI services that can be used to achieve this:
- [Travis Build Stages](https://docs.travis-ci.com/user/build-stages)
- [CircleCI Workflows](https://circleci.com/docs/2.0/workflows)
- [GitHub Actions](https://github.com/features/actions)
- [Codeship Deployment Pipelines](https://documentation.codeship.com/basic/builds-and-configuration/deployment-pipelines)
- [GitLab Pipelines](https://docs.gitlab.com/ee/ci/pipelines.html#introduction-to-pipelines-and-jobs)
- [GitLab Pipelines](https://docs.gitlab.com/ce/ci/introduction/)
- [Codefresh Pipelines](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/introduction-to-codefresh-pipelines)
- [Wercker Workflows](http://devcenter.wercker.com/docs/workflows)
- [GoCD Pipelines](https://docs.gocd.org/current/introduction/concepts_in_go.html#pipeline).
See [CI configuration recipes](../recipes/README.md#ci-configurations) for more details.
See [CI configuration recipes](../recipes/ci-configurations/README.md) for more details.
## Authentication
@@ -22,21 +23,21 @@ See [CI configuration recipes](../recipes/README.md#ci-configurations) for more
**semantic-release** requires push access to the project Git repository in order to create [Git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). The Git authentication can be set with one of the following environment variables:
| Variable | Description |
|-------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GH_TOKEN` or `GITHUB_TOKEN` | A GitHub [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line). |
| `GL_TOKEN` or `GITLAB_TOKEN` | A GitLab [personal access token](https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html). |
| `BB_TOKEN` or `BITBUCKET_TOKEN` | A Bitbucket [personal access token](https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html). |
| `BB_TOKEN_BASIC_AUTH` or `BITBUCKET_TOKEN_BASIC_AUTH` | A Bitbucket [personal access token](https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html) with basic auth support. For clearification `user:token` has to be the value of this env. |
| `BB_TOKEN_BASIC_AUTH` or `BITBUCKET_TOKEN_BASIC_AUTH` | A Bitbucket [personal access token](https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html) with basic auth support. For clarification `user:token` has to be the value of this env. |
| `GIT_CREDENTIALS` | [URL encoded](https://en.wikipedia.org/wiki/Percent-encoding) Git username and password in the format `<username>:<password>`. The username and password must each be individually URL encoded, not the `:` separating them. |
Alternatively the Git authentication can be set up via [SSH keys](../recipes/git-auth-ssh-keys.md).
Alternatively the Git authentication can be set up via [SSH keys](../recipes/git-hosted-services/git-auth-ssh-keys.md).
### Authentication for plugins
Most **semantic-release** [plugins](plugins.md) require setting up authentication in order to publish to a package manager registry. The default [@semantic-release/npm](https://github.com/semantic-release/npm#environment-variables) and [@semantic-release/github](https://github.com/semantic-release/github#environment-variables) plugins require the following environment variables:
| Variable | Description |
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NPM_TOKEN` | npm token created via [npm token create](https://docs.npmjs.com/getting-started/working_with_tokens#how-to-create-new-tokens).<br/>**Note**: Only the `auth-only` [level of npm two-factor authentication](https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication) is supported. |
| `GH_TOKEN` | GitHub authentication token.<br/>**Note**: Only the [personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) authentication is supported. |
@@ -44,6 +45,6 @@ See each plugin's documentation for the environment variables required.
The authentication token/credentials have to be made available in the CI service via environment variables.
See [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on how to configure environment variables in your CI service.
See [CI configuration recipes](../recipes/ci-configurations/README.md) for more details on how to configure environment variables in your CI service.
**Note**: The environment variables `GH_TOKEN`, `GITHUB_TOKEN`, `GL_TOKEN` and `GITLAB_TOKEN` can be used for both the Git authentication and the API authentication required by [@semantic-release/github](https://github.com/semantic-release/github) and [@semantic-release/gitlab](https://github.com/semantic-release/gitlab).
+14 -8
View File
@@ -1,6 +1,7 @@
# Configuration
**semantic-release** configuration consists of:
- Git repository ([URL](#repositoryurl) and options [release branches](#branches) and [tag format](#tagformat))
- Plugins [declaration](#plugins) and options
- Run mode ([debug](#debug), [dry run](#dryrun) and [local (no CI)](#ci))
@@ -12,8 +13,9 @@ Additionally, metadata of Git tags generated by **semantic-release** can be cust
## Configuration file
**semantic-release**s [options](#options), mode and [plugins](plugins.md) can be set via either:
- A `.releaserc` file, written in YAML or JSON, with optional extensions: .`yaml`/`.yml`/`.json`/`.js`
- A `release.config.js` file that exports an object
- A `.releaserc` file, written in YAML or JSON, with optional extensions: `.yaml`/`.yml`/`.json`/`.js`/`.cjs`
- A `release.config.(js|cjs)` file that exports an object
- A `release` key in the project's `package.json` file
Alternatively, some options can be set via CLI arguments.
@@ -21,6 +23,7 @@ Alternatively, some options can be set via CLI arguments.
The following three examples are the same.
- Via `release` key in the project's `package.json` file:
```json
{
"release": {
@@ -30,6 +33,7 @@ The following three examples are the same.
```
- Via `.releaserc` file:
```json
{
"branches": ["master", "next"]
@@ -37,6 +41,7 @@ The following three examples are the same.
```
- Via CLI argument:
```bash
$ semantic-release --branches next
```
@@ -45,7 +50,7 @@ $ semantic-release --branches next
**Note**: Plugin options cannot be defined via CLI arguments and must be defined in the configuration file.
**Note**: When configuring via `package.json`, the configuration must be under the `release` property. However, when using a `.releaserc` or a `release.config.js` file, the configuration must be set without a `release` property.
**Note**: When configuring via `package.json`, the configuration must be under the `release` property. However, when using a `.releaserc` or a `release.config` file, the configuration must be set without a `release` property.
## Options
@@ -65,12 +70,13 @@ Default: `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name:
CLI arguments: `--branches`
The branches on which releases should happen. By default **semantic-release** will release:
- regular releases to the default distribution channel from the branch `master`
- regular releases to a distribution channel matching the branch name from any existing branch with a name matching a maintenance release range (`N.N.x` or `N.x.x` or `N.x` with `N` being a number)
- regular releases to the `next` distribution channel from the branch `next` if it exists
- regular releases to the `next-major` distribution channel from the branch `next-major` if it exists
- prereleases to the `beta` distribution channel from the branch `beta` if it exists
- prereleases to the `alpha` distribution channel from the branch `alpha` if it exists
- regular releases to the `next-major` distribution channel from the branch `next-major` if it exists
- pre-releases to the `beta` distribution channel from the branch `beta` if it exists
- pre-releases to the `alpha` distribution channel from the branch `alpha` if it exists
**Note**: If your repository does not have a release branch, then **semantic-release** will fail with an `ERELEASEBRANCHES` error message. If you are using the default configuration, you can fix this error by pushing a `master` branch.
@@ -116,7 +122,7 @@ Type: `Boolean`<br>
Default: `false` if running in a CI environment, `true` otherwise<br>
CLI arguments: `-d`, `--dry-run`
The objective of the dry-run mode is to get a preview of the pending release. Dry-run mode skips the following steps: prepare, publish, success and fail. In addition to this it prints the next version and release notes to the console.
The objective of the dry-run mode is to get a preview of the pending release. Dry-run mode skips the following steps: prepare, publish, addChannel, success and fail. In addition to this it prints the next version and release notes to the console.
**Note**: The Dry-run mode verifies the repository push permission, even though nothing will be pushed. The verification is done to help user to figure out potential configuration issues.
@@ -143,7 +149,7 @@ Output debugging information. This can also be enabled by setting the `DEBUG` en
## Git environment variables
| Variable | Description | Default |
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ |
| `GIT_AUTHOR_NAME` | The author name associated with the [Git release tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging). See [Git environment variables](https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing). | @semantic-release-bot. |
| `GIT_AUTHOR_EMAIL` | The author email associated with the [Git release tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging). See [Git environment variables](https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing). | @semantic-release-bot email address. |
| `GIT_COMMITTER_NAME` | The committer name associated with the [Git release tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging). See [Git environment variables](https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing). | @semantic-release-bot. |
+24 -2
View File
@@ -24,6 +24,28 @@ For other type of projects we recommend installing **semantic-release** directly
$ npx semantic-release
```
**Note**: For a global installation, it's recommended to specify the major **semantic-release** version to install (for example with with `npx semantic-release@15`). This way your build will not automatically use the next major **semantic-release** release that could possibly break your build. You will have to upgrade manually when a new major version is released.
### Notes
**Note**: `npx` is a tool bundled with `npm@>=5.2.0`. It is used to conveniently install the semantic-release binary and to execute it. See [What is npx](../support/FAQ.md#what-is-npx) for more details.
1. If you've globally installed **semantic-release** then we recommend that you set the major **semantic-release** version to install.
For example, by using `npx semantic-release@18`.
This way you control which major version of **semantic-release** is used by your build, and thus avoid breaking the build when there's a new major version of **semantic-release**.
This also means you, or a bot, must upgrade **semantic-release** when a new major version is released.
2. Pinning **semantic-release** to an exact version makes your releases even more deterministic.
But pinning also means you, or a bot, must update to newer versions of **semantic-release** more often.
3. You can use [Renovate's regex manager](https://docs.renovatebot.com/modules/manager/regex/) to get automatic updates for **semantic-release** in either of the above scenarios.
Put this in your Renovate configuration file:
```json
{
"regexManagers": [
{
"description": "Update semantic-release version used by npx",
"fileMatch": ["^\\.github/workflows/[^/]+\\.ya?ml$"],
"matchStrings": ["\\srun: npx semantic-release@(?<currentValue>.*?)\\s"],
"datasourceTemplate": "npm",
"depNameTemplate": "semantic-release"
}
]
}
```
4. `npx` is a tool bundled with `npm@>=5.2.0`. You can use it to install (and run) the **semantic-release** binary.
See [What is npx](../support/FAQ.md#what-is-npx) for more details.
+14 -4
View File
@@ -5,7 +5,7 @@ Each [release step](../../README.md#release-steps) is implemented by configurabl
A plugin is a npm module that can implement one or more of the following steps:
| Step | Required | Description |
|--------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `verifyConditions` | No | Responsible for verifying conditions necessary to proceed with the release: configuration is correct, authentication token are valid, etc... |
| `analyzeCommits` | Yes | Responsible for determining the type of the next release (`major`, `minor` or `patch`). If multiple plugins with a `analyzeCommits` step are defined, the release type will be the highest one among plugins output. |
| `verifyRelease` | No | Responsible for verifying the parameters (version, type, dist-tag etc...) of the release that is about to be published. |
@@ -16,6 +16,8 @@ A plugin is a npm module that can implement one or more of the following steps:
| `success` | No | Responsible for notifying of a new release. |
| `fail` | No | Responsible for notifying of a failed release. |
Release steps will run in that order. At each step, **semantic-release** will run every plugin in the [`plugins` array](#plugins-declaration-and-execution-order), as long as the plugin implements the step.
**Note:** If no plugin with a `analyzeCommits` step is defined `@semantic-release/commit-analyzer` will be used.
## Plugins installation
@@ -23,6 +25,7 @@ A plugin is a npm module that can implement one or more of the following steps:
### Default plugins
These four plugins are already part of **semantic-release** and are listed in order of execution. They do not have to be installed separately:
```
"@semantic-release/commit-analyzer"
"@semantic-release/release-notes-generator"
@@ -64,12 +67,15 @@ For each [release step](../../README.md#release-steps) the plugins that implemen
```
With this configuration **semantic-release** will:
- execute the `verifyConditions` implementation of `@semantic-release/npm` then `@semantic-release/git`
- execute the `analyzeCommits` implementation of `@semantic-release/commit-analyzer`
- execute the `generateNotes` implementation of `@semantic-release/release-notes-generator`
- execute the `prepare` implementation of `@semantic-release/npm` then `@semantic-release/git`
- execute the `publish` implementation of `@semantic-release/npm`
Order is first determined by release steps (such as `verifyConditions``analyzeCommits`). At each release step, plugins are executed in the order in which they are defined.
## Plugin options configuration
A plugin configuration can be specified by wrapping the name and an options object in an array. Options configured this way will be passed only to that specific plugin.
@@ -81,9 +87,12 @@ Global plugin configuration can be defined at the root of the **semantic-release
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/github", {
"assets": ["dist/**"]
}],
[
"@semantic-release/github",
{
"assets": ["dist/**"]
}
],
"@semantic-release/git"
],
"preset": "angular"
@@ -91,5 +100,6 @@ Global plugin configuration can be defined at the root of the **semantic-release
```
With this configuration:
- All plugins will receive the `preset` option, which will be used by both `@semantic-release/commit-analyzer` and `@semantic-release/release-notes-generator` (and ignored by `@semantic-release/github` and `@semantic-release/git`)
- The `@semantic-release/github` plugin will receive the `assets` options (`@semantic-release/git` will not receive it and therefore will use it's default value for that option)
+38 -26
View File
@@ -1,19 +1,21 @@
# Workflow configuration
**semantic-release** allow to manage and automate complex release workflow, based on multiple Git branches and distribution channels. This allow to:
- Distributes certain releases to a particular group of users via distribution channels
- Distribute certain releases to a particular group of users via distribution channels
- Manage the availability of releases on distribution channels via branches merge
- Maintain multiple lines of releases in parallel
- Work on large future releases outside the normal flow of one version increment per Git push
See [Release workflow recipes](../recipes/README.md#release-workflow) for detailed examples.
See [Release workflow recipes](../recipes/release-workflow/README.md#release-workflow) for detailed examples.
The release workflow is configured via the [branches option](./configuration.md#branches) which accepts a single or an array of branch definitions.
Each branch can be defined either as a string, a [glob](https://github.com/micromatch/micromatch#matching-features) or an object. For string and glob definitions each [property](#branches-properties) will be defaulted.
A branch can defined as one of three types:
A branch can be defined as one of three types:
- [release](#release-branches): to make releases on top of the last version released
- [maintenance](#maintenance-branches): to make release on top of an old release
- [maintenance](#maintenance-branches): to make releases on top of an old release
- [pre-release](#pre-release-branches): to make pre-releases
The type of the branch is automatically determined based on naming convention and/or [properties](#branches-properties).
@@ -21,11 +23,11 @@ The type of the branch is automatically determined based on naming convention an
## Branches properties
| Property | Branch type | Description | Default |
|--------------|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| ------------ | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `name` | All | **Required.** The Git branch holding the commits to analyze and the code to release. See [name](#name). | - The value itself if defined as a `String` or the matching branches name if defined as a glob. |
| `channel` | All | The distribution channel on which to publish releases from this branch. Set to `false` to force the default distribution channel instead of using the default. See [channel](#channel). | `undefined` for the first release branch, the value of `name` for subsequent ones. |
| `range` | [maintenance](#maintenance-branches) only | **Required unless `name` is formatted like `N.N.x` or `N.x` (`N` is a number).** The range of [semantic versions](https://semver.org) to support on this branch. See [range](#range). | The value of `name`. |
| `prerelease` | [pre-release](#pre-release-branches) only | **Required.** The pre-release detonation to append to [semantic versions](https://semver.org) released from this branch. See [prerelease](#prerelease). | - |
| `prerelease` | [pre-release](#pre-release-branches) only | **Required.** The pre-release denotation to append to [semantic versions](https://semver.org) released from this branch. See [prerelease](#prerelease). | - |
### name
@@ -35,14 +37,15 @@ It can be defined as a [glob](https://github.com/micromatch/micromatch#matching-
If `name` doesn't match to any branch existing in the repository, the definition will be ignored. For example the default configuration includes the definition `next` and `next-major` which will become active only when the branches `next` and/or `next-major` are created in the repository. This allow to define your workflow once with all potential branches you might use and have the effective configuration evolving as you create new branches.
For example the configuration `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next']` will be expanded as:
```js
{
branches: [
{name: '1.x', range: '1.x', channel: '1.x'}, // Only after the `1.x` is created in the repo
{name: '2.x', range: '2.x', channel: '2.x'}, // Only after the `2.x` is created in the repo
{name: 'master'},
{name: 'next', channel: 'next'}, // Only after the `next` is created in the repo
]
{ name: "1.x", range: "1.x", channel: "1.x" }, // Only after the `1.x` is created in the repo
{ name: "2.x", range: "2.x", channel: "2.x" }, // Only after the `2.x` is created in the repo
{ name: "master" },
{ name: "next", channel: "next" }, // Only after the `next` is created in the repo
];
}
```
@@ -54,12 +57,13 @@ If the `channel` property is set to `false` the default channel will be used.
The value of `channel`, if defined as a string, is generated with [Lodash template](https://lodash.com/docs#template) with the variable `name` available.
For example the configuration `['master', {name: 'next', channel: 'channel-${name}'}]` will be expanded as:
```js
{
branches: [
{name: 'master'}, // `channel` is undefined so the default distribution channel will be used
{name: 'next', channel: 'channel-next'}, // `channel` is built with the template `channel-${name}`
]
{ name: "master" }, // `channel` is undefined so the default distribution channel will be used
{ name: "next", channel: "channel-next" }, // `channel` is built with the template `channel-${name}`
];
}
```
@@ -68,13 +72,14 @@ For example the configuration `['master', {name: 'next', channel: 'channel-${nam
A `range` only applies to maintenance branches, is required and must be formatted like `N.N.x` or `N.x` (`N` is a number). In case the `name` is formatted as a range (for example `1.x` or `1.5.x`) the branch will be considered a maintenance branch and the `name` value will be used for the `range`.
For example the configuration `['1.1.x', '1.2.x', 'master']` will be expanded as:
```js
{
branches: [
{name: '1.1.x', range: '1.1.x', channel: '1.1.x'},
{name: '1.2.x', range: '1.2.x', channel: '1.2.x'},
{name: 'master'},
]
{ name: "1.1.x", range: "1.1.x", channel: "1.1.x" },
{ name: "1.2.x", range: "1.2.x", channel: "1.2.x" },
{ name: "master" },
];
}
```
@@ -86,13 +91,14 @@ If the `prerelease` property is set to `true` the `name` value will be used.
The value of `prerelease`, if defined as a string, is generated with [Lodash template](https://lodash.com/docs#template) with the variable `name` available.
For example the configuration `['master', {name: 'pre/rc', prerelease: '${name.replace(/^pre\\//g, "")}'}, {name: 'beta', prerelease: true}]` will be expanded as:
```js
{
branches: [
{name: 'master'},
{name: 'pre/rc', channel: 'pre/rc', prerelease: 'rc'}, // `prerelease` is built with the template `${name.replace(/^pre\\//g, "")}`
{name: 'beta', channel: 'beta', prerelease: 'beta'}, // `prerelease` is set to `beta` as it is the value of `name`
]
{ name: "master" },
{ name: "pre/rc", channel: "pre/rc", prerelease: "rc" }, // `prerelease` is built with the template `${name.replace(/^pre\\//g, "")}`
{ name: "beta", channel: "beta", prerelease: true }, // `prerelease` is set to `beta` as it is the value of `name`
];
}
```
@@ -108,15 +114,17 @@ A project must define a minimum of 1 release branch and can have a maximum of 3.
**Note:** With **semantic-release** as with most package managers, a release version must be unique, independently of the distribution channel on which it is available.
See [publishing on distribution channels recipe](../recipes/distribution-channels.md) for a detailed example.
See [publishing on distribution channels recipe](../recipes/release-workflow/distribution-channels.md) for a detailed example.
#### Pushing to a release branch
With the configuration `"branches": ["master", "next"]`, if the last release published from `master` is `1.0.0` and the last one from `next` is `2.0.0` then:
- Only versions in range `1.x.x` can be published from `master`, so only `fix` and `feat` commits can be pushed to `master`
- Once `next` get merged into `master` the release `2.0.0` will be made available on the channel associated with `master` and both `master` and `next` will accept any commit type
This verification prevent scenario such as:
1. Create a `feat` commit on `next` which triggers the release of version `1.0.0` on the `next` channel
2. Merge `next` into `master` which adds `1.0.0` on the default channel
3. Create a `feat` commit on `next` which triggers the release of version `1.1.0` on the `next` channel
@@ -142,11 +150,12 @@ Maintenance branches are always considered lower than [release branches](#releas
**semantic-release** will automatically add releases to the corresponding distribution channel when code is [merged from a release or maintenance branch to another maintenance branch](#merging-into-a-maintenance-branch), however only versions within the branch `range` can be merged. If a merged version is outside the maintenance branch `range`, **semantic-release** will not add to the corresponding channel and will throw an `EINVALIDMAINTENANCEMERGE` error.
See [publishing maintenance releases recipe](../recipes/maintenance-releases.md) for a detailed example.
See [publishing maintenance releases recipe](../recipes/release-workflow/maintenance-releases.md) for a detailed example.
#### Pushing to a maintenance branch
With the configuration `"branches": ["1.0.x", "1.x", "master"]`, if the last release published from `master` is `1.5.0` then:
- Only versions in range `>=1.0.0 <1.1.0` can be published from `1.0.x`, so only `fix` commits can be pushed to `1.0.x`
- Only versions in range `>=1.1.0 <1.5.0` can be published from `1.x`, so only `fix` and `feat` commits can be pushed to `1.x` as long the resulting release is lower than `1.5.0`
- Once `2.0.0` is released from `master`, versions in range `>=1.1.0 <2.0.0` can be published from `1.x`, so any number of `fix` and `feat` commits can be pushed to `1.x`
@@ -154,6 +163,7 @@ With the configuration `"branches": ["1.0.x", "1.x", "master"]`, if the last rel
#### Merging into a maintenance branch
With the configuration `"branches": ["1.0.x", "1.x", "master"]`, if the last release published from `master` is `1.0.0` then:
- Creating the branch `1.0.x` from `master` will make the `1.0.0` release available on the `1.0.x` distribution channel
- Pushing a `fix` commit on the `1.0.x` branch will release the version `1.0.1` on the `1.0.x` distribution channel
- Creating the branch `1.x` from `master` will make the `1.0.0` release available on the `1.x` distribution channel
@@ -162,7 +172,7 @@ With the configuration `"branches": ["1.0.x", "1.x", "master"]`, if the last rel
### Pre-release branches
A pre-release branch is a type of branch used by **semantic-release** that allows to publish releases with a [pre-release version](https://semver.org/#spec-item-9).
Using a pre-release version allow to publish multiple releases with the same version. Those release will be differentiated via there identifiers (in `1.0.0-alpha.1` the identifier is `alpha.1`).
Using a pre-release version allow to publish multiple releases with the same version. Those release will be differentiated via their identifiers (in `1.0.0-alpha.1` the identifier is `alpha.1`).
This is useful when you need to work on a future major release that will include many breaking changes but you do not want to increment the version number for each breaking change commit.
A pre-release branch is characterized by the `prerelease` property that defines the static part of the version released (in `1.0.0-alpha.1` the static part fo the identifier is `alpha`). The [`prerelease`](#prerelease) value of each pre-release branch must be unique across the project.
@@ -171,16 +181,18 @@ A pre-release branch is characterized by the `prerelease` property that defines
When merging commits associated with an existing release, **semantic-release** will treat them as [pushed commits](#pushing-to-a-pre-release-branch) and publish a new release if necessary, but it will never add those releases to the distribution channel corresponding to the pre-release branch.
See [publishing pre-releases recipe](../recipes/pre-releases.md) for a detailed example.
See [publishing pre-releases recipe](../recipes/release-workflow/pre-releases.md) for a detailed example.
#### Pushing to a pre-release branch
With the configuration `"branches": ["master", {"name": "beta", "prerelease": true}]`, if the last release published from `master` is `1.0.0` then:
- Pushing a `BREAKING CHANGE` commit on the `beta` branch will release the version `2.0.0-beta.1` on the `beta` distribution channel
- Pushing either a `fix`, `feat` or a `BREAKING CHANGE` commit on the `beta` branch will release the version `2.0.0-beta.2` (then `2.0.0-beta.3`, `2.0.0-beta.4`, etc...) on the `beta` distribution channel
#### Merging into a pre-release branch
With the configuration `"branches": ["master", {"name": "beta", "prerelease": true}]`, if the last release published from `master` is `1.0.0` and the last one published from `beta` is `2.0.0-beta.1` then:
- Pushing a `fix` commit on the `master` branch will release the version `1.0.1` on the default distribution channel
- Merging the branch `master` into `beta` will release the version `2.0.0-beta.2` on the `beta` distribution channel
+91 -76
View File
@@ -1,46 +1,57 @@
const {pick} = require('lodash');
const marked = require('marked');
const TerminalRenderer = require('marked-terminal');
const envCi = require('env-ci');
const hookStd = require('hook-std');
const semver = require('semver');
const AggregateError = require('aggregate-error');
const pkg = require('./package.json');
const hideSensitive = require('./lib/hide-sensitive');
const getConfig = require('./lib/get-config');
const verify = require('./lib/verify');
const getNextVersion = require('./lib/get-next-version');
const getCommits = require('./lib/get-commits');
const getLastRelease = require('./lib/get-last-release');
const getReleaseToAdd = require('./lib/get-release-to-add');
const {extractErrors, makeTag} = require('./lib/utils');
const getGitAuthUrl = require('./lib/get-git-auth-url');
const getBranches = require('./lib/branches');
const getLogger = require('./lib/get-logger');
const {verifyAuth, isBranchUpToDate, getGitHead, tag, push, pushNotes, getTagHead, addNote} = require('./lib/git');
const getError = require('./lib/get-error');
const {COMMIT_NAME, COMMIT_EMAIL} = require('./lib/definitions/constants');
import { createRequire } from "node:module";
import { pick } from "lodash-es";
import * as marked from "marked";
import envCi from "env-ci";
import { hookStd } from "hook-std";
import semver from "semver";
import AggregateError from "aggregate-error";
import hideSensitive from "./lib/hide-sensitive.js";
import getConfig from "./lib/get-config.js";
import verify from "./lib/verify.js";
import getNextVersion from "./lib/get-next-version.js";
import getCommits from "./lib/get-commits.js";
import getLastRelease from "./lib/get-last-release.js";
import getReleaseToAdd from "./lib/get-release-to-add.js";
import { extractErrors, makeTag } from "./lib/utils.js";
import getGitAuthUrl from "./lib/get-git-auth-url.js";
import getBranches from "./lib/branches/index.js";
import getLogger from "./lib/get-logger.js";
import { addNote, getGitHead, getTagHead, isBranchUpToDate, push, pushNotes, tag, verifyAuth } from "./lib/git.js";
import getError from "./lib/get-error.js";
import { COMMIT_EMAIL, COMMIT_NAME } from "./lib/definitions/constants.js";
marked.setOptions({renderer: new TerminalRenderer()});
const require = createRequire(import.meta.url);
const pkg = require("./package.json");
let markedOptionsSet = false;
async function terminalOutput(text) {
if (!markedOptionsSet) {
const { default: TerminalRenderer } = await import("marked-terminal"); // eslint-disable-line node/no-unsupported-features/es-syntax
marked.setOptions({ renderer: new TerminalRenderer() });
markedOptionsSet = true;
}
return marked.parse(text);
}
/* eslint complexity: off */
async function run(context, plugins) {
const {cwd, env, options, logger} = context;
const {isCi, branch, prBranch, isPr} = context.envCi;
const { cwd, env, options, logger, envCi } = context;
const { isCi, branch, prBranch, isPr } = envCi;
const ciBranch = isPr ? prBranch : branch;
if (!isCi && !options.dryRun && !options.noCi) {
logger.warn('This run was not triggered in a known CI environment, running in dry-run mode.');
logger.warn("This run was not triggered in a known CI environment, running in dry-run mode.");
options.dryRun = true;
} else {
// When running on CI, set the commits author and commiter info and prevent the `git` CLI to prompt for username/password. See #703.
// When running on CI, set the commits author and committer info and prevent the `git` CLI to prompt for username/password. See #703.
Object.assign(env, {
GIT_AUTHOR_NAME: COMMIT_NAME,
GIT_AUTHOR_EMAIL: COMMIT_EMAIL,
GIT_COMMITTER_NAME: COMMIT_NAME,
GIT_COMMITTER_EMAIL: COMMIT_EMAIL,
...env,
GIT_ASKPASS: 'echo',
GIT_ASKPASS: "echo",
GIT_TERMINAL_PROMPT: 0,
});
}
@@ -53,30 +64,30 @@ async function run(context, plugins) {
// Verify config
await verify(context);
options.repositoryUrl = await getGitAuthUrl({...context, branch: {name: ciBranch}});
options.repositoryUrl = await getGitAuthUrl({ ...context, branch: { name: ciBranch } });
context.branches = await getBranches(options.repositoryUrl, ciBranch, context);
context.branch = context.branches.find(({name}) => name === ciBranch);
context.branch = context.branches.find(({ name }) => name === ciBranch);
if (!context.branch) {
logger.log(
`This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${context.branches
.map(({name}) => name)
.join(', ')}, therefore a new version wont be published.`
.map(({ name }) => name)
.join(", ")}, therefore a new version wont be published.`
);
return false;
}
logger[options.dryRun ? 'warn' : 'success'](
`Run automated release from branch ${ciBranch} on repository ${options.repositoryUrl}${
options.dryRun ? ' in dry-run mode' : ''
logger[options.dryRun ? "warn" : "success"](
`Run automated release from branch ${ciBranch} on repository ${options.originalRepositoryURL}${
options.dryRun ? " in dry-run mode" : ""
}`
);
try {
try {
await verifyAuth(options.repositoryUrl, context.branch.name, {cwd, env});
await verifyAuth(options.repositoryUrl, context.branch.name, { cwd, env });
} catch (error) {
if (!(await isBranchUpToDate(options.repositoryUrl, context.branch.name, {cwd, env}))) {
if (!(await isBranchUpToDate(options.repositoryUrl, context.branch.name, { cwd, env }))) {
logger.log(
`The local branch ${context.branch.name} is behind the remote one, therefore a new version won't be published.`
);
@@ -87,7 +98,7 @@ async function run(context, plugins) {
}
} catch (error) {
logger.error(`The command "${error.command}" failed with the error message ${error.stderr}.`);
throw getError('EGITNOPERMISSION', context);
throw getError("EGITNOPERMISSION", context);
}
logger.success(`Allowed to push to the Git repository`);
@@ -99,24 +110,27 @@ async function run(context, plugins) {
const releaseToAdd = getReleaseToAdd(context);
if (releaseToAdd) {
const {lastRelease, currentRelease, nextRelease} = releaseToAdd;
const { lastRelease, currentRelease, nextRelease } = releaseToAdd;
nextRelease.gitHead = await getTagHead(nextRelease.gitHead, {cwd, env});
currentRelease.gitHead = await getTagHead(currentRelease.gitHead, {cwd, env});
nextRelease.gitHead = await getTagHead(nextRelease.gitHead, { cwd, env });
currentRelease.gitHead = await getTagHead(currentRelease.gitHead, { cwd, env });
if (context.branch.mergeRange && !semver.satisfies(nextRelease.version, context.branch.mergeRange)) {
errors.push(getError('EINVALIDMAINTENANCEMERGE', {...context, nextRelease}));
errors.push(getError("EINVALIDMAINTENANCEMERGE", { ...context, nextRelease }));
} else {
const commits = await getCommits({...context, lastRelease, nextRelease});
nextRelease.notes = await plugins.generateNotes({...context, commits, lastRelease, nextRelease});
const commits = await getCommits({ ...context, lastRelease, nextRelease });
nextRelease.notes = await plugins.generateNotes({ ...context, commits, lastRelease, nextRelease });
if (options.dryRun) {
logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`);
} else {
await addNote({channels: [...currentRelease.channels, nextRelease.channel]}, nextRelease.gitHead, {cwd, env});
await push(options.repositoryUrl, {cwd, env});
await pushNotes(options.repositoryUrl, {cwd, env});
await addNote({ channels: [...currentRelease.channels, nextRelease.channel] }, nextRelease.gitHead, {
cwd,
env,
});
await push(options.repositoryUrl, { cwd, env });
await pushNotes(options.repositoryUrl, { cwd, env });
logger.success(
`Add ${nextRelease.channel ? `channel ${nextRelease.channel}` : 'default channel'} to tag ${
`Add ${nextRelease.channel ? `channel ${nextRelease.channel}` : "default channel"} to tag ${
nextRelease.gitTag
}`
);
@@ -129,9 +143,9 @@ async function run(context, plugins) {
gitHead: nextRelease.gitHead,
});
const releases = await plugins.addChannel({...context, commits, lastRelease, currentRelease, nextRelease});
const releases = await plugins.addChannel({ ...context, commits, lastRelease, currentRelease, nextRelease });
context.releases.push(...releases);
await plugins.success({...context, lastRelease, commits, nextRelease, releases});
await plugins.success({ ...context, lastRelease, commits, nextRelease, releases });
}
}
@@ -141,7 +155,7 @@ async function run(context, plugins) {
context.lastRelease = getLastRelease(context);
if (context.lastRelease.gitHead) {
context.lastRelease.gitHead = await getTagHead(context.lastRelease.gitHead, {cwd, env});
context.lastRelease.gitHead = await getTagHead(context.lastRelease.gitHead, { cwd, env });
}
if (context.lastRelease.gitTag) {
@@ -157,11 +171,11 @@ async function run(context, plugins) {
const nextRelease = {
type: await plugins.analyzeCommits(context),
channel: context.branch.channel || null,
gitHead: await getGitHead({cwd, env}),
gitHead: await getGitHead({ cwd, env }),
};
if (!nextRelease.type) {
logger.log('There are no relevant changes, so no new version is released.');
return context.releases.length > 0 ? {releases: context.releases} : false;
logger.log("There are no relevant changes, so no new version is released.");
return context.releases.length > 0 ? { releases: context.releases } : false;
}
context.nextRelease = nextRelease;
@@ -169,11 +183,11 @@ async function run(context, plugins) {
nextRelease.gitTag = makeTag(options.tagFormat, nextRelease.version);
nextRelease.name = nextRelease.gitTag;
if (context.branch.type !== 'prerelease' && !semver.satisfies(nextRelease.version, context.branch.range)) {
throw getError('EINVALIDNEXTVERSION', {
if (context.branch.type !== "prerelease" && !semver.satisfies(nextRelease.version, context.branch.range)) {
throw getError("EINVALIDNEXTVERSION", {
...context,
validBranches: context.branches.filter(
({type, accept}) => type !== 'prerelease' && accept.includes(nextRelease.type)
({ type, accept }) => type !== "prerelease" && accept.includes(nextRelease.type)
),
});
}
@@ -188,42 +202,42 @@ async function run(context, plugins) {
logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`);
} else {
// Create the tag before calling the publish plugins as some require the tag to exists
await tag(nextRelease.gitTag, nextRelease.gitHead, {cwd, env});
await addNote({channels: [nextRelease.channel]}, nextRelease.gitHead, {cwd, env});
await push(options.repositoryUrl, {cwd, env});
await pushNotes(options.repositoryUrl, {cwd, env});
await tag(nextRelease.gitTag, nextRelease.gitHead, { cwd, env });
await addNote({ channels: [nextRelease.channel] }, nextRelease.gitHead, { cwd, env });
await push(options.repositoryUrl, { cwd, env });
await pushNotes(options.repositoryUrl, { cwd, env });
logger.success(`Created tag ${nextRelease.gitTag}`);
}
const releases = await plugins.publish(context);
context.releases.push(...releases);
await plugins.success({...context, releases});
await plugins.success({ ...context, releases });
logger.success(
`Published release ${nextRelease.version} on ${nextRelease.channel ? nextRelease.channel : 'default'} channel`
`Published release ${nextRelease.version} on ${nextRelease.channel ? nextRelease.channel : "default"} channel`
);
if (options.dryRun) {
logger.log(`Release note for version ${nextRelease.version}:`);
if (nextRelease.notes) {
context.stdout.write(marked(nextRelease.notes));
context.stdout.write(await terminalOutput(nextRelease.notes));
}
}
return pick(context, ['lastRelease', 'commits', 'nextRelease', 'releases']);
return pick(context, ["lastRelease", "commits", "nextRelease", "releases"]);
}
function logErrors({logger, stderr}, err) {
async function logErrors({ logger, stderr }, err) {
const errors = extractErrors(err).sort((error) => (error.semanticRelease ? -1 : 0));
for (const error of errors) {
if (error.semanticRelease) {
logger.error(`${error.code} ${error.message}`);
if (error.details) {
stderr.write(marked(error.details));
stderr.write(await terminalOutput(error.details)); // eslint-disable-line no-await-in-loop
}
} else {
logger.error('An error occurred while running semantic-release: %O', error);
logger.error("An error occurred while running semantic-release: %O", error);
}
}
}
@@ -232,16 +246,16 @@ async function callFail(context, plugins, err) {
const errors = extractErrors(err).filter((err) => err.semanticRelease);
if (errors.length > 0) {
try {
await plugins.fail({...context, errors});
await plugins.fail({ ...context, errors });
} catch (error) {
logErrors(context, error);
await logErrors(context, error);
}
}
}
module.exports = async (cliOptions = {}, {cwd = process.cwd(), env = process.env, stdout, stderr} = {}) => {
const {unhook} = hookStd(
{silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean)},
export default async (cliOptions = {}, { cwd = process.cwd(), env = process.env, stdout, stderr } = {}) => {
const { unhook } = hookStd(
{ silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean) },
hideSensitive(env)
);
const context = {
@@ -249,12 +263,13 @@ module.exports = async (cliOptions = {}, {cwd = process.cwd(), env = process.env
env,
stdout: stdout || process.stdout,
stderr: stderr || process.stderr,
envCi: envCi({env, cwd}),
envCi: envCi({ env, cwd }),
};
context.logger = getLogger(context);
context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
try {
const {plugins, options} = await getConfig(context, cliOptions);
const { plugins, options } = await getConfig(context, cliOptions);
options.originalRepositoryURL = options.repositoryUrl;
context.options = options;
try {
const result = await run(context, plugins);
@@ -265,7 +280,7 @@ module.exports = async (cliOptions = {}, {cwd = process.cwd(), env = process.env
throw error;
}
} catch (error) {
logErrors(context, error);
await logErrors(context, error);
unhook();
throw error;
}
+6 -6
View File
@@ -1,16 +1,16 @@
const {isString, remove, omit, mapValues, template} = require('lodash');
const micromatch = require('micromatch');
const {getBranches} = require('../git');
import { isString, mapValues, omit, remove, template } from "lodash-es";
import micromatch from "micromatch";
import { getBranches } from "../git.js";
module.exports = async (repositoryUrl, {cwd}, branches) => {
const gitBranches = await getBranches(repositoryUrl, {cwd});
export default async (repositoryUrl, { cwd }, branches) => {
const gitBranches = await getBranches(repositoryUrl, { cwd });
return branches.reduce(
(branches, branch) => [
...branches,
...remove(gitBranches, (name) => micromatch(gitBranches, branch.name).includes(name)).map((name) => ({
name,
...mapValues(omit(branch, 'name'), (value) => (isString(value) ? template(value)({name}) : value)),
...mapValues(omit(branch, "name"), (value) => (isString(value) ? template(value)({ name }) : value)),
})),
],
[]
+13 -11
View File
@@ -1,32 +1,34 @@
const {template, escapeRegExp} = require('lodash');
const semver = require('semver');
const pReduce = require('p-reduce');
const debug = require('debug')('semantic-release:get-tags');
const {getTags, getNote} = require('../../lib/git');
import { escapeRegExp, template } from "lodash-es";
import semver from "semver";
import pReduce from "p-reduce";
import debugTags from "debug";
import { getNote, getTags } from "../../lib/git.js";
module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
const debug = debugTags("semantic-release:get-tags");
export default async ({ cwd, env, options: { tagFormat } }, branches) => {
// Generate a regex to parse tags formatted with `tagFormat`
// by replacing the `version` variable in the template by `(.+)`.
// The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
// so it's guaranteed to no be present in the `tagFormat`.
const tagRegexp = `^${escapeRegExp(template(tagFormat)({version: ' '})).replace(' ', '(.+)')}`;
const tagRegexp = `^${escapeRegExp(template(tagFormat)({ version: " " })).replace(" ", "(.+)")}`;
return pReduce(
branches,
async (branches, branch) => {
const branchTags = await pReduce(
await getTags(branch.name, {cwd, env}),
await getTags(branch.name, { cwd, env }),
async (branchTags, tag) => {
const [, version] = tag.match(tagRegexp) || [];
return version && semver.valid(semver.clean(version))
? [...branchTags, {gitTag: tag, version, channels: (await getNote(tag, {cwd, env})).channels || [null]}]
? [...branchTags, { gitTag: tag, version, channels: (await getNote(tag, { cwd, env })).channels || [null] }]
: branchTags;
},
[]
);
debug('found tags for branch %s: %o', branch.name, branchTags);
return [...branches, {...branch, tags: branchTags}];
debug("found tags for branch %s: %o", branch.name, branchTags);
return [...branches, { ...branch, tags: branchTags }];
},
[]
);
+23 -22
View File
@@ -1,50 +1,51 @@
const {isString, isRegExp} = require('lodash');
const AggregateError = require('aggregate-error');
const pEachSeries = require('p-each-series');
const DEFINITIONS = require('../definitions/branches');
const getError = require('../get-error');
const {fetch, fetchNotes, verifyBranchName} = require('../git');
const expand = require('./expand');
const getTags = require('./get-tags');
const normalize = require('./normalize');
import { isRegExp, isString } from "lodash-es";
import AggregateError from "aggregate-error";
import pEachSeries from "p-each-series";
import * as DEFINITIONS from "../definitions/branches.js";
import getError from "../get-error.js";
import { fetch, fetchNotes, verifyBranchName } from "../git.js";
import expand from "./expand.js";
import getTags from "./get-tags.js";
import * as normalize from "./normalize.js";
module.exports = async (repositoryUrl, ciBranch, context) => {
const {cwd, env} = context;
export default async (repositoryUrl, ciBranch, context) => {
const { cwd, env } = context;
const remoteBranches = await expand(
repositoryUrl,
context,
context.options.branches.map((branch) => (isString(branch) || isRegExp(branch) ? {name: branch} : branch))
context.options.branches.map((branch) => (isString(branch) || isRegExp(branch) ? { name: branch } : branch))
);
await pEachSeries(remoteBranches, async ({name}) => {
await fetch(repositoryUrl, name, ciBranch, {cwd, env});
await pEachSeries(remoteBranches, async ({ name }) => {
await fetch(repositoryUrl, name, ciBranch, { cwd, env });
});
await fetchNotes(repositoryUrl, {cwd, env});
await fetchNotes(repositoryUrl, { cwd, env });
const branches = await getTags(context, remoteBranches);
const errors = [];
const branchesByType = Object.entries(DEFINITIONS).reduce(
(branchesByType, [type, {filter}]) => ({[type]: branches.filter(filter), ...branchesByType}),
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
(branchesByType, [type, { filter }]) => ({ [type]: branches.filter(filter), ...branchesByType }),
{}
);
const result = Object.entries(DEFINITIONS).reduce((result, [type, {branchesValidator, branchValidator}]) => {
const result = Object.entries(DEFINITIONS).reduce((result, [type, { branchesValidator, branchValidator }]) => {
branchesByType[type].forEach((branch) => {
if (branchValidator && !branchValidator(branch)) {
errors.push(getError(`E${type.toUpperCase()}BRANCH`, {branch}));
errors.push(getError(`E${type.toUpperCase()}BRANCH`, { branch }));
}
});
const branchesOfType = normalize[type](branchesByType);
if (!branchesValidator(branchesOfType)) {
errors.push(getError(`E${type.toUpperCase()}BRANCHES`, {branches: branchesOfType}));
errors.push(getError(`E${type.toUpperCase()}BRANCHES`, { branches: branchesOfType }));
}
return {...result, [type]: branchesOfType};
return { ...result, [type]: branchesOfType };
}, {});
const duplicates = [...branches]
@@ -53,12 +54,12 @@ module.exports = async (repositoryUrl, ciBranch, context) => {
.filter((_, idx, array) => array[idx] === array[idx + 1] && array[idx] !== array[idx - 1]);
if (duplicates.length > 0) {
errors.push(getError('EDUPLICATEBRANCHES', {duplicates}));
errors.push(getError("EDUPLICATEBRANCHES", { duplicates }));
}
await pEachSeries(branches, async (branch) => {
if (!(await verifyBranchName(branch.name))) {
errors.push(getError('EINVALIDBRANCHNAME', branch));
errors.push(getError("EINVALIDBRANCHNAME", branch));
}
});
+23 -25
View File
@@ -1,28 +1,28 @@
const {sortBy, isNil} = require('lodash');
const semverDiff = require('semver-diff');
const {FIRST_RELEASE, RELEASE_TYPE} = require('../definitions/constants');
const {
tagsToVersions,
isMajorRange,
getUpperBound,
getLowerBound,
highest,
lowest,
getLatestVersion,
import { isNil, sortBy } from "lodash-es";
import semverDiff from "semver-diff";
import { FIRST_RELEASE, RELEASE_TYPE } from "../definitions/constants.js";
import {
getFirstVersion,
getLatestVersion,
getLowerBound,
getRange,
} = require('../utils');
getUpperBound,
highest,
isMajorRange,
lowest,
tagsToVersions,
} from "../utils.js";
function maintenance({maintenance, release}) {
export function maintenance({ maintenance, release }) {
return sortBy(
maintenance.map(({name, range, channel, ...rest}) => ({
maintenance.map(({ name, range, channel, ...rest }) => ({
...rest,
name,
range: range || name,
channel: isNil(channel) ? name : channel,
})),
'range'
).map(({name, range, tags, ...rest}, idx, branches) => {
"range"
).map(({ name, range, tags, ...rest }, idx, branches) => {
const versions = tagsToVersions(tags);
// Find the lower bound based on Maintenance branches
const maintenanceMin =
@@ -45,7 +45,7 @@ function maintenance({maintenance, release}) {
const diff = semverDiff(min, max);
return {
...rest,
type: 'maintenance',
type: "maintenance",
name,
tags,
range: getRange(min, max),
@@ -55,7 +55,7 @@ function maintenance({maintenance, release}) {
});
}
function release({release}) {
export function release({ release }) {
if (release.length === 0) {
return release;
}
@@ -63,7 +63,7 @@ function release({release}) {
// The intial lastVersion is the last release from the base branch of `FIRST_RELEASE` (1.0.0)
let lastVersion = getLatestVersion(tagsToVersions(release[0].tags)) || FIRST_RELEASE;
return release.map(({name, tags, channel, ...rest}, idx) => {
return release.map(({ name, tags, channel, ...rest }, idx) => {
const versions = tagsToVersions(tags);
// The new lastVersion is the highest version between the current branch last release and the previous branch lastVersion
lastVersion = highest(getLatestVersion(versions), lastVersion);
@@ -80,7 +80,7 @@ function release({release}) {
...rest,
channel: idx === 0 ? channel : isNil(channel) ? name : channel,
tags,
type: 'release',
type: "release",
name,
range: getRange(lastVersion, bound),
accept: bound ? RELEASE_TYPE.slice(0, RELEASE_TYPE.indexOf(diff)) : RELEASE_TYPE,
@@ -89,18 +89,16 @@ function release({release}) {
});
}
function prerelease({prerelease}) {
return prerelease.map(({name, prerelease, channel, tags, ...rest}) => {
export function prerelease({ prerelease }) {
return prerelease.map(({ name, prerelease, channel, tags, ...rest }) => {
const preid = prerelease === true ? name : prerelease;
return {
...rest,
channel: isNil(channel) ? name : channel,
type: 'prerelease',
type: "prerelease",
name,
prerelease: preid,
tags,
};
});
}
module.exports = {maintenance, release, prerelease};
+13 -14
View File
@@ -1,23 +1,22 @@
const {isNil, uniqBy} = require('lodash');
const semver = require('semver');
const {isMaintenanceRange} = require('../utils');
import { isNil, uniqBy } from "lodash-es";
import semver from "semver";
import { isMaintenanceRange } from "../utils.js";
const maintenance = {
filter: ({name, range}) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
branchValidator: ({range}) => (isNil(range) ? true : isMaintenanceRange(range)),
branchesValidator: (branches) => uniqBy(branches, ({range}) => semver.validRange(range)).length === branches.length,
export const maintenance = {
filter: ({ name, range }) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
branchValidator: ({ range }) => (isNil(range) ? true : isMaintenanceRange(range)),
branchesValidator: (branches) => uniqBy(branches, ({ range }) => semver.validRange(range)).length === branches.length,
};
const prerelease = {
filter: ({prerelease}) => !isNil(prerelease) && prerelease !== false,
branchValidator: ({name, prerelease}) =>
export const prerelease = {
filter: ({ prerelease }) => !isNil(prerelease) && prerelease !== false,
branchValidator: ({ name, prerelease }) =>
Boolean(prerelease) && Boolean(semver.valid(`1.0.0-${prerelease === true ? name : prerelease}.1`)),
branchesValidator: (branches) => uniqBy(branches, 'prerelease').length === branches.length,
branchesValidator: (branches) => uniqBy(branches, "prerelease").length === branches.length,
};
const release = {
export const release = {
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
filter: (branch) => !maintenance.filter(branch) && !prerelease.filter(branch),
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
};
module.exports = {maintenance, prerelease, release};
+9 -21
View File
@@ -1,29 +1,17 @@
const RELEASE_TYPE = ['patch', 'minor', 'major'];
export const RELEASE_TYPE = ["patch", "minor", "major"];
const FIRST_RELEASE = '1.0.0';
export const FIRST_RELEASE = "1.0.0";
const FIRSTPRERELEASE = '1';
export const FIRSTPRERELEASE = "1";
const COMMIT_NAME = 'semantic-release-bot';
export const COMMIT_NAME = "semantic-release-bot";
const COMMIT_EMAIL = 'semantic-release-bot@martynus.net';
export const COMMIT_EMAIL = "semantic-release-bot@martynus.net";
const RELEASE_NOTES_SEPARATOR = '\n\n';
export const RELEASE_NOTES_SEPARATOR = "\n\n";
const SECRET_REPLACEMENT = '[secure]';
export const SECRET_REPLACEMENT = "[secure]";
const SECRET_MIN_SIZE = 5;
export const SECRET_MIN_SIZE = 5;
const GIT_NOTE_REF = 'semantic-release';
module.exports = {
RELEASE_TYPE,
FIRST_RELEASE,
FIRSTPRERELEASE,
COMMIT_NAME,
COMMIT_EMAIL,
RELEASE_NOTES_SEPARATOR,
SECRET_REPLACEMENT,
SECRET_MIN_SIZE,
GIT_NOTE_REF,
};
export const GIT_NOTE_REF = "semantic-release";
+171 -105
View File
@@ -1,92 +1,119 @@
const {inspect} = require('util');
const {toLower, isString, trim} = require('lodash');
const pkg = require('../../package.json');
const {RELEASE_TYPE} = require('./constants');
import { inspect } from "node:util";
import { createRequire } from "node:module";
import { isString, toLower, trim } from "lodash-es";
import { RELEASE_TYPE } from "./constants.js";
const [homepage] = pkg.homepage.split('#');
const require = createRequire(import.meta.url);
const pkg = require("../../package.json");
const [homepage] = pkg.homepage.split("#");
const stringify = (object) =>
isString(object) ? object : inspect(object, {breakLength: Infinity, depth: 2, maxArrayLength: 5});
isString(object) ? object : inspect(object, { breakLength: Infinity, depth: 2, maxArrayLength: 5 });
const linkify = (file) => `${homepage}/blob/master/${file}`;
const wordsList = (words) =>
`${words.slice(0, -1).join(', ')}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
`${words.slice(0, -1).join(", ")}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
module.exports = {
ENOGITREPO: ({cwd}) => ({
message: 'Not running from a git repository.',
export function ENOGITREPO({ cwd }) {
return {
message: "Not running from a git repository.",
details: `The \`semantic-release\` command must be executed from a Git repository.
The current working directory is \`${cwd}\`.
Please verify your CI configuration to make sure the \`semantic-release\` command is executed from the root of the cloned repository.`,
}),
ENOREPOURL: () => ({
message: 'The `repositoryUrl` option is required.',
};
}
export function ENOREPOURL() {
return {
message: "The `repositoryUrl` option is required.",
details: `The [repositoryUrl option](${linkify(
'docs/usage/configuration.md#repositoryurl'
"docs/usage/configuration.md#repositoryurl"
)}) cannot be determined from the semantic-release configuration, the \`package.json\` nor the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes).
Please make sure to add the \`repositoryUrl\` to the [semantic-release configuration] (${linkify(
'docs/usage/configuration.md'
"docs/usage/configuration.md"
)}).`,
}),
EGITNOPERMISSION: ({options: {repositoryUrl}, branch: {name}}) => ({
message: 'Cannot push to the Git repository.',
};
}
export function EGITNOPERMISSION({ options: { repositoryUrl }, branch: { name } }) {
return {
message: "Cannot push to the Git repository.",
details: `**semantic-release** cannot push the version tag to the branch \`${name}\` on the remote Git repository with URL \`${repositoryUrl}\`.
This can be caused by:
- a misconfiguration of the [repositoryUrl](${linkify('docs/usage/configuration.md#repositoryurl')}) option
- a misconfiguration of the [repositoryUrl](${linkify("docs/usage/configuration.md#repositoryurl")}) option
- the repository being unavailable
- or missing push permission for the user configured via the [Git credentials on your CI environment](${linkify(
'docs/usage/ci-configuration.md#authentication'
"docs/usage/ci-configuration.md#authentication"
)})`,
}),
EINVALIDTAGFORMAT: ({options: {tagFormat}}) => ({
message: 'Invalid `tagFormat` option.',
};
}
export function EINVALIDTAGFORMAT({ options: { tagFormat } }) {
return {
message: "Invalid `tagFormat` option.",
details: `The [tagFormat](${linkify(
'docs/usage/configuration.md#tagformat'
"docs/usage/configuration.md#tagformat"
)}) must compile to a [valid Git reference](https://git-scm.com/docs/git-check-ref-format#_description).
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
}),
ETAGNOVERSION: ({options: {tagFormat}}) => ({
message: 'Invalid `tagFormat` option.',
};
}
export function ETAGNOVERSION({ options: { tagFormat } }) {
return {
message: "Invalid `tagFormat` option.",
details: `The [tagFormat](${linkify(
'docs/usage/configuration.md#tagformat'
"docs/usage/configuration.md#tagformat"
)}) option must contain the variable \`version\` exactly once.
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
}),
EPLUGINCONF: ({type, required, pluginConf}) => ({
};
}
export function EPLUGINCONF({ type, required, pluginConf }) {
return {
message: `The \`${type}\` plugin configuration is invalid.`,
details: `The [${type} plugin configuration](${linkify(`docs/usage/plugins.md#${toLower(type)}-plugin`)}) ${
required ? 'is required and ' : ''
} must be a single or an array of plugins definition. A plugin definition is an npm module name, optionnaly wrapped in an array with an object.
required ? "is required and " : ""
} must be a single or an array of plugins definition. A plugin definition is an npm module name, optionally wrapped in an array with an object.
Your configuration for the \`${type}\` plugin is \`${stringify(pluginConf)}\`.`,
}),
EPLUGINSCONF: ({plugin}) => ({
message: 'The `plugins` configuration is invalid.',
};
}
export function EPLUGINSCONF({ plugin }) {
return {
message: "The `plugins` configuration is invalid.",
details: `The [plugins](${linkify(
'docs/usage/configuration.md#plugins'
)}) option must be an array of plugin definions. A plugin definition is an npm module name, optionnaly wrapped in an array with an object.
"docs/usage/configuration.md#plugins"
)}) option must be an array of plugin definitions. A plugin definition is an npm module name, optionally wrapped in an array with an object.
The invalid configuration is \`${stringify(plugin)}\`.`,
}),
EPLUGIN: ({pluginName, type}) => ({
};
}
export function EPLUGIN({ pluginName, type }) {
return {
message: `A plugin configured in the step ${type} is not a valid semantic-release plugin.`,
details: `A valid \`${type}\` **semantic-release** plugin must be a function or an object with a function in the property \`${type}\`.
The plugin \`${pluginName}\` doesn't have the property \`${type}\` and cannot be used for the \`${type}\` step.
Please refer to the \`${pluginName}\` and [semantic-release plugins configuration](${linkify(
'docs/usage/plugins.md'
"docs/usage/plugins.md"
)}) documentation for more details.`,
}),
EANALYZECOMMITSOUTPUT: ({result, pluginName}) => ({
message: 'The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.',
};
}
export function EANALYZECOMMITSOUTPUT({ result, pluginName }) {
return {
message: "The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.",
details: `The \`analyzeCommits\` plugin must return a valid [semver](https://semver.org) release type. The valid values are: ${RELEASE_TYPE.map(
(type) => `\`${type}\``
).join(', ')}.
).join(", ")}.
The \`analyzeCommits\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
@@ -94,12 +121,15 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
- The **semantic-release** version: \`${pkg.version}\`
- The **semantic-release** logs from your CI job
- The value returned by the plugin: \`${stringify(result)}\`
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
'docs/developer-guide/plugin.md'
- A link to the **semantic-release** plugin developer guide: [${linkify("docs/developer-guide/plugin.md")}](${linkify(
"docs/developer-guide/plugin.md"
)})`,
}),
EGENERATENOTESOUTPUT: ({result, pluginName}) => ({
message: 'The `generateNotes` plugin returned an invalid value. It must return a `String`.',
};
}
export function EGENERATENOTESOUTPUT({ result, pluginName }) {
return {
message: "The `generateNotes` plugin returned an invalid value. It must return a `String`.",
details: `The \`generateNotes\` plugin must return a \`String\`.
The \`generateNotes\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
@@ -108,12 +138,15 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
- The **semantic-release** version: \`${pkg.version}\`
- The **semantic-release** logs from your CI job
- The value returned by the plugin: \`${stringify(result)}\`
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
'docs/developer-guide/plugin.md'
- A link to the **semantic-release** plugin developer guide: [${linkify("docs/developer-guide/plugin.md")}](${linkify(
"docs/developer-guide/plugin.md"
)})`,
}),
EPUBLISHOUTPUT: ({result, pluginName}) => ({
message: 'A `publish` plugin returned an invalid value. It must return an `Object`.',
};
}
export function EPUBLISHOUTPUT({ result, pluginName }) {
return {
message: "A `publish` plugin returned an invalid value. It must return an `Object`.",
details: `The \`publish\` plugins must return an \`Object\`.
The \`publish\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
@@ -122,12 +155,15 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
- The **semantic-release** version: \`${pkg.version}\`
- The **semantic-release** logs from your CI job
- The value returned by the plugin: \`${stringify(result)}\`
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
'docs/developer-guide/plugin.md'
- A link to the **semantic-release** plugin developer guide: [${linkify("docs/developer-guide/plugin.md")}](${linkify(
"docs/developer-guide/plugin.md"
)})`,
}),
EADDCHANNELOUTPUT: ({result, pluginName}) => ({
message: 'A `addChannel` plugin returned an invalid value. It must return an `Object`.',
};
}
export function EADDCHANNELOUTPUT({ result, pluginName }) {
return {
message: "A `addChannel` plugin returned an invalid value. It must return an `Object`.",
details: `The \`addChannel\` plugins must return an \`Object\`.
The \`addChannel\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
@@ -136,97 +172,127 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
- The **semantic-release** version: \`${pkg.version}\`
- The **semantic-release** logs from your CI job
- The value returned by the plugin: \`${stringify(result)}\`
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
'docs/developer-guide/plugin.md'
- A link to the **semantic-release** plugin developer guide: [${linkify("docs/developer-guide/plugin.md")}](${linkify(
"docs/developer-guide/plugin.md"
)})`,
}),
EINVALIDBRANCH: ({branch}) => ({
message: 'A branch is invalid in the `branches` configuration.',
};
}
export function EINVALIDBRANCH({ branch }) {
return {
message: "A branch is invalid in the `branches` configuration.",
details: `Each branch in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}) must be either a string, a regexp or an object with a \`name\` property.
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
}),
EINVALIDBRANCHNAME: ({branch}) => ({
message: 'A branch name is invalid in the `branches` configuration.',
};
}
export function EINVALIDBRANCHNAME({ branch }) {
return {
message: "A branch name is invalid in the `branches` configuration.",
details: `Each branch in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}) must be a [valid Git reference](https://git-scm.com/docs/git-check-ref-format#_description).
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
}),
EDUPLICATEBRANCHES: ({duplicates}) => ({
message: 'The `branches` configuration has duplicate branches.',
};
}
export function EDUPLICATEBRANCHES({ duplicates }) {
return {
message: "The `branches` configuration has duplicate branches.",
details: `Each branch in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}) must havea unique name.
Your configuration contains duplicates for the following branch names: \`${stringify(duplicates)}\`.`,
}),
EMAINTENANCEBRANCH: ({branch}) => ({
message: 'A maintenance branch is invalid in the `branches` configuration.',
};
}
export function EMAINTENANCEBRANCH({ branch }) {
return {
message: "A maintenance branch is invalid in the `branches` configuration.",
details: `Each maintenance branch in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}) must have a \`range\` property formatted like \`N.x\`, \`N.x.x\` or \`N.N.x\` (\`N\` is a number).
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
}),
EMAINTENANCEBRANCHES: ({branches}) => ({
message: 'The maintenance branches are invalid in the `branches` configuration.',
};
}
export function EMAINTENANCEBRANCHES({ branches }) {
return {
message: "The maintenance branches are invalid in the `branches` configuration.",
details: `Each maintenance branch in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}) must have a unique \`range\` property.
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
}),
ERELEASEBRANCHES: ({branches}) => ({
message: 'The release branches are invalid in the `branches` configuration.',
};
}
export function ERELEASEBRANCHES({ branches }) {
return {
message: "The release branches are invalid in the `branches` configuration.",
details: `A minimum of 1 and a maximum of 3 release branches are required in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}).
This may occur if your repository does not have a release branch, such as \`master\`.
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
}),
EPRERELEASEBRANCH: ({branch}) => ({
message: 'A pre-release branch configuration is invalid in the `branches` configuration.',
};
}
export function EPRERELEASEBRANCH({ branch }) {
return {
message: "A pre-release branch configuration is invalid in the `branches` configuration.",
details: `Each pre-release branch in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}) must have a \`prerelease\` property valid per the [Semantic Versioning Specification](https://semver.org/#spec-item-9). If the \`prerelease\` property is set to \`true\`, then the \`name\` property is used instead.
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
}),
EPRERELEASEBRANCHES: ({branches}) => ({
message: 'The pre-release branches are invalid in the `branches` configuration.',
};
}
export function EPRERELEASEBRANCHES({ branches }) {
return {
message: "The pre-release branches are invalid in the `branches` configuration.",
details: `Each pre-release branch in the [branches configuration](${linkify(
'docs/usage/configuration.md#branches'
"docs/usage/configuration.md#branches"
)}) must have a unique \`prerelease\` property. If the \`prerelease\` property is set to \`true\`, then the \`name\` property is used instead.
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
}),
EINVALIDNEXTVERSION: ({nextRelease: {version}, branch: {name, range}, commits, validBranches}) => ({
};
}
export function EINVALIDNEXTVERSION({ nextRelease: { version }, branch: { name, range }, commits, validBranches }) {
return {
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
details: `Based on the releases published on other branches, only versions within the range \`${range}\` can be published from branch \`${name}\`.
The following commit${commits.length > 1 ? 's are' : ' is'} responsible for the invalid release:
${commits.map(({commit: {short}, subject}) => `- ${subject} (${short})`).join('\n')}
The following commit${commits.length > 1 ? "s are" : " is"} responsible for the invalid release:
${commits.map(({ commit: { short }, subject }) => `- ${subject} (${short})`).join("\n")}
${
commits.length > 1 ? 'Those commits' : 'This commit'
commits.length > 1 ? "Those commits" : "This commit"
} should be moved to a valid branch with [git merge](https://git-scm.com/docs/git-merge) or [git cherry-pick](https://git-scm.com/docs/git-cherry-pick) and removed from branch \`${name}\` with [git revert](https://git-scm.com/docs/git-revert) or [git reset](https://git-scm.com/docs/git-reset).
A valid branch could be ${wordsList(validBranches.map(({name}) => `\`${name}\``))}.
A valid branch could be ${wordsList(validBranches.map(({ name }) => `\`${name}\``))}.
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
}),
EINVALIDMAINTENANCEMERGE: ({nextRelease: {channel, gitTag, version}, branch: {mergeRange, name}}) => ({
See the [workflow configuration documentation](${linkify("docs/usage/workflow-configuration.md")}) for more details.`,
};
}
export function EINVALIDMAINTENANCEMERGE({ nextRelease: { channel, gitTag, version }, branch: { mergeRange, name } }) {
return {
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
details: `Only releases within the range \`${mergeRange}\` can be merged into the maintenance branch \`${name}\` and published to the \`${channel}\` distribution channel.
The branch \`${name}\` head should be [reset](https://git-scm.com/docs/git-reset) to a previous commit so the commit with tag \`${gitTag}\` is removed from the branch history.
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
}),
};
See the [workflow configuration documentation](${linkify("docs/usage/workflow-configuration.md")}) for more details.`,
};
}
+21 -21
View File
@@ -1,23 +1,23 @@
/* eslint require-atomic-updates: off */
const {isString, isPlainObject} = require('lodash');
const {getGitHead} = require('../git');
const hideSensitive = require('../hide-sensitive');
const {hideSensitiveValues} = require('../utils');
const {RELEASE_TYPE, RELEASE_NOTES_SEPARATOR} = require('./constants');
import { isPlainObject, isString } from "lodash-es";
import { getGitHead } from "../git.js";
import hideSensitive from "../hide-sensitive.js";
import { hideSensitiveValues } from "../utils.js";
import { RELEASE_NOTES_SEPARATOR, RELEASE_TYPE } from "./constants.js";
module.exports = {
export default {
verifyConditions: {
required: false,
dryRun: true,
pipelineConfig: () => ({settleAll: true}),
pipelineConfig: () => ({ settleAll: true }),
},
analyzeCommits: {
default: ['@semantic-release/commit-analyzer'],
default: ["@semantic-release/commit-analyzer"],
required: true,
dryRun: true,
outputValidator: (output) => !output || RELEASE_TYPE.includes(output),
preprocess: ({commits, ...inputs}) => ({
preprocess: ({ commits, ...inputs }) => ({
...inputs,
commits: commits.filter((commit) => !/\[skip\s+release]|\[release\s+skip]/i.test(commit.message)),
}),
@@ -32,29 +32,29 @@ module.exports = {
verifyRelease: {
required: false,
dryRun: true,
pipelineConfig: () => ({settleAll: true}),
pipelineConfig: () => ({ settleAll: true }),
},
generateNotes: {
required: false,
dryRun: true,
outputValidator: (output) => !output || isString(output),
pipelineConfig: () => ({
getNextInput: ({nextRelease, ...context}, notes) => ({
getNextInput: ({ nextRelease, ...context }, notes) => ({
...context,
nextRelease: {
...nextRelease,
notes: `${nextRelease.notes ? `${nextRelease.notes}${RELEASE_NOTES_SEPARATOR}` : ''}${notes}`,
notes: `${nextRelease.notes ? `${nextRelease.notes}${RELEASE_NOTES_SEPARATOR}` : ""}${notes}`,
},
}),
}),
postprocess: (results, {env}) => hideSensitive(env)(results.filter(Boolean).join(RELEASE_NOTES_SEPARATOR)),
postprocess: (results, { env }) => hideSensitive(env)(results.filter(Boolean).join(RELEASE_NOTES_SEPARATOR)),
},
prepare: {
required: false,
dryRun: false,
pipelineConfig: ({generateNotes}) => ({
pipelineConfig: ({ generateNotes }) => ({
getNextInput: async (context) => {
const newGitHead = await getGitHead({cwd: context.cwd});
const newGitHead = await getGitHead({ cwd: context.cwd });
// If previous prepare plugin has created a commit (gitHead changed)
if (context.nextRelease.gitHead !== newGitHead) {
context.nextRelease.gitHead = newGitHead;
@@ -73,7 +73,7 @@ module.exports = {
outputValidator: (output) => !output || isPlainObject(output),
pipelineConfig: () => ({
// Add `nextRelease` and plugin properties to published release
transform: (release, step, {nextRelease}) => ({
transform: (release, step, { nextRelease }) => ({
...(release === false ? {} : nextRelease),
...release,
...step,
@@ -86,7 +86,7 @@ module.exports = {
outputValidator: (output) => !output || isPlainObject(output),
pipelineConfig: () => ({
// Add `nextRelease` and plugin properties to published release
transform: (release, step, {nextRelease}) => ({
transform: (release, step, { nextRelease }) => ({
...(release === false ? {} : nextRelease),
...release,
...step,
@@ -96,13 +96,13 @@ module.exports = {
success: {
required: false,
dryRun: false,
pipelineConfig: () => ({settleAll: true}),
preprocess: ({releases, env, ...inputs}) => ({...inputs, env, releases: hideSensitiveValues(env, releases)}),
pipelineConfig: () => ({ settleAll: true }),
preprocess: ({ releases, env, ...inputs }) => ({ ...inputs, env, releases: hideSensitiveValues(env, releases) }),
},
fail: {
required: false,
dryRun: false,
pipelineConfig: () => ({settleAll: true}),
preprocess: ({errors, env, ...inputs}) => ({...inputs, env, errors: hideSensitiveValues(env, errors)}),
pipelineConfig: () => ({ settleAll: true }),
preprocess: ({ errors, env, ...inputs }) => ({ ...inputs, env, errors: hideSensitiveValues(env, errors) }),
},
};
+15 -7
View File
@@ -1,5 +1,7 @@
const debug = require('debug')('semantic-release:get-commits');
const {getCommits} = require('./git');
import debugCommits from "debug";
import { getCommits } from "./git.js";
const debug = debugCommits("semantic-release:get-commits");
/**
* Retrieve the list of commits on the current branch since the commit sha associated with the last release, or all the commits of the current branch if there is no last released version.
@@ -8,16 +10,22 @@ const {getCommits} = require('./git');
*
* @return {Promise<Array<Object>>} The list of commits on the branch `branch` since the last release.
*/
module.exports = async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
export default async ({
cwd,
env,
lastRelease: { gitHead: from },
nextRelease: { gitHead: to = "HEAD" } = {},
logger,
}) => {
if (from) {
debug('Use from: %s', from);
debug("Use from: %s", from);
} else {
logger.log('No previous release found, retrieving all commits');
logger.log("No previous release found, retrieving all commits");
}
const commits = await getCommits(from, to, {cwd, env});
const commits = await getCommits(from, to, { cwd, env });
logger.log(`Found ${commits.length} commits since last release`);
debug('Parsed commits: %o', commits);
debug("Parsed commits: %o", commits);
return commits;
};
+46 -46
View File
@@ -1,49 +1,49 @@
const {castArray, pickBy, isNil, isString, isPlainObject} = require('lodash');
const readPkgUp = require('read-pkg-up');
const {cosmiconfig} = require('cosmiconfig');
const resolveFrom = require('resolve-from');
const debug = require('debug')('semantic-release:config');
const {repoUrl} = require('./git');
const PLUGINS_DEFINITIONS = require('./definitions/plugins');
const plugins = require('./plugins');
const {validatePlugin, parseConfig} = require('./plugins/utils');
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { createRequire } from "node:module";
const CONFIG_NAME = 'release';
const CONFIG_FILES = [
'package.json',
`.${CONFIG_NAME}rc`,
`.${CONFIG_NAME}rc.json`,
`.${CONFIG_NAME}rc.yaml`,
`.${CONFIG_NAME}rc.yml`,
`.${CONFIG_NAME}rc.js`,
`${CONFIG_NAME}.config.js`,
];
import { castArray, isNil, isPlainObject, isString, pickBy } from "lodash-es";
import { readPackageUp } from "read-pkg-up";
import { cosmiconfig } from "cosmiconfig";
import resolveFrom from "resolve-from";
import debugConfig from "debug";
import { repoUrl } from "./git.js";
import PLUGINS_DEFINITIONS from "./definitions/plugins.js";
import plugins from "./plugins/index.js";
import { parseConfig, validatePlugin } from "./plugins/utils.js";
module.exports = async (context, cliOptions) => {
const {cwd, env} = context;
const {config, filepath} = (await cosmiconfig(CONFIG_NAME, {searchPlaces: CONFIG_FILES}).search(cwd)) || {};
const debug = debugConfig("semantic-release:config");
const __dirname = dirname(fileURLToPath(import.meta.url));
const require = createRequire(import.meta.url);
debug('load config from: %s', filepath);
const CONFIG_NAME = "release";
export default async (context, cliOptions) => {
const { cwd, env } = context;
const { config, filepath } = (await cosmiconfig(CONFIG_NAME).search(cwd)) || {};
debug("load config from: %s", filepath);
// Merge config file options and CLI/API options
let options = {...config, ...cliOptions};
let options = { ...config, ...cliOptions };
const pluginsPath = {};
let extendPaths;
({extends: extendPaths, ...options} = options);
({ extends: extendPaths, ...options } = options);
if (extendPaths) {
// If `extends` is defined, load and merge each shareable config with `options`
options = {
...castArray(extendPaths).reduce((result, extendPath) => {
...(await castArray(extendPaths).reduce(async (eventualResult, extendPath) => {
const result = await eventualResult;
const extendsOptions = require(resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath));
// For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path,
// so those plugin will be loaded relatively to the config file
// so those plugin will be loaded relative to the config file
Object.entries(extendsOptions)
.filter(([, value]) => Boolean(value))
.reduce((pluginsPath, [option, value]) => {
castArray(value).forEach((plugin) => {
if (option === 'plugins' && validatePlugin(plugin)) {
if (option === "plugins" && validatePlugin(plugin)) {
pluginsPath[parseConfig(plugin)[0]] = extendPath;
} else if (
PLUGINS_DEFINITIONS[option] &&
@@ -55,8 +55,8 @@ module.exports = async (context, cliOptions) => {
return pluginsPath;
}, pluginsPath);
return {...result, ...extendsOptions};
}, {}),
return { ...result, ...extendsOptions };
}, {})),
...options,
};
}
@@ -64,36 +64,36 @@ module.exports = async (context, cliOptions) => {
// Set default options values if not defined yet
options = {
branches: [
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true},
"+([0-9])?(.{+([0-9]),x}).x",
"master",
"next",
"next-major",
{ name: "beta", prerelease: true },
{ name: "alpha", prerelease: true },
],
repositoryUrl: (await pkgRepoUrl({normalize: false, cwd})) || (await repoUrl({cwd, env})),
repositoryUrl: (await pkgRepoUrl({ normalize: false, cwd })) || (await repoUrl({ cwd, env })),
tagFormat: `v\${version}`,
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
'@semantic-release/github',
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
],
// Remove `null` and `undefined` options so they can be replaced with default ones
// Remove `null` and `undefined` options, so they can be replaced with default ones
...pickBy(options, (option) => !isNil(option)),
...(options.branches ? {branches: castArray(options.branches)} : {}),
...(options.branches ? { branches: castArray(options.branches) } : {}),
};
if (options.ci === false) {
options.noCi = true;
}
debug('options values: %O', options);
debug("options values: %O", options);
return {options, plugins: await plugins({...context, options}, pluginsPath)};
return { options, plugins: await plugins({ ...context, options }, pluginsPath) };
};
async function pkgRepoUrl(options) {
const {packageJson} = (await readPkgUp(options)) || {};
const { packageJson } = (await readPackageUp(options)) || {};
return packageJson && (isPlainObject(packageJson.repository) ? packageJson.repository.url : packageJson.repository);
}
+4 -4
View File
@@ -1,7 +1,7 @@
const SemanticReleaseError = require('@semantic-release/error');
const ERROR_DEFINITIONS = require('./definitions/errors');
import SemanticReleaseError from "@semantic-release/error";
import * as ERROR_DEFINITIONS from "./definitions/errors.js";
module.exports = (code, ctx = {}) => {
const {message, details} = ERROR_DEFINITIONS[code](ctx);
export default (code, ctx = {}) => {
const { message, details } = ERROR_DEFINITIONS[code](ctx);
return new SemanticReleaseError(message, code, details);
};
+34 -32
View File
@@ -1,8 +1,10 @@
const {parse, format} = require('url'); // eslint-disable-line node/no-deprecated-api
const {isNil} = require('lodash');
const hostedGitInfo = require('hosted-git-info');
const {verifyAuth} = require('./git');
const debug = require('debug')('semantic-release:get-git-auth-url');
import { format, parse } from "node:url";
import { isNil } from "lodash-es";
import hostedGitInfo from "hosted-git-info";
import debugAuthUrl from "debug";
import { verifyAuth } from "./git.js";
const debug = debugAuthUrl("semantic-release:get-git-auth-url");
/**
* Machinery to format a repository URL with the given credentials
@@ -16,15 +18,15 @@ const debug = require('debug')('semantic-release:get-git-auth-url');
function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
const [match, auth, host, basePort, path] =
/^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<port>\d+)?:?\/?(?<path>.*)$/.exec(repositoryUrl) || [];
const {port, hostname, ...parsed} = parse(
match ? `ssh://${auth ? `${auth}@` : ''}${host}${basePort ? `:${basePort}` : ''}/${path}` : repositoryUrl
const { port, hostname, ...parsed } = parse(
match ? `ssh://${auth ? `${auth}@` : ""}${host}${basePort ? `:${basePort}` : ""}/${path}` : repositoryUrl
);
return format({
...parsed,
auth: gitCredentials,
host: `${hostname}${protocol === 'ssh:' ? '' : port ? `:${port}` : ''}`,
protocol: protocol && /http[^s]/.test(protocol) ? 'http' : 'https',
host: `${hostname}${protocol === "ssh:" ? "" : port ? `:${port}` : ""}`,
protocol: protocol && /http[^s]/.test(protocol) ? "http" : "https",
});
}
@@ -36,9 +38,9 @@ function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
*
* @return {String} The authUrl as is if the connection was successfull, null otherwise
*/
async function ensureValidAuthUrl({cwd, env, branch}, authUrl) {
async function ensureValidAuthUrl({ cwd, env, branch }, authUrl) {
try {
await verifyAuth(authUrl, branch.name, {cwd, env});
await verifyAuth(authUrl, branch.name, { cwd, env });
return authUrl;
} catch (error) {
debug(error);
@@ -57,45 +59,45 @@ async function ensureValidAuthUrl({cwd, env, branch}, authUrl) {
*
* @return {String} The formatted Git repository URL.
*/
module.exports = async (context) => {
const {cwd, env, branch} = context;
export default async (context) => {
const { cwd, env, branch } = context;
const GIT_TOKENS = {
GIT_CREDENTIALS: undefined,
GH_TOKEN: undefined,
// GitHub Actions require the "x-access-token:" prefix for git access
// https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation
GITHUB_TOKEN: isNil(env.GITHUB_ACTION) ? undefined : 'x-access-token:',
GL_TOKEN: 'gitlab-ci-token:',
GITLAB_TOKEN: 'gitlab-ci-token:',
BB_TOKEN: 'x-token-auth:',
BITBUCKET_TOKEN: 'x-token-auth:',
BB_TOKEN_BASIC_AUTH: '',
BITBUCKET_TOKEN_BASIC_AUTH: '',
GITHUB_TOKEN: isNil(env.GITHUB_ACTION) ? undefined : "x-access-token:",
GL_TOKEN: "gitlab-ci-token:",
GITLAB_TOKEN: "gitlab-ci-token:",
BB_TOKEN: "x-token-auth:",
BITBUCKET_TOKEN: "x-token-auth:",
BB_TOKEN_BASIC_AUTH: "",
BITBUCKET_TOKEN_BASIC_AUTH: "",
};
let {repositoryUrl} = context.options;
const info = hostedGitInfo.fromUrl(repositoryUrl, {noGitPlus: true});
const {protocol, ...parsed} = parse(repositoryUrl);
let { repositoryUrl } = context.options;
const info = hostedGitInfo.fromUrl(repositoryUrl, { noGitPlus: true });
const { protocol, ...parsed } = parse(repositoryUrl);
if (info && info.getDefaultRepresentation() === 'shortcut') {
if (info && info.getDefaultRepresentation() === "shortcut") {
// Expand shorthand URLs (such as `owner/repo` or `gitlab:owner/repo`)
repositoryUrl = info.https();
} else if (protocol && protocol.includes('http')) {
} else if (protocol && protocol.includes("http")) {
// Replace `git+https` and `git+http` with `https` or `http`
repositoryUrl = format({...parsed, protocol: protocol.includes('https') ? 'https' : 'http', href: null});
repositoryUrl = format({ ...parsed, protocol: protocol.includes("https") ? "https" : "http", href: null });
}
// Test if push is allowed without transforming the URL (e.g. is ssh keys are set up)
try {
debug('Verifying ssh auth by attempting to push to %s', repositoryUrl);
await verifyAuth(repositoryUrl, branch.name, {cwd, env});
} catch (_) {
debug('SSH key auth failed, falling back to https.');
debug("Verifying ssh auth by attempting to push to %s", repositoryUrl);
await verifyAuth(repositoryUrl, branch.name, { cwd, env });
} catch {
debug("SSH key auth failed, falling back to https.");
const envVars = Object.keys(GIT_TOKENS).filter((envVar) => !isNil(env[envVar]));
// Skip verification if there is no ambiguity on which env var to use for authentication
if (envVars.length === 1) {
const gitCredentials = `${GIT_TOKENS[envVars[0]] || ''}${env[envVars[0]]}`;
const gitCredentials = `${GIT_TOKENS[envVars[0]] || ""}${env[envVars[0]]}`;
return formatAuthUrl(protocol, repositoryUrl, gitCredentials);
}
@@ -104,7 +106,7 @@ module.exports = async (context) => {
const candidateRepositoryUrls = [];
for (const envVar of envVars) {
const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar]}`;
const gitCredentials = `${GIT_TOKENS[envVar] || ""}${env[envVar]}`;
const authUrl = formatAuthUrl(protocol, repositoryUrl, gitCredentials);
candidateRepositoryUrls.push(ensureValidAuthUrl(context, authUrl));
}
+8 -8
View File
@@ -1,6 +1,6 @@
const {isUndefined} = require('lodash');
const semver = require('semver');
const {makeTag, isSameChannel} = require('./utils');
import { isUndefined } from "lodash-es";
import semver from "semver";
import { isSameChannel, makeTag } from "./utils.js";
/**
* Last release.
@@ -18,7 +18,7 @@ const {makeTag, isSameChannel} = require('./utils');
*
* - Filter out the branch tags that are not valid semantic version
* - Sort the versions
* - Retrive the highest version
* - Retrieve the highest version
*
* @param {Object} context semantic-release context.
* @param {Object} params Function parameters.
@@ -26,18 +26,18 @@ const {makeTag, isSameChannel} = require('./utils');
*
* @return {LastRelease} The last tagged release or empty object if none is found.
*/
module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
const [{version, gitTag, channels} = {}] = branch.tags
export default ({ branch, options: { tagFormat } }, { before } = {}) => {
const [{ version, gitTag, channels } = {}] = branch.tags
.filter(
(tag) =>
((branch.type === 'prerelease' && tag.channels.some((channel) => isSameChannel(branch.channel, channel))) ||
((branch.type === "prerelease" && tag.channels.some((channel) => isSameChannel(branch.channel, channel))) ||
!semver.prerelease(tag.version)) &&
(isUndefined(before) || semver.lt(tag.version, before))
)
.sort((a, b) => semver.rcompare(a.version, b.version));
if (gitTag) {
return {version, gitTag, channels, gitHead: gitTag, name: makeTag(tagFormat, version)};
return { version, gitTag, channels, gitHead: gitTag, name: makeTag(tagFormat, version) };
}
return {};
+10 -8
View File
@@ -1,16 +1,18 @@
const {Signale} = require('signale');
const figures = require('figures');
import signale from "signale";
import figures from "figures";
module.exports = ({stdout, stderr}) =>
const { Signale } = signale;
export default ({ stdout, stderr }) =>
new Signale({
config: {displayTimestamp: true, underlineMessage: false, displayLabel: false},
config: { displayTimestamp: true, underlineMessage: false, displayLabel: false },
disabled: false,
interactive: false,
scope: 'semantic-release',
scope: "semantic-release",
stream: [stdout],
types: {
error: {badge: figures.cross, color: 'red', label: '', stream: [stderr]},
log: {badge: figures.info, color: 'magenta', label: '', stream: [stdout]},
success: {badge: figures.tick, color: 'green', label: '', stream: [stdout]},
error: { badge: figures.cross, color: "red", label: "", stream: [stderr] },
log: { badge: figures.info, color: "magenta", label: "", stream: [stdout] },
success: { badge: figures.tick, color: "green", label: "", stream: [stdout] },
},
});
+10 -10
View File
@@ -1,20 +1,20 @@
const semver = require('semver');
const {FIRST_RELEASE, FIRSTPRERELEASE} = require('./definitions/constants');
const {isSameChannel, getLatestVersion, tagsToVersions, highest} = require('./utils');
import semver from "semver";
import { FIRST_RELEASE, FIRSTPRERELEASE } from "./definitions/constants.js";
import { getLatestVersion, highest, isSameChannel, tagsToVersions } from "./utils.js";
module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
export default ({ branch, nextRelease: { type, channel }, lastRelease, logger }) => {
let version;
if (lastRelease.version) {
const {major, minor, patch} = semver.parse(lastRelease.version);
const { major, minor, patch } = semver.parse(lastRelease.version);
if (branch.type === 'prerelease') {
if (branch.type === "prerelease") {
if (
semver.prerelease(lastRelease.version) &&
lastRelease.channels.some((lastReleaseChannel) => isSameChannel(lastReleaseChannel, channel))
) {
version = highest(
semver.inc(lastRelease.version, 'prerelease'),
`${semver.inc(getLatestVersion(tagsToVersions(branch.tags), {withPrerelease: true}), type)}-${
semver.inc(lastRelease.version, "prerelease"),
`${semver.inc(getLatestVersion(tagsToVersions(branch.tags), { withPrerelease: true }), type)}-${
branch.prerelease
}.${FIRSTPRERELEASE}`
);
@@ -25,9 +25,9 @@ module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) =
version = semver.inc(lastRelease.version, type);
}
logger.log('The next release version is %s', version);
logger.log("The next release version is %s", version);
} else {
version = branch.type === 'prerelease' ? `${FIRST_RELEASE}-${branch.prerelease}.${FIRSTPRERELEASE}` : FIRST_RELEASE;
version = branch.type === "prerelease" ? `${FIRST_RELEASE}-${branch.prerelease}.${FIRSTPRERELEASE}` : FIRST_RELEASE;
logger.log(`There is no previous release, the next release version is ${version}`);
}
+17 -17
View File
@@ -1,8 +1,8 @@
const {uniqBy, intersection} = require('lodash');
const semver = require('semver');
const semverDiff = require('semver-diff');
const getLastRelease = require('./get-last-release');
const {makeTag, getLowerBound} = require('./utils');
import { intersection, uniqBy } from "lodash-es";
import semver from "semver";
import semverDiff from "semver-diff";
import getLastRelease from "./get-last-release.js";
import { getLowerBound, makeTag } from "./utils.js";
/**
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
@@ -11,42 +11,42 @@ const {makeTag, getLowerBound} = require('./utils');
*
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
*/
module.exports = (context) => {
export default (context) => {
const {
branch,
branches,
options: {tagFormat},
options: { tagFormat },
} = context;
const higherChannels = branches
// Consider only releases of higher branches
.slice(branches.findIndex(({name}) => name === branch.name) + 1)
.slice(branches.findIndex(({ name }) => name === branch.name) + 1)
// Exclude prerelease branches
.filter(({type}) => type !== 'prerelease')
.map(({channel}) => channel || null);
.filter(({ type }) => type !== "prerelease")
.map(({ channel }) => channel || null);
const versiontoAdd = uniqBy(
branch.tags.filter(
({channels, version}) =>
({ channels, version }) =>
!channels.includes(branch.channel || null) &&
intersection(channels, higherChannels).length > 0 &&
(branch.type !== 'maintenance' || semver.gte(version, getLowerBound(branch.mergeRange)))
(branch.type !== "maintenance" || semver.gte(version, getLowerBound(branch.mergeRange)))
),
'version'
"version"
).sort((a, b) => semver.compare(b.version, a.version))[0];
if (versiontoAdd) {
const {version, gitTag, channels} = versiontoAdd;
const lastRelease = getLastRelease(context, {before: version});
const { version, gitTag, channels } = versiontoAdd;
const lastRelease = getLastRelease(context, { before: version });
if (semver.gt(getLastRelease(context).version, version)) {
return;
}
const type = lastRelease.version ? semverDiff(lastRelease.version, version) : 'major';
const type = lastRelease.version ? semverDiff(lastRelease.version, version) : "major";
const name = makeTag(tagFormat, version);
return {
lastRelease,
currentRelease: {type, version, channels, gitTag, name, gitHead: gitTag},
currentRelease: { type, version, channels, gitTag, name, gitHead: gitTag },
nextRelease: {
type,
version,
+64 -84
View File
@@ -1,10 +1,12 @@
const gitLogParser = require('git-log-parser');
const getStream = require('get-stream');
const execa = require('execa');
const debug = require('debug')('semantic-release:git');
const {GIT_NOTE_REF} = require('./definitions/constants');
import gitLogParser from "git-log-parser";
import getStream from "get-stream";
import { execa } from "execa";
import debugGit from "debug";
import { GIT_NOTE_REF } from "./definitions/constants.js";
Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
const debug = debugGit("semantic-release:git");
Object.assign(gitLogParser.fields, { hash: "H", message: "B", gitTags: "d", committerDate: { key: "ci", type: Date } });
/**
* Get the commit sha for a given tag.
@@ -14,8 +16,8 @@ Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', commi
*
* @return {String} The commit sha of the tag in parameter or `null`.
*/
async function getTagHead(tagName, execaOptions) {
return (await execa('git', ['rev-list', '-1', tagName], execaOptions)).stdout;
export async function getTagHead(tagName, execaOptions) {
return (await execa("git", ["rev-list", "-1", tagName], execaOptions)).stdout;
}
/**
@@ -27,9 +29,9 @@ async function getTagHead(tagName, execaOptions) {
* @return {Array<String>} List of git tags.
* @throws {Error} If the `git` command fails.
*/
async function getTags(branch, execaOptions) {
return (await execa('git', ['tag', '--merged', branch], execaOptions)).stdout
.split('\n')
export async function getTags(branch, execaOptions) {
return (await execa("git", ["tag", "--merged", branch], execaOptions)).stdout
.split("\n")
.map((tag) => tag.trim())
.filter(Boolean);
}
@@ -42,15 +44,15 @@ async function getTags(branch, execaOptions) {
* @param {Object} [execaOpts] Options to pass to `execa`.
* @return {Promise<Array<Object>>} The list of commits between `from` and `to`.
*/
async function getCommits(from, to, execaOptions) {
export async function getCommits(from, to, execaOptions) {
return (
await getStream.array(
gitLogParser.parse(
{_: `${from ? from + '..' : ''}${to}`},
{cwd: execaOptions.cwd, env: {...process.env, ...execaOptions.env}}
{ _: `${from ? from + ".." : ""}${to}` },
{ cwd: execaOptions.cwd, env: { ...process.env, ...execaOptions.env } }
)
)
).map(({message, gitTags, ...commit}) => ({...commit, message: message.trim(), gitTags: gitTags.trim()}));
).map(({ message, gitTags, ...commit }) => ({ ...commit, message: message.trim(), gitTags: gitTags.trim() }));
}
/**
@@ -62,9 +64,9 @@ async function getCommits(from, to, execaOptions) {
* @return {Array<String>} List of git branches.
* @throws {Error} If the `git` command fails.
*/
async function getBranches(repositoryUrl, execaOptions) {
return (await execa('git', ['ls-remote', '--heads', repositoryUrl], execaOptions)).stdout
.split('\n')
export async function getBranches(repositoryUrl, execaOptions) {
return (await execa("git", ["ls-remote", "--heads", repositoryUrl], execaOptions)).stdout
.split("\n")
.filter(Boolean)
.map((branch) => branch.match(/^.+refs\/heads\/(?<branch>.+)$/)[1]);
}
@@ -77,9 +79,9 @@ async function getBranches(repositoryUrl, execaOptions) {
*
* @return {Boolean} `true` if the reference exists, falsy otherwise.
*/
async function isRefExists(ref, execaOptions) {
export async function isRefExists(ref, execaOptions) {
try {
return (await execa('git', ['rev-parse', '--verify', ref], execaOptions)).exitCode === 0;
return (await execa("git", ["rev-parse", "--verify", ref], execaOptions)).exitCode === 0;
} catch (error) {
debug(error);
}
@@ -99,32 +101,32 @@ async function isRefExists(ref, execaOptions) {
* @param {String} branch The repository branch to fetch.
* @param {Object} [execaOpts] Options to pass to `execa`.
*/
async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
export async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
const isDetachedHead =
(await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {...execaOptions, reject: false})).stdout === 'HEAD';
(await execa("git", ["rev-parse", "--abbrev-ref", "HEAD"], { ...execaOptions, reject: false })).stdout === "HEAD";
try {
await execa(
'git',
"git",
[
'fetch',
'--unshallow',
'--tags',
"fetch",
"--unshallow",
"--tags",
...(branch === ciBranch && !isDetachedHead
? [repositoryUrl]
: ['--update-head-ok', repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
: ["--update-head-ok", repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
],
execaOptions
);
} catch (_) {
} catch {
await execa(
'git',
"git",
[
'fetch',
'--tags',
"fetch",
"--tags",
...(branch === ciBranch && !isDetachedHead
? [repositoryUrl]
: ['--update-head-ok', repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
: ["--update-head-ok", repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
],
execaOptions
);
@@ -137,15 +139,15 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
* @param {String} repositoryUrl The remote repository URL.
* @param {Object} [execaOpts] Options to pass to `execa`.
*/
async function fetchNotes(repositoryUrl, execaOptions) {
export async function fetchNotes(repositoryUrl, execaOptions) {
try {
await execa(
'git',
['fetch', '--unshallow', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`],
"git",
["fetch", "--unshallow", repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`],
execaOptions
);
} catch (_) {
await execa('git', ['fetch', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`], {
} catch {
await execa("git", ["fetch", repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`], {
...execaOptions,
reject: false,
});
@@ -159,8 +161,8 @@ async function fetchNotes(repositoryUrl, execaOptions) {
*
* @return {String} the sha of the HEAD commit.
*/
async function getGitHead(execaOptions) {
return (await execa('git', ['rev-parse', 'HEAD'], execaOptions)).stdout;
export async function getGitHead(execaOptions) {
return (await execa("git", ["rev-parse", "HEAD"], execaOptions)).stdout;
}
/**
@@ -170,9 +172,9 @@ async function getGitHead(execaOptions) {
*
* @return {string} The value of the remote git URL.
*/
async function repoUrl(execaOptions) {
export async function repoUrl(execaOptions) {
try {
return (await execa('git', ['config', '--get', 'remote.origin.url'], execaOptions)).stdout;
return (await execa("git", ["config", "--get", "remote.origin.url"], execaOptions)).stdout;
} catch (error) {
debug(error);
}
@@ -185,9 +187,9 @@ async function repoUrl(execaOptions) {
*
* @return {Boolean} `true` if the current working directory is in a git repository, falsy otherwise.
*/
async function isGitRepo(execaOptions) {
export async function isGitRepo(execaOptions) {
try {
return (await execa('git', ['rev-parse', '--git-dir'], execaOptions)).exitCode === 0;
return (await execa("git", ["rev-parse", "--git-dir"], execaOptions)).exitCode === 0;
} catch (error) {
debug(error);
}
@@ -202,9 +204,9 @@ async function isGitRepo(execaOptions) {
*
* @throws {Error} if not authorized to push.
*/
async function verifyAuth(repositoryUrl, branch, execaOptions) {
export async function verifyAuth(repositoryUrl, branch, execaOptions) {
try {
await execa('git', ['push', '--dry-run', '--no-verify', repositoryUrl, `HEAD:${branch}`], execaOptions);
await execa("git", ["push", "--dry-run", "--no-verify", repositoryUrl, `HEAD:${branch}`], execaOptions);
} catch (error) {
debug(error);
throw error;
@@ -220,8 +222,8 @@ async function verifyAuth(repositoryUrl, branch, execaOptions) {
*
* @throws {Error} if the tag creation failed.
*/
async function tag(tagName, ref, execaOptions) {
await execa('git', ['tag', tagName, ref], execaOptions);
export async function tag(tagName, ref, execaOptions) {
await execa("git", ["tag", tagName, ref], execaOptions);
}
/**
@@ -232,8 +234,8 @@ async function tag(tagName, ref, execaOptions) {
*
* @throws {Error} if the push failed.
*/
async function push(repositoryUrl, execaOptions) {
await execa('git', ['push', '--tags', repositoryUrl], execaOptions);
export async function push(repositoryUrl, execaOptions) {
await execa("git", ["push", "--tags", repositoryUrl], execaOptions);
}
/**
@@ -244,8 +246,8 @@ async function push(repositoryUrl, execaOptions) {
*
* @throws {Error} if the push failed.
*/
async function pushNotes(repositoryUrl, execaOptions) {
await execa('git', ['push', repositoryUrl, `refs/notes/${GIT_NOTE_REF}`], execaOptions);
export async function pushNotes(repositoryUrl, execaOptions) {
await execa("git", ["push", repositoryUrl, `refs/notes/${GIT_NOTE_REF}`], execaOptions);
}
/**
@@ -256,9 +258,9 @@ async function pushNotes(repositoryUrl, execaOptions) {
*
* @return {Boolean} `true` if valid, falsy otherwise.
*/
async function verifyTagName(tagName, execaOptions) {
export async function verifyTagName(tagName, execaOptions) {
try {
return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOptions)).exitCode === 0;
return (await execa("git", ["check-ref-format", `refs/tags/${tagName}`], execaOptions)).exitCode === 0;
} catch (error) {
debug(error);
}
@@ -272,9 +274,9 @@ async function verifyTagName(tagName, execaOptions) {
*
* @return {Boolean} `true` if valid, falsy otherwise.
*/
async function verifyBranchName(branch, execaOptions) {
export async function verifyBranchName(branch, execaOptions) {
try {
return (await execa('git', ['check-ref-format', `refs/heads/${branch}`], execaOptions)).exitCode === 0;
return (await execa("git", ["check-ref-format", `refs/heads/${branch}`], execaOptions)).exitCode === 0;
} catch (error) {
debug(error);
}
@@ -289,10 +291,10 @@ async function verifyBranchName(branch, execaOptions) {
*
* @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise.
*/
async function isBranchUpToDate(repositoryUrl, branch, execaOptions) {
export async function isBranchUpToDate(repositoryUrl, branch, execaOptions) {
return (
(await getGitHead(execaOptions)) ===
(await execa('git', ['ls-remote', '--heads', repositoryUrl, branch], execaOptions)).stdout.match(/^(?<ref>\w+)?/)[1]
(await execa("git", ["ls-remote", "--heads", repositoryUrl, branch], execaOptions)).stdout.match(/^(?<ref>\w+)?/)[1]
);
}
@@ -304,9 +306,9 @@ async function isBranchUpToDate(repositoryUrl, branch, execaOptions) {
*
* @return {Object} the parsed JSON note if there is one, an empty object otherwise.
*/
async function getNote(ref, execaOptions) {
export async function getNote(ref, execaOptions) {
try {
return JSON.parse((await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOptions)).stdout);
return JSON.parse((await execa("git", ["notes", "--ref", GIT_NOTE_REF, "show", ref], execaOptions)).stdout);
} catch (error) {
if (error.exitCode === 1) {
return {};
@@ -318,34 +320,12 @@ async function getNote(ref, execaOptions) {
}
/**
* Get and parse the JSON note of a given reference.
* Add JSON note to a given reference.
*
* @param {Object} note The object to save in the reference note.
* @param {String} ref The Git reference to add the note to.
* @param {Object} [execaOpts] Options to pass to `execa`.
*/
async function addNote(note, ref, execaOptions) {
await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-f', '-m', JSON.stringify(note), ref], execaOptions);
export async function addNote(note, ref, execaOptions) {
await execa("git", ["notes", "--ref", GIT_NOTE_REF, "add", "-f", "-m", JSON.stringify(note), ref], execaOptions);
}
module.exports = {
getTagHead,
getTags,
getCommits,
getBranches,
isRefExists,
fetch,
fetchNotes,
getGitHead,
repoUrl,
isGitRepo,
verifyAuth,
tag,
push,
pushNotes,
verifyTagName,
isBranchUpToDate,
verifyBranchName,
getNote,
addNote,
};
+6 -6
View File
@@ -1,10 +1,10 @@
const {escapeRegExp, size, isString} = require('lodash');
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('./definitions/constants');
import { escapeRegExp, isString, size } from "lodash-es";
import { SECRET_MIN_SIZE, SECRET_REPLACEMENT } from "./definitions/constants.js";
module.exports = (env) => {
export default (env) => {
const toReplace = Object.keys(env).filter((envVar) => {
// https://github.com/semantic-release/semantic-release/issues/1558
if (envVar === 'GOPRIVATE') {
if (envVar === "GOPRIVATE") {
return false;
}
@@ -12,8 +12,8 @@ module.exports = (env) => {
});
const regexp = new RegExp(
toReplace.map((envVar) => `${escapeRegExp(env[envVar])}|${escapeRegExp(encodeURI(env[envVar]))}`).join('|'),
'g'
toReplace.map((envVar) => `${escapeRegExp(env[envVar])}|${escapeRegExp(encodeURI(env[envVar]))}`).join("|"),
"g"
);
return (output) =>
output && isString(output) && toReplace.length > 0 ? output.toString().replace(regexp, SECRET_REPLACEMENT) : output;
+43 -33
View File
@@ -1,40 +1,41 @@
const {identity, isPlainObject, omit, castArray, isNil, isString} = require('lodash');
const AggregateError = require('aggregate-error');
const getError = require('../get-error');
const PLUGINS_DEFINITIONS = require('../definitions/plugins');
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('./utils');
const pipeline = require('./pipeline');
const normalize = require('./normalize');
import { castArray, identity, isNil, isPlainObject, isString, omit } from "lodash-es";
import AggregateError from "aggregate-error";
import getError from "../get-error.js";
import PLUGINS_DEFINITIONS from "../definitions/plugins.js";
import { loadPlugin, parseConfig, validatePlugin, validateStep } from "./utils.js";
import pipeline from "./pipeline.js";
import normalize from "./normalize.js";
module.exports = (context, pluginsPath) => {
let {options, logger} = context;
export default async (context, pluginsPath) => {
let { options, logger } = context;
const errors = [];
const plugins = options.plugins
? castArray(options.plugins).reduce((plugins, plugin) => {
? await castArray(options.plugins).reduce(async (eventualPluginsList, plugin) => {
const pluginsList = await eventualPluginsList;
if (validatePlugin(plugin)) {
const [name, config] = parseConfig(plugin);
plugin = isString(name) ? loadPlugin(context, name, pluginsPath) : name;
plugin = isString(name) ? await loadPlugin(context, name, pluginsPath) : name;
if (isPlainObject(plugin)) {
Object.entries(plugin).forEach(([type, func]) => {
if (PLUGINS_DEFINITIONS[type]) {
Reflect.defineProperty(func, 'pluginName', {
value: isPlainObject(name) ? 'Inline plugin' : name,
Reflect.defineProperty(func, "pluginName", {
value: isPlainObject(name) ? "Inline plugin" : name,
writable: false,
enumerable: true,
});
plugins[type] = [...(plugins[type] || []), [func, config]];
pluginsList[type] = [...(pluginsList[type] || []), [func, config]];
}
});
} else {
errors.push(getError('EPLUGINSCONF', {plugin}));
errors.push(getError("EPLUGINSCONF", { plugin }));
}
} else {
errors.push(getError('EPLUGINSCONF', {plugin}));
errors.push(getError("EPLUGINSCONF", { plugin }));
}
return plugins;
return pluginsList;
}, {})
: [];
@@ -42,11 +43,15 @@ module.exports = (context, pluginsPath) => {
throw new AggregateError(errors);
}
options = {...plugins, ...options};
options = { ...plugins, ...options };
const pluginsConf = Object.entries(PLUGINS_DEFINITIONS).reduce(
(pluginsConf, [type, {required, default: def, pipelineConfig, postprocess = identity, preprocess = identity}]) => {
const pluginsConfig = await Object.entries(PLUGINS_DEFINITIONS).reduce(
async (
eventualPluginsConfigAccumulator,
[type, { required, default: def, pipelineConfig, postprocess = identity, preprocess = identity }]
) => {
let pluginOptions;
const pluginsConfigAccumulator = await eventualPluginsConfigAccumulator;
if (isNil(options[type]) && def) {
pluginOptions = def;
@@ -58,30 +63,35 @@ module.exports = (context, pluginsPath) => {
);
}
if (!validateStep({required}, options[type])) {
errors.push(getError('EPLUGINCONF', {type, required, pluginConf: options[type]}));
return pluginsConf;
if (!validateStep({ required }, options[type])) {
errors.push(getError("EPLUGINCONF", { type, required, pluginConf: options[type] }));
return pluginsConfigAccumulator;
}
pluginOptions = options[type];
}
const steps = castArray(pluginOptions).map((pluginOpt) =>
normalize(
{...context, options: omit(options, Object.keys(PLUGINS_DEFINITIONS), 'plugins')},
type,
pluginOpt,
pluginsPath
const steps = await Promise.all(
castArray(pluginOptions).map(async (pluginOpt) =>
normalize(
{ ...context, options: omit(options, Object.keys(PLUGINS_DEFINITIONS), "plugins") },
type,
pluginOpt,
pluginsPath
)
)
);
pluginsConf[type] = async (input) =>
pluginsConfigAccumulator[type] = async (input) =>
postprocess(
await pipeline(steps, pipelineConfig && pipelineConfig(pluginsConf, logger))(await preprocess(input)),
await pipeline(
steps,
pipelineConfig && pipelineConfig(pluginsConfigAccumulator, logger)
)(await preprocess(input)),
input
);
return pluginsConf;
return pluginsConfigAccumulator;
},
plugins
);
@@ -89,5 +99,5 @@ module.exports = (context, pluginsPath) => {
throw new AggregateError(errors);
}
return pluginsConf;
return pluginsConfig;
};
+19 -17
View File
@@ -1,44 +1,46 @@
const {isPlainObject, isFunction, noop, cloneDeep, omit} = require('lodash');
const debug = require('debug')('semantic-release:plugins');
const getError = require('../get-error');
const {extractErrors} = require('../utils');
const PLUGINS_DEFINITIONS = require('../definitions/plugins');
const {loadPlugin, parseConfig} = require('./utils');
import { cloneDeep, isFunction, isPlainObject, noop, omit } from "lodash-es";
import debugPlugins from "debug";
import getError from "../get-error.js";
import { extractErrors } from "../utils.js";
import PLUGINS_DEFINITIONS from "../definitions/plugins.js";
import { loadPlugin, parseConfig } from "./utils.js";
module.exports = (context, type, pluginOpt, pluginsPath) => {
const {stdout, stderr, options, logger} = context;
const debug = debugPlugins("semantic-release:plugins");
export default async (context, type, pluginOpt, pluginsPath) => {
const { stdout, stderr, options, logger } = context;
if (!pluginOpt) {
return noop;
}
const [name, config] = parseConfig(pluginOpt);
const pluginName = name.pluginName ? name.pluginName : isFunction(name) ? `[Function: ${name.name}]` : name;
const plugin = loadPlugin(context, name, pluginsPath);
const plugin = await loadPlugin(context, name, pluginsPath);
debug(`options for ${pluginName}/${type}: %O`, config);
let func;
if (isFunction(plugin)) {
func = plugin.bind(null, cloneDeep({...options, ...config}));
func = plugin.bind(null, cloneDeep({ ...options, ...config }));
} else if (isPlainObject(plugin) && plugin[type] && isFunction(plugin[type])) {
func = plugin[type].bind(null, cloneDeep({...options, ...config}));
func = plugin[type].bind(null, cloneDeep({ ...options, ...config }));
} else {
throw getError('EPLUGIN', {type, pluginName});
throw getError("EPLUGIN", { type, pluginName });
}
const validator = async (input) => {
const {dryRun, outputValidator} = PLUGINS_DEFINITIONS[type] || {};
const { dryRun, outputValidator } = PLUGINS_DEFINITIONS[type] || {};
try {
if (!input.options.dryRun || dryRun) {
logger.log(`Start step "${type}" of plugin "${pluginName}"`);
const result = await func({
...cloneDeep(omit(input, ['stdout', 'stderr', 'logger'])),
...cloneDeep(omit(input, ["stdout", "stderr", "logger"])),
stdout,
stderr,
logger: logger.scope(logger.scopeName, pluginName),
});
if (outputValidator && !outputValidator(result)) {
throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName});
throw getError(`E${type.toUpperCase()}OUTPUT`, { result, pluginName });
}
logger.success(`Completed step "${type}" of plugin "${pluginName}"`);
@@ -48,12 +50,12 @@ module.exports = (context, type, pluginOpt, pluginsPath) => {
logger.warn(`Skip step "${type}" of plugin "${pluginName}" in dry-run mode`);
} catch (error) {
logger.error(`Failed step "${type}" of plugin "${pluginName}"`);
extractErrors(error).forEach((err) => Object.assign(err, {pluginName}));
extractErrors(error).forEach((err) => Object.assign(err, { pluginName }));
throw error;
}
};
Reflect.defineProperty(validator, 'pluginName', {value: pluginName, writable: false, enumerable: true});
Reflect.defineProperty(validator, "pluginName", { value: pluginName, writable: false, enumerable: true });
if (!isFunction(pluginOpt)) {
if (pluginsPath[name]) {
+34 -33
View File
@@ -1,7 +1,7 @@
const {identity} = require('lodash');
const pReduce = require('p-reduce');
const AggregateError = require('aggregate-error');
const {extractErrors} = require('../utils');
import { identity } from "lodash-es";
import pReduce from "p-reduce";
import AggregateError from "aggregate-error";
import { extractErrors } from "../utils.js";
/**
* A Function that execute a list of function sequencially. If at least one Function ins the pipeline throws an Error or rejects, the pipeline function rejects as well.
@@ -23,36 +23,37 @@ const {extractErrors} = require('../utils');
* @param {Function} [options.getNextInput=identity] Function called after each step is executed, with the last step input and the current current step result; the returned value will be used as the input of the next step.
* @param {Function} [options.transform=identity] Function called after each step is executed, with the current step result, the step function and the last step input; the returned value will be saved in the pipeline results.
*
* @return {Pipeline} A Function that execute the `steps` sequencially
* @return {Pipeline} A Function that execute the `steps` sequentially
*/
module.exports = (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async (input) => {
const results = [];
const errors = [];
await pReduce(
steps,
async (lastInput, step) => {
let result;
try {
// Call the step with the input computed at the end of the previous iteration and save intermediary result
result = await transform(await step(lastInput), step, lastInput);
results.push(result);
} catch (error) {
if (settleAll) {
errors.push(...extractErrors(error));
result = error;
} else {
throw error;
export default (steps, { settleAll = false, getNextInput = identity, transform = identity } = {}) =>
async (input) => {
const results = [];
const errors = [];
await pReduce(
steps,
async (lastInput, step) => {
let result;
try {
// Call the step with the input computed at the end of the previous iteration and save intermediary result
result = await transform(await step(lastInput), step, lastInput);
results.push(result);
} catch (error) {
if (settleAll) {
errors.push(...extractErrors(error));
result = error;
} else {
throw error;
}
}
}
// Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one
return getNextInput(lastInput, result);
},
input
);
if (errors.length > 0) {
throw new AggregateError(errors);
}
// Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one
return getNextInput(lastInput, result);
},
input
);
if (errors.length > 0) {
throw new AggregateError(errors);
}
return results;
};
return results;
};
+24 -11
View File
@@ -1,6 +1,9 @@
const {dirname} = require('path');
const {isString, isFunction, castArray, isArray, isPlainObject, isNil} = require('lodash');
const resolveFrom = require('resolve-from');
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { castArray, isArray, isFunction, isNil, isPlainObject, isString } from "lodash-es";
import resolveFrom from "resolve-from";
const __dirname = dirname(fileURLToPath(import.meta.url));
const validateSteps = (conf) => {
return conf.every((conf) => {
@@ -24,7 +27,7 @@ const validateSteps = (conf) => {
});
};
function validatePlugin(conf) {
export function validatePlugin(conf) {
return (
isString(conf) ||
(isArray(conf) &&
@@ -35,7 +38,7 @@ function validatePlugin(conf) {
);
}
function validateStep({required}, conf) {
export function validateStep({ required }, conf) {
conf = castArray(conf).filter(Boolean);
if (required) {
return conf.length >= 1 && validateSteps(conf);
@@ -44,25 +47,35 @@ function validateStep({required}, conf) {
return conf.length === 0 || validateSteps(conf);
}
function loadPlugin({cwd}, name, pluginsPath) {
export async function loadPlugin({ cwd }, name, pluginsPath) {
const basePath = pluginsPath[name]
? dirname(resolveFrom.silent(__dirname, pluginsPath[name]) || resolveFrom(cwd, pluginsPath[name]))
: __dirname;
return isFunction(name) ? name : require(resolveFrom.silent(basePath, name) || resolveFrom(cwd, name));
if (isFunction(name)) {
return name;
}
const file = resolveFrom.silent(basePath, name) || resolveFrom(cwd, name);
const { default: cjsExport, ...esmNamedExports } = await import(`file://${file}`);
if (cjsExport) {
return cjsExport;
}
return esmNamedExports;
}
function parseConfig(plugin) {
export function parseConfig(plugin) {
let path;
let config;
if (isArray(plugin)) {
[path, config] = plugin;
} else if (isPlainObject(plugin) && !isNil(plugin.path)) {
({path, ...config} = plugin);
({ path, ...config } = plugin);
} else {
path = plugin;
}
return [path, config || {}];
}
module.exports = {validatePlugin, validateStep, loadPlugin, parseConfig};
+26 -44
View File
@@ -1,12 +1,12 @@
const {isFunction, union, template} = require('lodash');
const semver = require('semver');
const hideSensitive = require('./hide-sensitive');
import { isFunction, template, union } from "lodash-es";
import semver from "semver";
import hideSensitive from "./hide-sensitive.js";
function extractErrors(err) {
return err && isFunction(err[Symbol.iterator]) ? [...err] : [err];
export function extractErrors(err) {
return err && err.errors ? [...err.errors] : [err];
}
function hideSensitiveValues(env, objs) {
export function hideSensitiveValues(env, objs) {
const hideFunction = hideSensitive(env);
return objs.map((object) => {
Object.getOwnPropertyNames(object).forEach((prop) => {
@@ -18,51 +18,51 @@ function hideSensitiveValues(env, objs) {
});
}
function tagsToVersions(tags) {
return tags.map(({version}) => version);
export function tagsToVersions(tags) {
return tags.map(({ version }) => version);
}
function isMajorRange(range) {
export function isMajorRange(range) {
return /^\d+\.x(?:\.x)?$/i.test(range);
}
function isMaintenanceRange(range) {
export function isMaintenanceRange(range) {
return /^\d+\.(?:\d+|x)(?:\.x)?$/i.test(range);
}
function getUpperBound(range) {
export function getUpperBound(range) {
const result = semver.valid(range)
? range
: ((semver.validRange(range) || '').match(/<(?<upperBound>\d+\.\d+\.\d+(-\d+)?)$/) || [])[1];
: ((semver.validRange(range) || "").match(/<(?<upperBound>\d+\.\d+\.\d+(-\d+)?)$/) || [])[1];
return result
? // https://github.com/npm/node-semver/issues/322
result.replace(/-\d+$/, '')
result.replace(/-\d+$/, "")
: result;
}
function getLowerBound(range) {
return ((semver.validRange(range) || '').match(/(?<lowerBound>\d+\.\d+\.\d+)/) || [])[1];
export function getLowerBound(range) {
return ((semver.validRange(range) || "").match(/(?<lowerBound>\d+\.\d+\.\d+)/) || [])[1];
}
function highest(version1, version2) {
export function highest(version1, version2) {
return version1 && version2 ? (semver.gt(version1, version2) ? version1 : version2) : version1 || version2;
}
function lowest(version1, version2) {
export function lowest(version1, version2) {
return version1 && version2 ? (semver.lt(version1, version2) ? version1 : version2) : version1 || version2;
}
function getLatestVersion(versions, {withPrerelease} = {}) {
export function getLatestVersion(versions, { withPrerelease } = {}) {
return versions.filter((version) => withPrerelease || !semver.prerelease(version)).sort(semver.rcompare)[0];
}
function getEarliestVersion(versions, {withPrerelease} = {}) {
export function getEarliestVersion(versions, { withPrerelease } = {}) {
return versions.filter((version) => withPrerelease || !semver.prerelease(version)).sort(semver.compare)[0];
}
function getFirstVersion(versions, lowerBranches) {
const lowerVersion = union(...lowerBranches.map(({tags}) => tagsToVersions(tags))).sort(semver.rcompare);
export function getFirstVersion(versions, lowerBranches) {
const lowerVersion = union(...lowerBranches.map(({ tags }) => tagsToVersions(tags))).sort(semver.rcompare);
if (lowerVersion[0]) {
return versions.sort(semver.compare).find((version) => semver.gt(version, lowerVersion[0]));
}
@@ -70,32 +70,14 @@ function getFirstVersion(versions, lowerBranches) {
return getEarliestVersion(versions);
}
function getRange(min, max) {
return `>=${min}${max ? ` <${max}` : ''}`;
export function getRange(min, max) {
return `>=${min}${max ? ` <${max}` : ""}`;
}
function makeTag(tagFormat, version) {
return template(tagFormat)({version});
export function makeTag(tagFormat, version) {
return template(tagFormat)({ version });
}
function isSameChannel(channel, otherChannel) {
export function isSameChannel(channel, otherChannel) {
return channel === otherChannel || (!channel && !otherChannel);
}
module.exports = {
extractErrors,
hideSensitiveValues,
tagsToVersions,
isMajorRange,
isMaintenanceRange,
getUpperBound,
getLowerBound,
highest,
lowest,
getLatestVersion,
getEarliestVersion,
getFirstVersion,
getRange,
makeTag,
isSameChannel,
};
+14 -14
View File
@@ -1,39 +1,39 @@
const {template, isString, isPlainObject} = require('lodash');
const AggregateError = require('aggregate-error');
const {isGitRepo, verifyTagName} = require('./git');
const getError = require('./get-error');
import { isPlainObject, isString, template } from "lodash-es";
import AggregateError from "aggregate-error";
import { isGitRepo, verifyTagName } from "./git.js";
import getError from "./get-error.js";
module.exports = async (context) => {
export default async (context) => {
const {
cwd,
env,
options: {repositoryUrl, tagFormat, branches},
options: { repositoryUrl, tagFormat, branches },
} = context;
const errors = [];
if (!(await isGitRepo({cwd, env}))) {
errors.push(getError('ENOGITREPO', {cwd}));
if (!(await isGitRepo({ cwd, env }))) {
errors.push(getError("ENOGITREPO", { cwd }));
} else if (!repositoryUrl) {
errors.push(getError('ENOREPOURL'));
errors.push(getError("ENOREPOURL"));
}
// Verify that compiling the `tagFormat` produce a valid Git tag
if (!(await verifyTagName(template(tagFormat)({version: '0.0.0'})))) {
errors.push(getError('EINVALIDTAGFORMAT', context));
if (!(await verifyTagName(template(tagFormat)({ version: "0.0.0" })))) {
errors.push(getError("EINVALIDTAGFORMAT", context));
}
// Verify the `tagFormat` contains the variable `version` by compiling the `tagFormat` template
// with a space as the `version` value and verify the result contains the space.
// The space is used as it's an invalid tag character, so it's guaranteed to no be present in the `tagFormat`.
if ((template(tagFormat)({version: ' '}).match(/ /g) || []).length !== 1) {
errors.push(getError('ETAGNOVERSION', context));
if ((template(tagFormat)({ version: " " }).match(/ /g) || []).length !== 1) {
errors.push(getError("ETAGNOVERSION", context));
}
branches.forEach((branch) => {
if (
!((isString(branch) && branch.trim()) || (isPlainObject(branch) && isString(branch.name) && branch.name.trim()))
) {
errors.push(getError('EINVALIDBRANCH', {branch}));
errors.push(getError("EINVALIDBRANCH", { branch }));
}
});
+15744
View File
File diff suppressed because it is too large Load Diff
+58 -52
View File
@@ -2,11 +2,16 @@
"name": "semantic-release",
"description": "Automated semver compliant package publishing",
"version": "0.0.0-development",
"type": "module",
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
"ava": {
"files": [
"test/**/*.test.js"
],
"nodeArguments": [
"--loader=testdouble",
"--no-warnings"
],
"timeout": "2m"
},
"bin": {
@@ -17,60 +22,60 @@
},
"contributors": [
"Gregor Martynus (https://twitter.com/gr2m)",
"Pierre Vanduynslager (https://twitter.com/@pvdlg_)"
"Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
"Matt Travi <npm@travi.org> (https://matt.travi.org/)"
],
"dependencies": {
"@semantic-release/commit-analyzer": "^8.0.0",
"@semantic-release/error": "^2.2.0",
"@semantic-release/github": "^7.0.0",
"@semantic-release/npm": "^7.0.0",
"@semantic-release/release-notes-generator": "^9.0.0",
"aggregate-error": "^3.0.0",
"cosmiconfig": "^6.0.0",
"@semantic-release/commit-analyzer": "^10.0.0",
"@semantic-release/error": "^4.0.0",
"@semantic-release/github": "^9.0.0",
"@semantic-release/npm": "^10.0.2",
"@semantic-release/release-notes-generator": "^11.0.0",
"aggregate-error": "^4.0.1",
"cosmiconfig": "^8.0.0",
"debug": "^4.0.0",
"env-ci": "^5.0.0",
"execa": "^4.0.0",
"figures": "^3.0.0",
"find-versions": "^4.0.0",
"get-stream": "^5.0.0",
"env-ci": "^9.0.0",
"execa": "^7.0.0",
"figures": "^5.0.0",
"find-versions": "^5.1.0",
"get-stream": "^6.0.0",
"git-log-parser": "^1.2.0",
"hook-std": "^2.0.0",
"hosted-git-info": "^3.0.0",
"lodash": "^4.17.15",
"marked": "^1.0.0",
"marked-terminal": "^4.0.0",
"hook-std": "^3.0.0",
"hosted-git-info": "^6.0.0",
"lodash-es": "^4.17.21",
"marked": "^4.1.0",
"marked-terminal": "^5.1.1",
"micromatch": "^4.0.2",
"p-each-series": "^2.1.0",
"p-reduce": "^2.0.0",
"read-pkg-up": "^7.0.0",
"p-each-series": "^3.0.0",
"p-reduce": "^3.0.0",
"read-pkg-up": "^9.1.0",
"resolve-from": "^5.0.0",
"semver": "^7.3.2",
"semver-diff": "^3.1.1",
"semver-diff": "^4.0.0",
"signale": "^1.2.1",
"yargs": "^15.0.1"
"yargs": "^17.5.1"
},
"devDependencies": {
"ava": "^3.1.0",
"clear-module": "^4.0.0",
"codecov": "^3.0.0",
"delay": "^4.0.0",
"dockerode": "^3.0.0",
"file-url": "^3.0.0",
"fs-extra": "^9.0.0",
"got": "^11.0.0",
"js-yaml": "^3.10.0",
"mockserver-client": "^5.1.1",
"nock": "^12.0.0",
"nyc": "^15.0.0",
"p-retry": "^4.0.0",
"proxyquire": "^2.0.0",
"sinon": "^9.0.0",
"stream-buffers": "^3.0.2",
"tempy": "^0.5.0",
"xo": "^0.29.0"
"ava": "5.3.0",
"c8": "7.14.0",
"clear-module": "4.1.2",
"codecov": "3.8.3",
"dockerode": "3.3.5",
"file-url": "4.0.0",
"fs-extra": "11.1.1",
"got": "13.0.0",
"js-yaml": "4.1.0",
"mockserver-client": "5.15.0",
"nock": "13.3.1",
"p-retry": "5.1.2",
"prettier": "2.8.8",
"sinon": "15.1.0",
"stream-buffers": "3.0.2",
"tempy": "3.0.0",
"testdouble": "3.18.0"
},
"engines": {
"node": ">=10.18"
"node": ">=18"
},
"files": [
"bin",
@@ -93,7 +98,7 @@
],
"license": "MIT",
"main": "index.js",
"nyc": {
"c8": {
"include": [
"lib/**/*.js",
"index.js",
@@ -111,7 +116,8 @@
"trailingComma": "es5"
},
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
@@ -119,16 +125,16 @@
},
"scripts": {
"codecov": "codecov -f coverage/coverage-final.json",
"lint": "xo",
"lint": "prettier --check \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"docs/**/*.md\" \"{bin,lib,test}/**/*.js\"",
"lint:fix": "prettier --write \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"docs/**/*.md\" \"{bin,lib,test}/**/*.js\"",
"pretest": "npm run lint",
"semantic-release": "./bin/semantic-release.js",
"test": "nyc ava -v"
"test": "c8 ava --verbose",
"test:ci": "c8 ava --verbose"
},
"xo": {
"prettier": true,
"space": true,
"rules": {
"unicorn/string-content": "off"
}
"renovate": {
"extends": [
"github>semantic-release/.github"
]
}
}
+238 -220
View File
@@ -1,259 +1,277 @@
const test = require('ava');
const {union} = require('lodash');
const semver = require('semver');
const proxyquire = require('proxyquire');
import test from "ava";
import { union } from "lodash-es";
import semver from "semver";
import * as td from "testdouble";
const getBranch = (branches, branch) => branches.find(({name}) => name === branch);
const release = (branches, name, version) => getBranch(branches, name).tags.push({version});
const getBranch = (branches, branch) => branches.find(({ name }) => name === branch);
const release = (branches, name, version) => getBranch(branches, name).tags.push({ version });
const merge = (branches, source, target, tag) => {
getBranch(branches, target).tags = union(
getBranch(branches, source).tags.filter(({version}) => !tag || semver.cmp(version, '<=', tag)),
getBranch(branches, source).tags.filter(({ version }) => !tag || semver.cmp(version, "<=", tag)),
getBranch(branches, target).tags
);
};
const remoteBranches = [];
const repositoryUrl = "repositoryUrl";
let expand, getTags, getBranches;
test('Enforce ranges with branching release workflow', async (t) => {
const branches = [
{name: '1.x', tags: []},
{name: '1.0.x', tags: []},
{name: 'master', tags: []},
{name: 'next', tags: []},
{name: 'next-major', tags: []},
{name: 'beta', prerelease: true, tags: []},
{name: 'alpha', prerelease: true, tags: []},
];
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
let result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, '1.0.x').range, '>=1.0.0 <1.0.0', 'Cannot release on 1.0.x before a releasing on master');
t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.0', 'Cannot release on 1.x before a releasing on master');
t.is(getBranch(result, 'master').range, '>=1.0.0');
t.is(getBranch(result, 'next').range, '>=1.0.0');
t.is(getBranch(result, 'next-major').range, '>=1.0.0');
release(branches, 'master', '1.0.0');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, '1.0.x').range, '>=1.0.0 <1.0.0', 'Cannot release on 1.0.x before a releasing on master');
t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.0', 'Cannot release on 1.x before a releasing on master');
t.is(getBranch(result, 'master').range, '>=1.0.0');
t.is(getBranch(result, 'next').range, '>=1.0.0');
t.is(getBranch(result, 'next-major').range, '>=1.0.0');
release(branches, 'master', '1.0.1');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.0.1', 'Can release only > than 1.0.1 on master');
t.is(getBranch(result, 'next').range, '>=1.0.1', 'Can release only > than 1.0.1 on next');
t.is(getBranch(result, 'next-major').range, '>=1.0.1', 'Can release only > than 1.0.1 on next-major');
merge(branches, 'master', 'next');
merge(branches, 'master', 'next-major');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.0.1', 'Can release only > than 1.0.1 on master');
t.is(getBranch(result, 'next').range, '>=1.0.1', 'Can release only > than 1.0.1 on next');
t.is(getBranch(result, 'next-major').range, '>=1.0.1', 'Can release only > than 1.0.1 on next-major');
release(branches, 'next', '1.1.0');
release(branches, 'next', '1.1.1');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.0.1 <1.1.0', 'Can release only patch, > than 1.0.1 on master');
t.is(getBranch(result, 'next').range, '>=1.1.1', 'Can release only > than 1.1.1 on next');
t.is(getBranch(result, 'next-major').range, '>=1.1.1', 'Can release > than 1.1.1 on next-major');
release(branches, 'next-major', '2.0.0');
release(branches, 'next-major', '2.0.1');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.0.1 <1.1.0', 'Can release only patch, > than 1.0.1 on master');
t.is(getBranch(result, 'next').range, '>=1.1.1 <2.0.0', 'Can release only patch or minor, > than 1.1.0 on next');
t.is(getBranch(result, 'next-major').range, '>=2.0.1', 'Can release any version, > than 2.0.1 on next-major');
merge(branches, 'next-major', 'beta');
release(branches, 'beta', '3.0.0-beta.1');
merge(branches, 'beta', 'alpha');
release(branches, 'alpha', '4.0.0-alpha.1');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'next-major').range, '>=2.0.1', 'Can release any version, > than 2.0.1 on next-major');
merge(branches, 'master', '1.0.x');
merge(branches, 'master', '1.x');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.0.1 <1.1.0', 'Can release only patch, > than 1.0.1 on master');
t.is(
getBranch(result, '1.0.x').range,
'>=1.0.1 <1.0.1',
'Cannot release on 1.0.x before >= 1.1.0 is released on master'
);
t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.1', 'Cannot release on 1.x before >= 1.2.0 is released on master');
release(branches, 'master', '1.0.2');
release(branches, 'master', '1.0.3');
release(branches, 'master', '1.0.4');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.0.4 <1.1.0', 'Can release only patch, > than 1.0.4 on master');
t.is(
getBranch(result, '1.0.x').range,
'>=1.0.1 <1.0.2',
'Cannot release on 1.0.x before >= 1.1.0 is released on master'
);
t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.2', 'Cannot release on 1.x before >= 1.2.0 is released on master');
merge(branches, 'next', 'master');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.1.1', 'Can release only > than 1.1.1 on master');
t.is(getBranch(result, 'next').range, '>=1.1.1 <2.0.0', 'Can release only patch or minor, > than 1.1.1 on next');
t.is(getBranch(result, 'next-major').range, '>=2.0.1', 'Can release any version, > than 2.0.1 on next-major');
t.is(
getBranch(result, '1.0.x').range,
'>=1.0.1 <1.0.2',
'Cannot release on 1.0.x before 1.0.x version from master are merged'
);
t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.2', 'Cannot release on 1.x before >= 2.0.0 is released on master');
merge(branches, 'master', '1.0.x', '1.0.4');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.1.1', 'Can release only > than 1.1.1 on master');
t.is(getBranch(result, '1.0.x').range, '>=1.0.4 <1.1.0', 'Can release on 1.0.x only within range');
t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.1.0', 'Cannot release on 1.x before >= 2.0.0 is released on master');
merge(branches, 'master', '1.x');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=1.1.1', 'Can release only > than 1.1.1 on master');
t.is(getBranch(result, '1.0.x').range, '>=1.0.4 <1.1.0', 'Can release on 1.0.x only within range');
t.is(getBranch(result, '1.x').range, '>=1.1.1 <1.1.1', 'Cannot release on 1.x before >= 2.0.0 is released on master');
merge(branches, 'next-major', 'next');
merge(branches, 'next', 'master');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=2.0.1', 'Can release only > than 2.0.1 on master');
t.is(getBranch(result, 'next').range, '>=2.0.1', 'Can release only > than 2.0.1 on next');
t.is(getBranch(result, 'next-major').range, '>=2.0.1', 'Can release only > than 2.0.1 on next-major');
t.is(getBranch(result, '1.x').range, '>=1.1.1 <2.0.0', 'Can release on 1.x only within range');
merge(branches, 'beta', 'master');
release(branches, 'master', '3.0.0');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, 'master').range, '>=3.0.0', 'Can release only > than 3.0.0 on master');
t.is(getBranch(result, 'next').range, '>=3.0.0', 'Can release only > than 3.0.0 on next');
t.is(getBranch(result, 'next-major').range, '>=3.0.0', 'Can release only > than 3.0.0 on next-major');
branches.push({name: '1.1.x', tags: []});
merge(branches, '1.x', '1.1.x');
result = (await getBranches('repositoryUrl', 'master', {options: {branches}})).map(({name, range}) => ({
name,
range,
}));
t.is(getBranch(result, '1.0.x').range, '>=1.0.4 <1.1.0', 'Can release on 1.0.x only within range');
t.is(getBranch(result, '1.1.x').range, '>=1.1.1 <1.2.0', 'Can release on 1.1.x only within range');
t.is(getBranch(result, '1.x').range, '>=1.2.0 <2.0.0', 'Can release on 1.x only within range');
test.beforeEach(async (t) => {
getTags = (await td.replaceEsm("../../lib/branches/get-tags.js")).default;
expand = (await td.replaceEsm("../../lib/branches/expand.js")).default;
getBranches = (await import("../../lib/branches/index.js")).default;
});
test('Throw SemanticReleaseError for invalid configurations', async (t) => {
const branches = [
{name: '123', range: '123', tags: []},
{name: '1.x', tags: []},
{name: 'maintenance-1', range: '1.x', tags: []},
{name: '1.x.x', tags: []},
{name: 'beta', prerelease: '', tags: []},
{name: 'alpha', prerelease: 'alpha', tags: []},
{name: 'preview', prerelease: 'alpha', tags: []},
];
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
const errors = [...(await t.throwsAsync(getBranches('repositoryUrl', 'master', {options: {branches}})))];
test.afterEach.always((t) => {
td.reset();
});
t.is(errors[0].name, 'SemanticReleaseError');
t.is(errors[0].code, 'EMAINTENANCEBRANCH');
test.serial("Enforce ranges with branching release workflow", async (t) => {
const branches = [
{ name: "1.x", tags: [] },
{ name: "1.0.x", tags: [] },
{ name: "master", tags: [] },
{ name: "next", tags: [] },
{ name: "next-major", tags: [] },
{ name: "beta", prerelease: true, tags: [] },
{ name: "alpha", prerelease: true, tags: [] },
];
const context = { options: { branches } };
td.when(expand(repositoryUrl, context, branches)).thenResolve(remoteBranches);
td.when(getTags(context, remoteBranches)).thenResolve(branches);
let result = (await getBranches(repositoryUrl, "master", context)).map(({ name, range }) => ({ name, range }));
t.is(getBranch(result, "1.0.x").range, ">=1.0.0 <1.0.0", "Cannot release on 1.0.x before a releasing on master");
t.is(getBranch(result, "1.x").range, ">=1.1.0 <1.0.0", "Cannot release on 1.x before a releasing on master");
t.is(getBranch(result, "master").range, ">=1.0.0");
t.is(getBranch(result, "next").range, ">=1.0.0");
t.is(getBranch(result, "next-major").range, ">=1.0.0");
release(branches, "master", "1.0.0");
result = (await getBranches("repositoryUrl", "master", context)).map(({ name, range }) => ({ name, range }));
t.is(getBranch(result, "1.0.x").range, ">=1.0.0 <1.0.0", "Cannot release on 1.0.x before a releasing on master");
t.is(getBranch(result, "1.x").range, ">=1.1.0 <1.0.0", "Cannot release on 1.x before a releasing on master");
t.is(getBranch(result, "master").range, ">=1.0.0");
t.is(getBranch(result, "next").range, ">=1.0.0");
t.is(getBranch(result, "next-major").range, ">=1.0.0");
release(branches, "master", "1.0.1");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.0.1", "Can release only > than 1.0.1 on master");
t.is(getBranch(result, "next").range, ">=1.0.1", "Can release only > than 1.0.1 on next");
t.is(getBranch(result, "next-major").range, ">=1.0.1", "Can release only > than 1.0.1 on next-major");
merge(branches, "master", "next");
merge(branches, "master", "next-major");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.0.1", "Can release only > than 1.0.1 on master");
t.is(getBranch(result, "next").range, ">=1.0.1", "Can release only > than 1.0.1 on next");
t.is(getBranch(result, "next-major").range, ">=1.0.1", "Can release only > than 1.0.1 on next-major");
release(branches, "next", "1.1.0");
release(branches, "next", "1.1.1");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.0.1 <1.1.0", "Can release only patch, > than 1.0.1 on master");
t.is(getBranch(result, "next").range, ">=1.1.1", "Can release only > than 1.1.1 on next");
t.is(getBranch(result, "next-major").range, ">=1.1.1", "Can release > than 1.1.1 on next-major");
release(branches, "next-major", "2.0.0");
release(branches, "next-major", "2.0.1");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.0.1 <1.1.0", "Can release only patch, > than 1.0.1 on master");
t.is(getBranch(result, "next").range, ">=1.1.1 <2.0.0", "Can release only patch or minor, > than 1.1.0 on next");
t.is(getBranch(result, "next-major").range, ">=2.0.1", "Can release any version, > than 2.0.1 on next-major");
merge(branches, "next-major", "beta");
release(branches, "beta", "3.0.0-beta.1");
merge(branches, "beta", "alpha");
release(branches, "alpha", "4.0.0-alpha.1");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "next-major").range, ">=2.0.1", "Can release any version, > than 2.0.1 on next-major");
merge(branches, "master", "1.0.x");
merge(branches, "master", "1.x");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.0.1 <1.1.0", "Can release only patch, > than 1.0.1 on master");
t.is(
getBranch(result, "1.0.x").range,
">=1.0.1 <1.0.1",
"Cannot release on 1.0.x before >= 1.1.0 is released on master"
);
t.is(getBranch(result, "1.x").range, ">=1.1.0 <1.0.1", "Cannot release on 1.x before >= 1.2.0 is released on master");
release(branches, "master", "1.0.2");
release(branches, "master", "1.0.3");
release(branches, "master", "1.0.4");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.0.4 <1.1.0", "Can release only patch, > than 1.0.4 on master");
t.is(
getBranch(result, "1.0.x").range,
">=1.0.1 <1.0.2",
"Cannot release on 1.0.x before >= 1.1.0 is released on master"
);
t.is(getBranch(result, "1.x").range, ">=1.1.0 <1.0.2", "Cannot release on 1.x before >= 1.2.0 is released on master");
merge(branches, "next", "master");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.1.1", "Can release only > than 1.1.1 on master");
t.is(getBranch(result, "next").range, ">=1.1.1 <2.0.0", "Can release only patch or minor, > than 1.1.1 on next");
t.is(getBranch(result, "next-major").range, ">=2.0.1", "Can release any version, > than 2.0.1 on next-major");
t.is(
getBranch(result, "1.0.x").range,
">=1.0.1 <1.0.2",
"Cannot release on 1.0.x before 1.0.x version from master are merged"
);
t.is(getBranch(result, "1.x").range, ">=1.1.0 <1.0.2", "Cannot release on 1.x before >= 2.0.0 is released on master");
merge(branches, "master", "1.0.x", "1.0.4");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.1.1", "Can release only > than 1.1.1 on master");
t.is(getBranch(result, "1.0.x").range, ">=1.0.4 <1.1.0", "Can release on 1.0.x only within range");
t.is(getBranch(result, "1.x").range, ">=1.1.0 <1.1.0", "Cannot release on 1.x before >= 2.0.0 is released on master");
merge(branches, "master", "1.x");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=1.1.1", "Can release only > than 1.1.1 on master");
t.is(getBranch(result, "1.0.x").range, ">=1.0.4 <1.1.0", "Can release on 1.0.x only within range");
t.is(getBranch(result, "1.x").range, ">=1.1.1 <1.1.1", "Cannot release on 1.x before >= 2.0.0 is released on master");
merge(branches, "next-major", "next");
merge(branches, "next", "master");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=2.0.1", "Can release only > than 2.0.1 on master");
t.is(getBranch(result, "next").range, ">=2.0.1", "Can release only > than 2.0.1 on next");
t.is(getBranch(result, "next-major").range, ">=2.0.1", "Can release only > than 2.0.1 on next-major");
t.is(getBranch(result, "1.x").range, ">=1.1.1 <2.0.0", "Can release on 1.x only within range");
merge(branches, "beta", "master");
release(branches, "master", "3.0.0");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "master").range, ">=3.0.0", "Can release only > than 3.0.0 on master");
t.is(getBranch(result, "next").range, ">=3.0.0", "Can release only > than 3.0.0 on next");
t.is(getBranch(result, "next-major").range, ">=3.0.0", "Can release only > than 3.0.0 on next-major");
branches.push({ name: "1.1.x", tags: [] });
merge(branches, "1.x", "1.1.x");
result = (await getBranches("repositoryUrl", "master", { options: { branches } })).map(({ name, range }) => ({
name,
range,
}));
t.is(getBranch(result, "1.0.x").range, ">=1.0.4 <1.1.0", "Can release on 1.0.x only within range");
t.is(getBranch(result, "1.1.x").range, ">=1.1.1 <1.2.0", "Can release on 1.1.x only within range");
t.is(getBranch(result, "1.x").range, ">=1.2.0 <2.0.0", "Can release on 1.x only within range");
});
test.serial("Throw SemanticReleaseError for invalid configurations", async (t) => {
const branches = [
{ name: "123", range: "123", tags: [] },
{ name: "1.x", tags: [] },
{ name: "maintenance-1", range: "1.x", tags: [] },
{ name: "1.x.x", tags: [] },
{ name: "beta", prerelease: "", tags: [] },
{ name: "alpha", prerelease: "alpha", tags: [] },
{ name: "preview", prerelease: "alpha", tags: [] },
];
const context = { options: { branches } };
td.when(expand(repositoryUrl, context, branches)).thenResolve(remoteBranches);
td.when(getTags(context, remoteBranches)).thenResolve(branches);
const error = await t.throwsAsync(getBranches(repositoryUrl, "master", context));
const errors = [...error.errors];
t.is(errors[0].name, "SemanticReleaseError");
t.is(errors[0].code, "EMAINTENANCEBRANCH");
t.truthy(errors[0].message);
t.truthy(errors[0].details);
t.is(errors[1].name, 'SemanticReleaseError');
t.is(errors[1].code, 'EMAINTENANCEBRANCHES');
t.is(errors[1].name, "SemanticReleaseError");
t.is(errors[1].code, "EMAINTENANCEBRANCHES");
t.truthy(errors[1].message);
t.truthy(errors[1].details);
t.is(errors[2].name, 'SemanticReleaseError');
t.is(errors[2].code, 'EPRERELEASEBRANCH');
t.is(errors[2].name, "SemanticReleaseError");
t.is(errors[2].code, "EPRERELEASEBRANCH");
t.truthy(errors[2].message);
t.truthy(errors[2].details);
t.is(errors[3].name, 'SemanticReleaseError');
t.is(errors[3].code, 'EPRERELEASEBRANCHES');
t.is(errors[3].name, "SemanticReleaseError");
t.is(errors[3].code, "EPRERELEASEBRANCHES");
t.truthy(errors[3].message);
t.truthy(errors[3].details);
t.is(errors[4].name, 'SemanticReleaseError');
t.is(errors[4].code, 'ERELEASEBRANCHES');
t.is(errors[4].name, "SemanticReleaseError");
t.is(errors[4].code, "ERELEASEBRANCHES");
t.truthy(errors[4].message);
t.truthy(errors[4].details);
});
test('Throw a SemanticReleaseError if there is duplicate branches', async (t) => {
test.serial("Throw a SemanticReleaseError if there is duplicate branches", async (t) => {
const branches = [
{name: 'master', tags: []},
{name: 'master', tags: []},
{ name: "master", tags: [] },
{ name: "master", tags: [] },
];
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
const context = { options: { branches } };
td.when(expand(repositoryUrl, context, branches)).thenResolve(remoteBranches);
td.when(getTags(context, remoteBranches)).thenResolve(branches);
const errors = [...(await t.throwsAsync(getBranches('repositoryUrl', 'master', {options: {branches}})))];
const errors = [...(await t.throwsAsync(getBranches(repositoryUrl, "master", context))).errors];
t.is(errors[0].name, 'SemanticReleaseError');
t.is(errors[0].code, 'EDUPLICATEBRANCHES');
t.is(errors[0].name, "SemanticReleaseError");
t.is(errors[0].code, "EDUPLICATEBRANCHES");
t.truthy(errors[0].message);
t.truthy(errors[0].details);
});
test('Throw a SemanticReleaseError for each invalid branch name', async (t) => {
test.serial("Throw a SemanticReleaseError for each invalid branch name", async (t) => {
const branches = [
{name: '~master', tags: []},
{name: '^master', tags: []},
{ name: "~master", tags: [] },
{ name: "^master", tags: [] },
];
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
const context = { options: { branches } };
const remoteBranches = [];
td.when(expand(repositoryUrl, context, branches)).thenResolve(remoteBranches);
td.when(getTags(context, remoteBranches)).thenResolve(branches);
const errors = [...(await t.throwsAsync(getBranches('repositoryUrl', 'master', {options: {branches}})))];
const errors = [...(await t.throwsAsync(getBranches(repositoryUrl, "master", context))).errors];
t.is(errors[0].name, 'SemanticReleaseError');
t.is(errors[0].code, 'EINVALIDBRANCHNAME');
t.is(errors[0].name, "SemanticReleaseError");
t.is(errors[0].code, "EINVALIDBRANCHNAME");
t.truthy(errors[0].message);
t.truthy(errors[0].details);
t.is(errors[1].name, 'SemanticReleaseError');
t.is(errors[1].code, 'EINVALIDBRANCHNAME');
t.is(errors[1].name, "SemanticReleaseError");
t.is(errors[1].code, "EINVALIDBRANCHNAME");
t.truthy(errors[1].message);
t.truthy(errors[1].details);
});
+44 -44
View File
@@ -1,54 +1,54 @@
const test = require('ava');
const expand = require('../../lib/branches/expand');
const {gitRepo, gitCommits, gitCheckout, gitPush} = require('../helpers/git-utils');
import test from "ava";
import expand from "../../lib/branches/expand.js";
import { gitCheckout, gitCommits, gitPush, gitRepo } from "../helpers/git-utils.js";
test('Expand branches defined with globs', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['First'], {cwd});
await gitPush(repositoryUrl, 'master', {cwd});
await gitCheckout('1.0.x', true, {cwd});
await gitCommits(['Second'], {cwd});
await gitPush(repositoryUrl, '1.0.x', {cwd});
await gitCheckout('1.x.x', true, {cwd});
await gitCommits(['Third'], {cwd});
await gitPush(repositoryUrl, '1.x.x', {cwd});
await gitCheckout('2.x', true, {cwd});
await gitCommits(['Fourth'], {cwd});
await gitPush(repositoryUrl, '2.x', {cwd});
await gitCheckout('next', true, {cwd});
await gitCommits(['Fifth'], {cwd});
await gitPush(repositoryUrl, 'next', {cwd});
await gitCheckout('pre/foo', true, {cwd});
await gitCommits(['Sixth'], {cwd});
await gitPush(repositoryUrl, 'pre/foo', {cwd});
await gitCheckout('pre/bar', true, {cwd});
await gitCommits(['Seventh'], {cwd});
await gitPush(repositoryUrl, 'pre/bar', {cwd});
await gitCheckout('beta', true, {cwd});
await gitCommits(['Eighth'], {cwd});
await gitPush(repositoryUrl, 'beta', {cwd});
test("Expand branches defined with globs", async (t) => {
const { cwd, repositoryUrl } = await gitRepo(true);
await gitCommits(["First"], { cwd });
await gitPush(repositoryUrl, "master", { cwd });
await gitCheckout("1.0.x", true, { cwd });
await gitCommits(["Second"], { cwd });
await gitPush(repositoryUrl, "1.0.x", { cwd });
await gitCheckout("1.x.x", true, { cwd });
await gitCommits(["Third"], { cwd });
await gitPush(repositoryUrl, "1.x.x", { cwd });
await gitCheckout("2.x", true, { cwd });
await gitCommits(["Fourth"], { cwd });
await gitPush(repositoryUrl, "2.x", { cwd });
await gitCheckout("next", true, { cwd });
await gitCommits(["Fifth"], { cwd });
await gitPush(repositoryUrl, "next", { cwd });
await gitCheckout("pre/foo", true, { cwd });
await gitCommits(["Sixth"], { cwd });
await gitPush(repositoryUrl, "pre/foo", { cwd });
await gitCheckout("pre/bar", true, { cwd });
await gitCommits(["Seventh"], { cwd });
await gitPush(repositoryUrl, "pre/bar", { cwd });
await gitCheckout("beta", true, { cwd });
await gitCommits(["Eighth"], { cwd });
await gitPush(repositoryUrl, "beta", { cwd });
const branches = [
// Should match all maintenance type branches
{name: '+([0-9])?(.{+([0-9]),x}).x'},
{name: 'master', channel: 'latest'},
{name: 'next'},
{name: 'pre/{foo,bar}', channel: `\${name.replace(/^pre\\//g, '')}`, prerelease: true},
{ name: "+([0-9])?(.{+([0-9]),x}).x" },
{ name: "master", channel: "latest" },
{ name: "next" },
{ name: "pre/{foo,bar}", channel: `\${name.replace(/^pre\\//g, '')}`, prerelease: true },
// Should be ignored as there is no matching branches in the repo
{name: 'missing'},
{ name: "missing" },
// Should be ignored as the matching branch in the repo is already matched by `/^pre\\/(\\w+)$/gi`
{name: '*/foo', channel: 'foo', prerelease: 'foo'},
{name: 'beta', channel: `channel-\${name}`, prerelease: true},
{ name: "*/foo", channel: "foo", prerelease: "foo" },
{ name: "beta", channel: `channel-\${name}`, prerelease: true },
];
t.deepEqual(await expand(repositoryUrl, {cwd}, branches), [
{name: '1.0.x'},
{name: '1.x.x'},
{name: '2.x'},
{name: 'master', channel: 'latest'},
{name: 'next'},
{name: 'pre/bar', channel: 'bar', prerelease: true},
{name: 'pre/foo', channel: 'foo', prerelease: true},
{name: 'beta', channel: 'channel-beta', prerelease: true},
t.deepEqual(await expand(repositoryUrl, { cwd }, branches), [
{ name: "1.0.x" },
{ name: "1.x.x" },
{ name: "2.x" },
{ name: "master", channel: "latest" },
{ name: "next" },
{ name: "pre/bar", channel: "bar", prerelease: true },
{ name: "pre/foo", channel: "foo", prerelease: true },
{ name: "beta", channel: "channel-beta", prerelease: true },
]);
});
+100 -97
View File
@@ -1,153 +1,156 @@
const test = require('ava');
const getTags = require('../../lib/branches/get-tags');
const {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} = require('../helpers/git-utils');
import test from "ava";
import getTags from "../../lib/branches/get-tags.js";
import { gitAddNote, gitCheckout, gitCommits, gitRepo, gitTagVersion } from "../helpers/git-utils.js";
test('Get the valid tags', async (t) => {
const {cwd} = await gitRepo();
const commits = await gitCommits(['First'], {cwd});
await gitTagVersion('foo', undefined, {cwd});
await gitTagVersion('v2.0.0', undefined, {cwd});
commits.push(...(await gitCommits(['Second'], {cwd})));
await gitTagVersion('v1.0.0', undefined, {cwd});
commits.push(...(await gitCommits(['Third'], {cwd})));
await gitTagVersion('v3.0', undefined, {cwd});
commits.push(...(await gitCommits(['Fourth'], {cwd})));
await gitTagVersion('v3.0.0-beta.1', undefined, {cwd});
test("Get the valid tags", async (t) => {
const { cwd } = await gitRepo();
const commits = await gitCommits(["First"], { cwd });
await gitTagVersion("foo", undefined, { cwd });
await gitTagVersion("v2.0.0", undefined, { cwd });
commits.push(...(await gitCommits(["Second"], { cwd })));
await gitTagVersion("v1.0.0", undefined, { cwd });
commits.push(...(await gitCommits(["Third"], { cwd })));
await gitTagVersion("v3.0", undefined, { cwd });
commits.push(...(await gitCommits(["Fourth"], { cwd })));
await gitTagVersion("v3.0.0-beta.1", undefined, { cwd });
const result = await getTags({cwd, options: {tagFormat: `v\${version}`}}, [{name: 'master'}]);
const result = await getTags({ cwd, options: { tagFormat: `v\${version}` } }, [{ name: "master" }]);
t.deepEqual(result, [
{
name: 'master',
name: "master",
tags: [
{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]},
{gitTag: 'v2.0.0', version: '2.0.0', channels: [null]},
{gitTag: 'v3.0.0-beta.1', version: '3.0.0-beta.1', channels: [null]},
{ gitTag: "v1.0.0", version: "1.0.0", channels: [null] },
{ gitTag: "v2.0.0", version: "2.0.0", channels: [null] },
{ gitTag: "v3.0.0-beta.1", version: "3.0.0-beta.1", channels: [null] },
],
},
]);
});
test('Get the valid tags from multiple branches', async (t) => {
const {cwd} = await gitRepo();
await gitCommits(['First'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
await gitAddNote(JSON.stringify({channels: [null, '1.x']}), 'v1.0.0', {cwd});
await gitCommits(['Second'], {cwd});
await gitTagVersion('v1.1.0', undefined, {cwd});
await gitAddNote(JSON.stringify({channels: [null, '1.x']}), 'v1.1.0', {cwd});
await gitCheckout('1.x', true, {cwd});
await gitCheckout('master', false, {cwd});
await gitCommits(['Third'], {cwd});
await gitTagVersion('v2.0.0', undefined, {cwd});
await gitAddNote(JSON.stringify({channels: [null, 'next']}), 'v2.0.0', {cwd});
await gitCheckout('next', true, {cwd});
await gitCommits(['Fourth'], {cwd});
await gitTagVersion('v3.0.0', undefined, {cwd});
await gitAddNote(JSON.stringify({channels: ['next']}), 'v3.0.0', {cwd});
test("Get the valid tags from multiple branches", async (t) => {
const { cwd } = await gitRepo();
await gitCommits(["First"], { cwd });
await gitTagVersion("v1.0.0", undefined, { cwd });
await gitAddNote(JSON.stringify({ channels: [null, "1.x"] }), "v1.0.0", { cwd });
await gitCommits(["Second"], { cwd });
await gitTagVersion("v1.1.0", undefined, { cwd });
await gitAddNote(JSON.stringify({ channels: [null, "1.x"] }), "v1.1.0", { cwd });
await gitCheckout("1.x", true, { cwd });
await gitCheckout("master", false, { cwd });
await gitCommits(["Third"], { cwd });
await gitTagVersion("v2.0.0", undefined, { cwd });
await gitAddNote(JSON.stringify({ channels: [null, "next"] }), "v2.0.0", { cwd });
await gitCheckout("next", true, { cwd });
await gitCommits(["Fourth"], { cwd });
await gitTagVersion("v3.0.0", undefined, { cwd });
await gitAddNote(JSON.stringify({ channels: ["next"] }), "v3.0.0", { cwd });
const result = await getTags({cwd, options: {tagFormat: `v\${version}`}}, [
{name: '1.x'},
{name: 'master'},
{name: 'next'},
const result = await getTags({ cwd, options: { tagFormat: `v\${version}` } }, [
{ name: "1.x" },
{ name: "master" },
{ name: "next" },
]);
t.deepEqual(result, [
{
name: '1.x',
name: "1.x",
tags: [
{gitTag: 'v1.0.0', version: '1.0.0', channels: [null, '1.x']},
{gitTag: 'v1.1.0', version: '1.1.0', channels: [null, '1.x']},
{ gitTag: "v1.0.0", version: "1.0.0", channels: [null, "1.x"] },
{ gitTag: "v1.1.0", version: "1.1.0", channels: [null, "1.x"] },
],
},
{
name: 'master',
tags: [...result[0].tags, {gitTag: 'v2.0.0', version: '2.0.0', channels: [null, 'next']}],
name: "master",
tags: [...result[0].tags, { gitTag: "v2.0.0", version: "2.0.0", channels: [null, "next"] }],
},
{
name: 'next',
tags: [...result[1].tags, {gitTag: 'v3.0.0', version: '3.0.0', channels: ['next']}],
name: "next",
tags: [...result[1].tags, { gitTag: "v3.0.0", version: "3.0.0", channels: ["next"] }],
},
]);
});
test('Return branches with and empty tags array if no valid tag is found', async (t) => {
const {cwd} = await gitRepo();
await gitCommits(['First'], {cwd});
await gitTagVersion('foo', undefined, {cwd});
await gitCommits(['Second'], {cwd});
await gitTagVersion('v2.0.x', undefined, {cwd});
await gitCommits(['Third'], {cwd});
await gitTagVersion('v3.0', undefined, {cwd});
test("Return branches with and empty tags array if no valid tag is found", async (t) => {
const { cwd } = await gitRepo();
await gitCommits(["First"], { cwd });
await gitTagVersion("foo", undefined, { cwd });
await gitCommits(["Second"], { cwd });
await gitTagVersion("v2.0.x", undefined, { cwd });
await gitCommits(["Third"], { cwd });
await gitTagVersion("v3.0", undefined, { cwd });
const result = await getTags({cwd, options: {tagFormat: `prefix@v\${version}`}}, [{name: 'master'}]);
const result = await getTags({ cwd, options: { tagFormat: `prefix@v\${version}` } }, [{ name: "master" }]);
t.deepEqual(result, [{name: 'master', tags: []}]);
t.deepEqual(result, [{ name: "master", tags: [] }]);
});
test('Return branches with and empty tags array if no valid tag is found in history of configured branches', async (t) => {
const {cwd} = await gitRepo();
await gitCommits(['First'], {cwd});
await gitCheckout('next', true, {cwd});
await gitCommits(['Second'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
await gitAddNote(JSON.stringify({channels: [null, 'next']}), 'v1.0.0', {cwd});
await gitCommits(['Third'], {cwd});
await gitTagVersion('v2.0.0', undefined, {cwd});
await gitAddNote(JSON.stringify({channels: [null, 'next']}), 'v2.0.0', {cwd});
await gitCommits(['Fourth'], {cwd});
await gitTagVersion('v3.0.0', undefined, {cwd});
await gitAddNote(JSON.stringify({channels: [null, 'next']}), 'v3.0.0', {cwd});
await gitCheckout('master', false, {cwd});
test("Return branches with and empty tags array if no valid tag is found in history of configured branches", async (t) => {
const { cwd } = await gitRepo();
await gitCommits(["First"], { cwd });
await gitCheckout("next", true, { cwd });
await gitCommits(["Second"], { cwd });
await gitTagVersion("v1.0.0", undefined, { cwd });
await gitAddNote(JSON.stringify({ channels: [null, "next"] }), "v1.0.0", { cwd });
await gitCommits(["Third"], { cwd });
await gitTagVersion("v2.0.0", undefined, { cwd });
await gitAddNote(JSON.stringify({ channels: [null, "next"] }), "v2.0.0", { cwd });
await gitCommits(["Fourth"], { cwd });
await gitTagVersion("v3.0.0", undefined, { cwd });
await gitAddNote(JSON.stringify({ channels: [null, "next"] }), "v3.0.0", { cwd });
await gitCheckout("master", false, { cwd });
const result = await getTags({cwd, options: {tagFormat: `prefix@v\${version}`}}, [{name: 'master'}, {name: 'next'}]);
const result = await getTags({ cwd, options: { tagFormat: `prefix@v\${version}` } }, [
{ name: "master" },
{ name: "next" },
]);
t.deepEqual(result, [
{name: 'master', tags: []},
{name: 'next', tags: []},
{ name: "master", tags: [] },
{ name: "next", tags: [] },
]);
});
test('Get the highest valid tag corresponding to the "tagFormat"', async (t) => {
const {cwd} = await gitRepo();
await gitCommits(['First'], {cwd});
const { cwd } = await gitRepo();
await gitCommits(["First"], { cwd });
await gitTagVersion('1.0.0', undefined, {cwd});
t.deepEqual(await getTags({cwd, options: {tagFormat: `\${version}`}}, [{name: 'master'}]), [
{name: 'master', tags: [{gitTag: '1.0.0', version: '1.0.0', channels: [null]}]},
await gitTagVersion("1.0.0", undefined, { cwd });
t.deepEqual(await getTags({ cwd, options: { tagFormat: `\${version}` } }, [{ name: "master" }]), [
{ name: "master", tags: [{ gitTag: "1.0.0", version: "1.0.0", channels: [null] }] },
]);
await gitTagVersion('foo-1.0.0-bar', undefined, {cwd});
t.deepEqual(await getTags({cwd, options: {tagFormat: `foo-\${version}-bar`}}, [{name: 'master'}]), [
{name: 'master', tags: [{gitTag: 'foo-1.0.0-bar', version: '1.0.0', channels: [null]}]},
await gitTagVersion("foo-1.0.0-bar", undefined, { cwd });
t.deepEqual(await getTags({ cwd, options: { tagFormat: `foo-\${version}-bar` } }, [{ name: "master" }]), [
{ name: "master", tags: [{ gitTag: "foo-1.0.0-bar", version: "1.0.0", channels: [null] }] },
]);
await gitTagVersion('foo-v1.0.0-bar', undefined, {cwd});
t.deepEqual(await getTags({cwd, options: {tagFormat: `foo-v\${version}-bar`}}, [{name: 'master'}]), [
await gitTagVersion("foo-v1.0.0-bar", undefined, { cwd });
t.deepEqual(await getTags({ cwd, options: { tagFormat: `foo-v\${version}-bar` } }, [{ name: "master" }]), [
{
name: 'master',
tags: [{gitTag: 'foo-v1.0.0-bar', version: '1.0.0', channels: [null]}],
name: "master",
tags: [{ gitTag: "foo-v1.0.0-bar", version: "1.0.0", channels: [null] }],
},
]);
await gitTagVersion('(.+)/1.0.0/(a-z)', undefined, {cwd});
t.deepEqual(await getTags({cwd, options: {tagFormat: `(.+)/\${version}/(a-z)`}}, [{name: 'master'}]), [
await gitTagVersion("(.+)/1.0.0/(a-z)", undefined, { cwd });
t.deepEqual(await getTags({ cwd, options: { tagFormat: `(.+)/\${version}/(a-z)` } }, [{ name: "master" }]), [
{
name: 'master',
tags: [{gitTag: '(.+)/1.0.0/(a-z)', version: '1.0.0', channels: [null]}],
name: "master",
tags: [{ gitTag: "(.+)/1.0.0/(a-z)", version: "1.0.0", channels: [null] }],
},
]);
await gitTagVersion('2.0.0-1.0.0-bar.1', undefined, {cwd});
t.deepEqual(await getTags({cwd, options: {tagFormat: `2.0.0-\${version}-bar.1`}}, [{name: 'master'}]), [
await gitTagVersion("2.0.0-1.0.0-bar.1", undefined, { cwd });
t.deepEqual(await getTags({ cwd, options: { tagFormat: `2.0.0-\${version}-bar.1` } }, [{ name: "master" }]), [
{
name: 'master',
tags: [{gitTag: '2.0.0-1.0.0-bar.1', version: '1.0.0', channels: [null]}],
name: "master",
tags: [{ gitTag: "2.0.0-1.0.0-bar.1", version: "1.0.0", channels: [null] }],
},
]);
await gitTagVersion('3.0.0-bar.2', undefined, {cwd});
t.deepEqual(await getTags({cwd, options: {tagFormat: `\${version}-bar.2`}}, [{name: 'master'}]), [
{name: 'master', tags: [{gitTag: '3.0.0-bar.2', version: '3.0.0', channels: [null]}]},
await gitTagVersion("3.0.0-bar.2", undefined, { cwd });
t.deepEqual(await getTags({ cwd, options: { tagFormat: `\${version}-bar.2` } }, [{ name: "master" }]), [
{ name: "master", tags: [{ gitTag: "3.0.0-bar.2", version: "3.0.0", channels: [null] }] },
]);
});
+193 -191
View File
@@ -1,17 +1,17 @@
const test = require('ava');
const normalize = require('../../lib/branches/normalize');
import test from "ava";
import * as normalize from "../../lib/branches/normalize.js";
const toTags = (versions) => versions.map((version) => ({version}));
const toTags = (versions) => versions.map((version) => ({ version }));
test('Maintenance branches - initial state', (t) => {
test("Maintenance branches - initial state", (t) => {
const maintenance = [
{name: '1.x', channel: '1.x', tags: []},
{name: '1.1.x', tags: []},
{name: '1.2.x', tags: []},
{ name: "1.x", channel: "1.x", tags: [] },
{ name: "1.1.x", tags: [] },
{ name: "1.2.x", tags: [] },
];
const release = [{name: 'master', tags: []}];
const release = [{ name: "master", tags: [] }];
t.deepEqual(
normalize.maintenance({maintenance, release}).map(({type, name, range, accept, channel, mergeRange}) => ({
normalize.maintenance({ maintenance, release }).map(({ type, name, range, accept, channel, mergeRange }) => ({
type,
name,
range,
@@ -21,51 +21,51 @@ test('Maintenance branches - initial state', (t) => {
})),
[
{
type: 'maintenance',
name: '1.1.x',
range: '>=1.1.0 <1.0.0',
type: "maintenance",
name: "1.1.x",
range: ">=1.1.0 <1.0.0",
accept: [],
channel: '1.1.x',
mergeRange: '>=1.1.0 <1.2.0',
channel: "1.1.x",
mergeRange: ">=1.1.0 <1.2.0",
},
{
type: 'maintenance',
name: '1.2.x',
range: '>=1.2.0 <1.0.0',
type: "maintenance",
name: "1.2.x",
range: ">=1.2.0 <1.0.0",
accept: [],
channel: '1.2.x',
mergeRange: '>=1.2.0 <1.3.0',
channel: "1.2.x",
mergeRange: ">=1.2.0 <1.3.0",
},
{
type: 'maintenance',
name: '1.x',
range: '>=1.3.0 <1.0.0',
type: "maintenance",
name: "1.x",
range: ">=1.3.0 <1.0.0",
accept: [],
channel: '1.x',
mergeRange: '>=1.3.0 <2.0.0',
channel: "1.x",
mergeRange: ">=1.3.0 <2.0.0",
},
]
);
});
test('Maintenance branches - cap range to first release present on default branch and not in any Maintenance one', (t) => {
test("Maintenance branches - cap range to first release present on default branch and not in any Maintenance one", (t) => {
const maintenance = [
{name: '1.x', tags: toTags(['1.0.0', '1.1.0', '1.1.1', '1.2.0', '1.2.1', '1.3.0', '1.4.0', '1.5.0'])},
{name: 'name', range: '1.1.x', tags: toTags(['1.0.0', '1.0.1', '1.1.0', '1.1.1'])},
{name: '1.2.x', tags: toTags(['1.0.0', '1.1.0', '1.1.1', '1.2.0', '1.2.1'])},
{name: '2.x.x', tags: toTags(['1.0.0', '1.1.0', '1.1.1', '1.2.0', '1.2.1', '1.5.0'])},
{ name: "1.x", tags: toTags(["1.0.0", "1.1.0", "1.1.1", "1.2.0", "1.2.1", "1.3.0", "1.4.0", "1.5.0"]) },
{ name: "name", range: "1.1.x", tags: toTags(["1.0.0", "1.0.1", "1.1.0", "1.1.1"]) },
{ name: "1.2.x", tags: toTags(["1.0.0", "1.1.0", "1.1.1", "1.2.0", "1.2.1"]) },
{ name: "2.x.x", tags: toTags(["1.0.0", "1.1.0", "1.1.1", "1.2.0", "1.2.1", "1.5.0"]) },
];
const release = [
{
name: 'master',
tags: toTags(['1.0.0', '1.1.0', '1.1.1', '1.2.0', '1.2.1', '1.3.0', '1.4.0', '1.5.0', '1.6.0', '2.0.0']),
name: "master",
tags: toTags(["1.0.0", "1.1.0", "1.1.1", "1.2.0", "1.2.1", "1.3.0", "1.4.0", "1.5.0", "1.6.0", "2.0.0"]),
},
];
t.deepEqual(
normalize
.maintenance({maintenance, release})
.map(({type, name, range, accept, channel, mergeRange: maintenanceRange}) => ({
.maintenance({ maintenance, release })
.map(({ type, name, range, accept, channel, mergeRange: maintenanceRange }) => ({
type,
name,
range,
@@ -75,50 +75,50 @@ test('Maintenance branches - cap range to first release present on default branc
})),
[
{
type: 'maintenance',
name: 'name',
range: '>=1.1.1 <1.2.0',
accept: ['patch'],
channel: 'name',
mergeRange: '>=1.1.0 <1.2.0',
type: "maintenance",
name: "name",
range: ">=1.1.1 <1.2.0",
accept: ["patch"],
channel: "name",
mergeRange: ">=1.1.0 <1.2.0",
},
{
type: 'maintenance',
name: '1.2.x',
range: '>=1.2.1 <1.3.0',
accept: ['patch'],
channel: '1.2.x',
mergeRange: '>=1.2.0 <1.3.0',
type: "maintenance",
name: "1.2.x",
range: ">=1.2.1 <1.3.0",
accept: ["patch"],
channel: "1.2.x",
mergeRange: ">=1.2.0 <1.3.0",
},
{
type: 'maintenance',
name: '1.x',
range: '>=1.5.0 <1.6.0',
accept: ['patch'],
channel: '1.x',
mergeRange: '>=1.3.0 <2.0.0',
type: "maintenance",
name: "1.x",
range: ">=1.5.0 <1.6.0",
accept: ["patch"],
channel: "1.x",
mergeRange: ">=1.3.0 <2.0.0",
},
{
type: 'maintenance',
name: '2.x.x',
range: '>=2.0.0 <1.6.0',
type: "maintenance",
name: "2.x.x",
range: ">=2.0.0 <1.6.0",
accept: [],
channel: '2.x.x',
mergeRange: '>=2.0.0 <3.0.0',
channel: "2.x.x",
mergeRange: ">=2.0.0 <3.0.0",
},
]
);
});
test('Maintenance branches - cap range to default branch last release if all release are also present on maintenance branch', (t) => {
test("Maintenance branches - cap range to default branch last release if all release are also present on maintenance branch", (t) => {
const maintenance = [
{name: '1.x', tags: toTags(['1.0.0', '1.2.0', '1.3.0'])},
{name: '2.x.x', tags: toTags(['1.0.0', '1.2.0', '1.3.0', '2.0.0'])},
{ name: "1.x", tags: toTags(["1.0.0", "1.2.0", "1.3.0"]) },
{ name: "2.x.x", tags: toTags(["1.0.0", "1.2.0", "1.3.0", "2.0.0"]) },
];
const release = [{name: 'master', tags: toTags(['1.0.0', '1.2.0', '1.3.0', '2.0.0'])}];
const release = [{ name: "master", tags: toTags(["1.0.0", "1.2.0", "1.3.0", "2.0.0"]) }];
t.deepEqual(
normalize.maintenance({maintenance, release}).map(({type, name, range, accept, channel, mergeRange}) => ({
normalize.maintenance({ maintenance, release }).map(({ type, name, range, accept, channel, mergeRange }) => ({
type,
name,
range,
@@ -128,270 +128,272 @@ test('Maintenance branches - cap range to default branch last release if all rel
})),
[
{
type: 'maintenance',
name: '1.x',
range: '>=1.3.0 <2.0.0',
accept: ['patch', 'minor'],
channel: '1.x',
mergeRange: '>=1.0.0 <2.0.0',
type: "maintenance",
name: "1.x",
range: ">=1.3.0 <2.0.0",
accept: ["patch", "minor"],
channel: "1.x",
mergeRange: ">=1.0.0 <2.0.0",
},
{
type: 'maintenance',
name: '2.x.x',
range: '>=2.0.0 <2.0.0',
type: "maintenance",
name: "2.x.x",
range: ">=2.0.0 <2.0.0",
accept: [],
channel: '2.x.x',
mergeRange: '>=2.0.0 <3.0.0',
channel: "2.x.x",
mergeRange: ">=2.0.0 <3.0.0",
},
]
);
});
test('Release branches - initial state', (t) => {
test("Release branches - initial state", (t) => {
const release = [
{name: 'master', tags: []},
{name: 'next', channel: 'next', tags: []},
{name: 'next-major', tags: []},
{ name: "master", tags: [] },
{ name: "next", channel: "next", tags: [] },
{ name: "next-major", tags: [] },
];
t.deepEqual(
normalize
.release({release})
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
.release({ release })
.map(({ type, name, range, accept, channel, main }) => ({ type, name, range, accept, channel, main })),
[
{
type: 'release',
name: 'master',
range: '>=1.0.0',
accept: ['patch', 'minor', 'major'],
type: "release",
name: "master",
range: ">=1.0.0",
accept: ["patch", "minor", "major"],
channel: undefined,
main: true,
},
{
type: 'release',
name: 'next',
range: '>=1.0.0',
accept: ['patch', 'minor', 'major'],
channel: 'next',
type: "release",
name: "next",
range: ">=1.0.0",
accept: ["patch", "minor", "major"],
channel: "next",
main: false,
},
{
type: 'release',
name: 'next-major',
range: '>=1.0.0',
accept: ['patch', 'minor', 'major'],
channel: 'next-major',
type: "release",
name: "next-major",
range: ">=1.0.0",
accept: ["patch", "minor", "major"],
channel: "next-major",
main: false,
},
]
);
});
test('Release branches - 3 release branches', (t) => {
test("Release branches - 3 release branches", (t) => {
const release = [
{name: 'master', tags: toTags(['1.0.0', '1.0.1', '1.0.2'])},
{name: 'next', tags: toTags(['1.0.0', '1.0.1', '1.0.2', '1.1.0', '1.2.0'])},
{name: 'next-major', tags: toTags(['1.0.0', '1.0.1', '1.0.2', '1.1.0', '1.2.0', '2.0.0', '2.0.1', '2.1.0'])},
{ name: "master", tags: toTags(["1.0.0", "1.0.1", "1.0.2"]) },
{ name: "next", tags: toTags(["1.0.0", "1.0.1", "1.0.2", "1.1.0", "1.2.0"]) },
{ name: "next-major", tags: toTags(["1.0.0", "1.0.1", "1.0.2", "1.1.0", "1.2.0", "2.0.0", "2.0.1", "2.1.0"]) },
];
t.deepEqual(
normalize
.release({release})
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
.release({ release })
.map(({ type, name, range, accept, channel, main }) => ({ type, name, range, accept, channel, main })),
[
{type: 'release', name: 'master', range: '>=1.0.2 <1.1.0', accept: ['patch'], channel: undefined, main: true},
{ type: "release", name: "master", range: ">=1.0.2 <1.1.0", accept: ["patch"], channel: undefined, main: true },
{
type: 'release',
name: 'next',
range: '>=1.2.0 <2.0.0',
accept: ['patch', 'minor'],
channel: 'next',
type: "release",
name: "next",
range: ">=1.2.0 <2.0.0",
accept: ["patch", "minor"],
channel: "next",
main: false,
},
{
type: 'release',
name: 'next-major',
range: '>=2.1.0',
accept: ['patch', 'minor', 'major'],
channel: 'next-major',
type: "release",
name: "next-major",
range: ">=2.1.0",
accept: ["patch", "minor", "major"],
channel: "next-major",
main: false,
},
]
);
});
test('Release branches - 2 release branches', (t) => {
test("Release branches - 2 release branches", (t) => {
const release = [
{name: 'master', tags: toTags(['1.0.0', '1.0.1', '1.1.0', '1.1.1', '1.2.0'])},
{name: 'next', tags: toTags(['1.0.0', '1.0.1', '1.1.0', '1.1.1', '1.2.0', '2.0.0', '2.0.1', '2.1.0'])},
{ name: "master", tags: toTags(["1.0.0", "1.0.1", "1.1.0", "1.1.1", "1.2.0"]) },
{ name: "next", tags: toTags(["1.0.0", "1.0.1", "1.1.0", "1.1.1", "1.2.0", "2.0.0", "2.0.1", "2.1.0"]) },
];
t.deepEqual(
normalize
.release({release})
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
.release({ release })
.map(({ type, name, range, accept, channel, main }) => ({ type, name, range, accept, channel, main })),
[
{
type: 'release',
name: 'master',
range: '>=1.2.0 <2.0.0',
accept: ['patch', 'minor'],
type: "release",
name: "master",
range: ">=1.2.0 <2.0.0",
accept: ["patch", "minor"],
channel: undefined,
main: true,
},
{
type: 'release',
name: 'next',
range: '>=2.1.0',
accept: ['patch', 'minor', 'major'],
channel: 'next',
type: "release",
name: "next",
range: ">=2.1.0",
accept: ["patch", "minor", "major"],
channel: "next",
main: false,
},
]
);
});
test('Release branches - 1 release branches', (t) => {
const release = [{name: 'master', tags: toTags(['1.0.0', '1.1.0', '1.1.1', '1.2.0'])}];
test("Release branches - 1 release branches", (t) => {
const release = [{ name: "master", tags: toTags(["1.0.0", "1.1.0", "1.1.1", "1.2.0"]) }];
t.deepEqual(
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
[{type: 'release', name: 'master', range: '>=1.2.0', accept: ['patch', 'minor', 'major'], channel: undefined}]
normalize
.release({ release })
.map(({ type, name, range, accept, channel }) => ({ type, name, range, accept, channel })),
[{ type: "release", name: "master", range: ">=1.2.0", accept: ["patch", "minor", "major"], channel: undefined }]
);
});
test('Release branches - cap ranges to first release only present on following branch', (t) => {
test("Release branches - cap ranges to first release only present on following branch", (t) => {
const release = [
{name: 'master', tags: toTags(['1.0.0', '1.1.0', '1.2.0', '2.0.0'])},
{name: 'next', tags: toTags(['1.0.0', '1.1.0', '1.2.0', '2.0.0', '2.1.0'])},
{name: 'next-major', tags: toTags(['1.0.0', '1.1.0', '1.2.0', '2.0.0', '2.1.0', '2.2.0'])},
{ name: "master", tags: toTags(["1.0.0", "1.1.0", "1.2.0", "2.0.0"]) },
{ name: "next", tags: toTags(["1.0.0", "1.1.0", "1.2.0", "2.0.0", "2.1.0"]) },
{ name: "next-major", tags: toTags(["1.0.0", "1.1.0", "1.2.0", "2.0.0", "2.1.0", "2.2.0"]) },
];
t.deepEqual(
normalize
.release({release})
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
.release({ release })
.map(({ type, name, range, accept, channel, main }) => ({ type, name, range, accept, channel, main })),
[
{type: 'release', name: 'master', range: '>=2.0.0 <2.1.0', accept: ['patch'], channel: undefined, main: true},
{type: 'release', name: 'next', range: '>=2.1.0 <2.2.0', accept: ['patch'], channel: 'next', main: false},
{ type: "release", name: "master", range: ">=2.0.0 <2.1.0", accept: ["patch"], channel: undefined, main: true },
{ type: "release", name: "next", range: ">=2.1.0 <2.2.0", accept: ["patch"], channel: "next", main: false },
{
type: 'release',
name: 'next-major',
range: '>=2.2.0',
accept: ['patch', 'minor', 'major'],
channel: 'next-major',
type: "release",
name: "next-major",
range: ">=2.2.0",
accept: ["patch", "minor", "major"],
channel: "next-major",
main: false,
},
]
);
});
test('Release branches - Handle missing previous tags in branch history', (t) => {
test("Release branches - Handle missing previous tags in branch history", (t) => {
const release = [
{name: 'master', tags: toTags(['1.0.0', '2.0.0'])},
{name: 'next', tags: toTags(['1.0.0', '1.1.0', '1.1.1', '1.2.0', '2.0.0'])},
{ name: "master", tags: toTags(["1.0.0", "2.0.0"]) },
{ name: "next", tags: toTags(["1.0.0", "1.1.0", "1.1.1", "1.2.0", "2.0.0"]) },
];
t.deepEqual(
normalize
.release({release})
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
.release({ release })
.map(({ type, name, range, accept, channel, main }) => ({ type, name, range, accept, channel, main })),
[
{
type: 'release',
name: 'master',
range: '>=2.0.0',
accept: ['patch', 'minor', 'major'],
type: "release",
name: "master",
range: ">=2.0.0",
accept: ["patch", "minor", "major"],
channel: undefined,
main: true,
},
{
type: 'release',
name: 'next',
range: '>=2.0.0',
accept: ['patch', 'minor', 'major'],
channel: 'next',
type: "release",
name: "next",
range: ">=2.0.0",
accept: ["patch", "minor", "major"],
channel: "next",
main: false,
},
]
);
});
test('Release branches - limit releases on 2nd and 3rd branch based on 1st branch last release', (t) => {
test("Release branches - limit releases on 2nd and 3rd branch based on 1st branch last release", (t) => {
const release = [
{name: 'master', tags: toTags(['1.0.0', '1.1.0', '2.0.0', '3.0.0'])},
{name: 'next', tags: toTags(['1.0.0', '1.1.0'])},
{name: 'next-major', tags: toTags(['1.0.0', '1.1.0', '2.0.0'])},
{ name: "master", tags: toTags(["1.0.0", "1.1.0", "2.0.0", "3.0.0"]) },
{ name: "next", tags: toTags(["1.0.0", "1.1.0"]) },
{ name: "next-major", tags: toTags(["1.0.0", "1.1.0", "2.0.0"]) },
];
t.deepEqual(
normalize
.release({release})
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
.release({ release })
.map(({ type, name, range, accept, channel, main }) => ({ type, name, range, accept, channel, main })),
[
{
type: 'release',
name: 'master',
range: '>=3.0.0',
accept: ['patch', 'minor', 'major'],
type: "release",
name: "master",
range: ">=3.0.0",
accept: ["patch", "minor", "major"],
channel: undefined,
main: true,
},
{
type: 'release',
name: 'next',
range: '>=3.0.0',
accept: ['patch', 'minor', 'major'],
channel: 'next',
type: "release",
name: "next",
range: ">=3.0.0",
accept: ["patch", "minor", "major"],
channel: "next",
main: false,
},
{
type: 'release',
name: 'next-major',
range: '>=3.0.0',
accept: ['patch', 'minor', 'major'],
channel: 'next-major',
type: "release",
name: "next-major",
range: ">=3.0.0",
accept: ["patch", "minor", "major"],
channel: "next-major",
main: false,
},
]
);
});
test('Prerelease branches', (t) => {
test("Prerelease branches", (t) => {
const prerelease = [
{name: 'beta', channel: 'beta', prerelease: true, tags: []},
{name: 'alpha', prerelease: 'preview', tags: []},
{ name: "beta", channel: "beta", prerelease: true, tags: [] },
{ name: "alpha", prerelease: "preview", tags: [] },
];
t.deepEqual(
normalize.prerelease({prerelease}).map(({type, name, channel}) => ({type, name, channel})),
normalize.prerelease({ prerelease }).map(({ type, name, channel }) => ({ type, name, channel })),
[
{type: 'prerelease', name: 'beta', channel: 'beta'},
{type: 'prerelease', name: 'alpha', channel: 'alpha'},
{ type: "prerelease", name: "beta", channel: "beta" },
{ type: "prerelease", name: "alpha", channel: "alpha" },
]
);
});
test('Allow to set channel to "false" to prevent default', (t) => {
const maintenance = [{name: '1.x', channel: false, tags: []}];
const maintenance = [{ name: "1.x", channel: false, tags: [] }];
const release = [
{name: 'master', channel: false, tags: []},
{name: 'next', channel: false, tags: []},
{ name: "master", channel: false, tags: [] },
{ name: "next", channel: false, tags: [] },
];
const prerelease = [{name: 'beta', channel: false, prerelease: true, tags: []}];
const prerelease = [{ name: "beta", channel: false, prerelease: true, tags: [] }];
t.deepEqual(
normalize.maintenance({maintenance, release}).map(({name, channel}) => ({name, channel})),
[{name: '1.x', channel: false}]
normalize.maintenance({ maintenance, release }).map(({ name, channel }) => ({ name, channel })),
[{ name: "1.x", channel: false }]
);
t.deepEqual(
normalize.release({release}).map(({name, channel}) => ({name, channel})),
normalize.release({ release }).map(({ name, channel }) => ({ name, channel })),
[
{name: 'master', channel: false},
{name: 'next', channel: false},
{ name: "master", channel: false },
{ name: "next", channel: false },
]
);
t.deepEqual(
normalize.prerelease({prerelease}).map(({name, channel}) => ({name, channel})),
[{name: 'beta', channel: false}]
normalize.prerelease({ prerelease }).map(({ name, channel }) => ({ name, channel })),
[{ name: "beta", channel: false }]
);
});
+198 -128
View File
@@ -1,171 +1,232 @@
const test = require('ava');
const {escapeRegExp} = require('lodash');
const proxyquire = require('proxyquire').noPreserveCache();
const {stub} = require('sinon');
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
import test from "ava";
import { escapeRegExp } from "lodash-es";
import * as td from "testdouble";
import { stub } from "sinon";
import { SECRET_REPLACEMENT } from "../lib/definitions/constants.js";
let previousArgv;
let previousEnv;
test.beforeEach((t) => {
t.context.logs = '';
t.context.errors = '';
t.context.stdout = stub(process.stdout, 'write').callsFake((value) => {
t.context.logs = "";
t.context.errors = "";
t.context.stdout = stub(process.stdout, "write").callsFake((value) => {
t.context.logs += value.toString();
});
t.context.stderr = stub(process.stderr, 'write').callsFake((value) => {
t.context.stderr = stub(process.stderr, "write").callsFake((value) => {
t.context.errors += value.toString();
});
previousArgv = process.argv;
previousEnv = process.env;
});
test.afterEach.always((t) => {
t.context.stdout.restore();
t.context.stderr.restore();
process.argv = previousArgv;
process.env = previousEnv;
td.reset();
});
test.serial('Pass options to semantic-release API', async (t) => {
const run = stub().resolves(true);
test.serial("Pass options to semantic-release API", async (t) => {
const argv = [
'',
'',
'-b',
'master',
'next',
'-r',
'https://github/com/owner/repo.git',
'-t',
"",
"",
"-b",
"master",
"next",
"-r",
"https://github/com/owner/repo.git",
"-t",
`v\${version}`,
'-p',
'plugin1',
'plugin2',
'-e',
'config1',
'config2',
'--verify-conditions',
'condition1',
'condition2',
'--analyze-commits',
'analyze',
'--verify-release',
'verify1',
'verify2',
'--generate-notes',
'notes',
'--prepare',
'prepare1',
'prepare2',
'--publish',
'publish1',
'publish2',
'--success',
'success1',
'success2',
'--fail',
'fail1',
'fail2',
'--debug',
'-d',
"-p",
"plugin1",
"plugin2",
"-e",
"config1",
"config2",
"--verify-conditions",
"condition1",
"condition2",
"--analyze-commits",
"analyze",
"--verify-release",
"verify1",
"verify2",
"--generate-notes",
"notes",
"--prepare",
"prepare1",
"prepare2",
"--publish",
"publish1",
"publish2",
"--success",
"success1",
"success2",
"--fail",
"fail1",
"fail2",
"--debug",
"-d",
];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
const index = await td.replaceEsm("../index.js");
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
t.deepEqual(run.args[0][0].branches, ['master', 'next']);
t.is(run.args[0][0].repositoryUrl, 'https://github/com/owner/repo.git');
t.is(run.args[0][0].tagFormat, `v\${version}`);
t.deepEqual(run.args[0][0].plugins, ['plugin1', 'plugin2']);
t.deepEqual(run.args[0][0].extends, ['config1', 'config2']);
t.deepEqual(run.args[0][0].verifyConditions, ['condition1', 'condition2']);
t.is(run.args[0][0].analyzeCommits, 'analyze');
t.deepEqual(run.args[0][0].verifyRelease, ['verify1', 'verify2']);
t.deepEqual(run.args[0][0].generateNotes, ['notes']);
t.deepEqual(run.args[0][0].prepare, ['prepare1', 'prepare2']);
t.deepEqual(run.args[0][0].publish, ['publish1', 'publish2']);
t.deepEqual(run.args[0][0].success, ['success1', 'success2']);
t.deepEqual(run.args[0][0].fail, ['fail1', 'fail2']);
t.is(run.args[0][0].debug, true);
t.is(run.args[0][0].dryRun, true);
td.verify(
index.default({
branches: ["master", "next"],
b: ["master", "next"],
"repository-url": "https://github/com/owner/repo.git",
repositoryUrl: "https://github/com/owner/repo.git",
r: "https://github/com/owner/repo.git",
"tag-format": `v\${version}`,
tagFormat: `v\${version}`,
t: `v\${version}`,
plugins: ["plugin1", "plugin2"],
p: ["plugin1", "plugin2"],
extends: ["config1", "config2"],
e: ["config1", "config2"],
"dry-run": true,
dryRun: true,
d: true,
verifyConditions: ["condition1", "condition2"],
"verify-conditions": ["condition1", "condition2"],
analyzeCommits: "analyze",
"analyze-commits": "analyze",
verifyRelease: ["verify1", "verify2"],
"verify-release": ["verify1", "verify2"],
generateNotes: ["notes"],
"generate-notes": ["notes"],
prepare: ["prepare1", "prepare2"],
publish: ["publish1", "publish2"],
success: ["success1", "success2"],
fail: ["fail1", "fail2"],
debug: true,
_: [],
$0: "",
})
);
t.is(exitCode, 0);
});
test.serial('Pass options to semantic-release API with alias arguments', async (t) => {
const run = stub().resolves(true);
test.serial("Pass options to semantic-release API with alias arguments", async (t) => {
const argv = [
'',
'',
'--branches',
'master',
'--repository-url',
'https://github/com/owner/repo.git',
'--tag-format',
"",
"",
"--branches",
"master",
"--repository-url",
"https://github/com/owner/repo.git",
"--tag-format",
`v\${version}`,
'--plugins',
'plugin1',
'plugin2',
'--extends',
'config1',
'config2',
'--dry-run',
"--plugins",
"plugin1",
"plugin2",
"--extends",
"config1",
"config2",
"--dry-run",
];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
const index = await td.replaceEsm("../index.js");
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
t.deepEqual(run.args[0][0].branches, ['master']);
t.is(run.args[0][0].repositoryUrl, 'https://github/com/owner/repo.git');
t.is(run.args[0][0].tagFormat, `v\${version}`);
t.deepEqual(run.args[0][0].plugins, ['plugin1', 'plugin2']);
t.deepEqual(run.args[0][0].extends, ['config1', 'config2']);
t.is(run.args[0][0].dryRun, true);
td.verify(
index.default({
branches: ["master"],
b: ["master"],
"repository-url": "https://github/com/owner/repo.git",
repositoryUrl: "https://github/com/owner/repo.git",
r: "https://github/com/owner/repo.git",
"tag-format": `v\${version}`,
tagFormat: `v\${version}`,
t: `v\${version}`,
plugins: ["plugin1", "plugin2"],
p: ["plugin1", "plugin2"],
extends: ["config1", "config2"],
e: ["config1", "config2"],
"dry-run": true,
dryRun: true,
d: true,
_: [],
$0: "",
})
);
t.is(exitCode, 0);
});
test.serial('Pass unknown options to semantic-release API', async (t) => {
const run = stub().resolves(true);
const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
test.serial("Pass unknown options to semantic-release API", async (t) => {
const argv = ["", "", "--bool", "--first-option", "value1", "--second-option", "value2", "--second-option", "value3"];
const index = await td.replaceEsm("../index.js");
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
t.is(run.args[0][0].bool, true);
t.is(run.args[0][0].firstOption, 'value1');
t.deepEqual(run.args[0][0].secondOption, ['value2', 'value3']);
td.verify(
index.default({
bool: true,
firstOption: "value1",
"first-option": "value1",
secondOption: ["value2", "value3"],
"second-option": ["value2", "value3"],
_: [],
$0: "",
})
);
t.is(exitCode, 0);
});
test.serial('Pass empty Array to semantic-release API for list option set to "false"', async (t) => {
const run = stub().resolves(true);
const argv = ['', '', '--publish', 'false'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
const argv = ["", "", "--publish", "false"];
const index = await td.replaceEsm("../index.js");
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
t.deepEqual(run.args[0][0].publish, []);
td.verify(index.default({ publish: [], _: [], $0: "" }));
t.is(exitCode, 0);
});
test.serial('Do not set properties in option for which arg is not in command line', async (t) => {
test.serial("Do not set properties in option for which arg is not in command line", async (t) => {
const run = stub().resolves(true);
const argv = ['', '', '-b', 'master'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
const argv = ["", "", "-b", "master"];
await td.replaceEsm("../index.js", null, run);
process.argv = argv;
const cli = (await import("../cli.js")).default;
await cli();
t.false('ci' in run.args[0][0]);
t.false('d' in run.args[0][0]);
t.false('dry-run' in run.args[0][0]);
t.false('debug' in run.args[0][0]);
t.false('r' in run.args[0][0]);
t.false('t' in run.args[0][0]);
t.false('p' in run.args[0][0]);
t.false('e' in run.args[0][0]);
t.false("ci" in run.args[0][0]);
t.false("d" in run.args[0][0]);
t.false("dry-run" in run.args[0][0]);
t.false("debug" in run.args[0][0]);
t.false("r" in run.args[0][0]);
t.false("t" in run.args[0][0]);
t.false("p" in run.args[0][0]);
t.false("e" in run.args[0][0]);
});
test.serial('Display help', async (t) => {
test.serial("Display help", async (t) => {
const run = stub().resolves(true);
const argv = ['', '', '--help'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
const argv = ["", "", "--help"];
await td.replaceEsm("../index.js", null, run);
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
@@ -173,10 +234,12 @@ test.serial('Display help', async (t) => {
t.is(exitCode, 0);
});
test.serial('Return error exitCode and prints help if called with a command', async (t) => {
test.serial("Return error exitCode and prints help if called with a command", async (t) => {
const run = stub().resolves(true);
const argv = ['', '', 'pre'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
const argv = ["", "", "pre"];
await td.replaceEsm("../index.js", null, run);
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
@@ -185,10 +248,12 @@ test.serial('Return error exitCode and prints help if called with a command', as
t.is(exitCode, 1);
});
test.serial('Return error exitCode if multiple plugin are set for single plugin', async (t) => {
test.serial("Return error exitCode if multiple plugin are set for single plugin", async (t) => {
const run = stub().resolves(true);
const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
const argv = ["", "", "--analyze-commits", "analyze1", "analyze2"];
await td.replaceEsm("../index.js", null, run);
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
@@ -197,10 +262,12 @@ test.serial('Return error exitCode if multiple plugin are set for single plugin'
t.is(exitCode, 1);
});
test.serial('Return error exitCode if semantic-release throw error', async (t) => {
const run = stub().rejects(new Error('semantic-release error'));
const argv = ['', ''];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
test.serial("Return error exitCode if semantic-release throw error", async (t) => {
const argv = ["", ""];
const index = await td.replaceEsm("../index.js");
td.when(index.default({ _: [], $0: "" })).thenReject(new Error("semantic-release error"));
process.argv = argv;
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
@@ -208,11 +275,14 @@ test.serial('Return error exitCode if semantic-release throw error', async (t) =
t.is(exitCode, 1);
});
test.serial('Hide sensitive environment variable values from the logs', async (t) => {
const env = {MY_TOKEN: 'secret token'};
const run = stub().rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`));
const argv = ['', ''];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}});
test.serial("Hide sensitive environment variable values from the logs", async (t) => {
const env = { MY_TOKEN: "secret token" };
const argv = ["", ""];
const index = await td.replaceEsm("../index.js");
td.when(index.default({ _: [], $0: "" })).thenReject(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`));
process.argv = argv;
process.env = { ...process.env, ...env };
const cli = (await import("../cli.js")).default;
const exitCode = await cli();
+62 -54
View File
@@ -1,86 +1,94 @@
const test = require('ava');
const {maintenance, prerelease, release} = require('../../lib/definitions/branches');
import test from "ava";
import { maintenance, prerelease, release } from "../../lib/definitions/branches.js";
test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
t.true(maintenance.filter({name: '1.x.x'}));
t.true(maintenance.filter({name: '1.0.x'}));
t.true(maintenance.filter({name: '1.x'}));
t.true(maintenance.filter({name: 'some-name', range: '1.x.x'}));
t.true(maintenance.filter({name: 'some-name', range: '1.1.x'}));
t.true(maintenance.filter({name: 'some-name', range: ''}));
t.true(maintenance.filter({name: 'some-name', range: true}));
/* eslint-disable unicorn/no-fn-reference-in-iterator */
t.true(maintenance.filter({ name: "1.x.x" }));
t.true(maintenance.filter({ name: "1.0.x" }));
t.true(maintenance.filter({ name: "1.x" }));
t.true(maintenance.filter({ name: "some-name", range: "1.x.x" }));
t.true(maintenance.filter({ name: "some-name", range: "1.1.x" }));
t.true(maintenance.filter({ name: "some-name", range: "" }));
t.true(maintenance.filter({ name: "some-name", range: true }));
t.false(maintenance.filter({name: 'some-name', range: null}));
t.false(maintenance.filter({name: 'some-name', range: false}));
t.false(maintenance.filter({name: 'some-name'}));
t.false(maintenance.filter({name: '1.0.0'}));
t.false(maintenance.filter({name: 'x.x.x'}));
t.false(maintenance.filter({ name: "some-name", range: null }));
t.false(maintenance.filter({ name: "some-name", range: false }));
t.false(maintenance.filter({ name: "some-name" }));
t.false(maintenance.filter({ name: "1.0.0" }));
t.false(maintenance.filter({ name: "x.x.x" }));
/* eslint-enable unicorn/no-fn-reference-in-iterator */
});
test('A "maintenance" branches must have a "range" property formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
t.true(maintenance.branchValidator({name: 'some-name', range: '1.x.x'}));
t.true(maintenance.branchValidator({name: 'some-name', range: '1.1.x'}));
t.true(maintenance.branchValidator({ name: "some-name", range: "1.x.x" }));
t.true(maintenance.branchValidator({ name: "some-name", range: "1.1.x" }));
t.false(maintenance.branchValidator({name: 'some-name', range: '^1.0.0'}));
t.false(maintenance.branchValidator({name: 'some-name', range: '>=1.0.0 <2.0.0'}));
t.false(maintenance.branchValidator({name: 'some-name', range: '1.0.0'}));
t.false(maintenance.branchValidator({name: 'some-name', range: 'wrong-range'}));
t.false(maintenance.branchValidator({name: 'some-name', range: true}));
t.false(maintenance.branchValidator({name: 'some-name', range: ''}));
t.false(maintenance.branchValidator({ name: "some-name", range: "^1.0.0" }));
t.false(maintenance.branchValidator({ name: "some-name", range: ">=1.0.0 <2.0.0" }));
t.false(maintenance.branchValidator({ name: "some-name", range: "1.0.0" }));
t.false(maintenance.branchValidator({ name: "some-name", range: "wrong-range" }));
t.false(maintenance.branchValidator({ name: "some-name", range: true }));
t.false(maintenance.branchValidator({ name: "some-name", range: "" }));
});
test('The "maintenance" branches must have unique ranges', (t) => {
t.true(maintenance.branchesValidator([{range: '1.x.x'}, {range: '1.0.x'}]));
t.true(maintenance.branchesValidator([{ range: "1.x.x" }, { range: "1.0.x" }]));
t.false(maintenance.branchesValidator([{range: '1.x.x'}, {range: '1.x.x'}]));
t.false(maintenance.branchesValidator([{range: '1.x.x'}, {range: '1.x'}]));
t.false(maintenance.branchesValidator([{ range: "1.x.x" }, { range: "1.x.x" }]));
t.false(maintenance.branchesValidator([{ range: "1.x.x" }, { range: "1.x" }]));
});
test('A "prerelease" branch is identified by having a thruthy "prerelease" property', (t) => {
t.true(prerelease.filter({name: 'some-name', prerelease: true}));
t.true(prerelease.filter({name: 'some-name', prerelease: 'beta'}));
t.true(prerelease.filter({name: 'some-name', prerelease: ''}));
/* eslint-disable unicorn/no-fn-reference-in-iterator */
t.true(prerelease.filter({ name: "some-name", prerelease: true }));
t.true(prerelease.filter({ name: "some-name", prerelease: "beta" }));
t.true(prerelease.filter({ name: "some-name", prerelease: "" }));
t.false(prerelease.filter({name: 'some-name', prerelease: null}));
t.false(prerelease.filter({name: 'some-name', prerelease: false}));
t.false(prerelease.filter({name: 'some-name'}));
t.false(prerelease.filter({ name: "some-name", prerelease: null }));
t.false(prerelease.filter({ name: "some-name", prerelease: false }));
t.false(prerelease.filter({ name: "some-name" }));
/* eslint-enable unicorn/no-fn-reference-in-iterator */
});
test('A "prerelease" branch must have a valid prerelease detonation in "prerelease" property or in "name" if "prerelease" is "true"', (t) => {
t.true(prerelease.branchValidator({name: 'beta', prerelease: true}));
t.true(prerelease.branchValidator({name: 'some-name', prerelease: 'beta'}));
t.true(prerelease.branchValidator({ name: "beta", prerelease: true }));
t.true(prerelease.branchValidator({ name: "some-name", prerelease: "beta" }));
t.false(prerelease.branchValidator({name: 'some-name', prerelease: ''}));
t.false(prerelease.branchValidator({name: 'some-name', prerelease: null}));
t.false(prerelease.branchValidator({name: 'some-name', prerelease: false}));
t.false(prerelease.branchValidator({name: 'some-name', prerelease: '000'}));
t.false(prerelease.branchValidator({name: 'some-name', prerelease: '#beta'}));
t.false(prerelease.branchValidator({name: '000', prerelease: true}));
t.false(prerelease.branchValidator({name: '#beta', prerelease: true}));
t.false(prerelease.branchValidator({ name: "some-name", prerelease: "" }));
t.false(prerelease.branchValidator({ name: "some-name", prerelease: null }));
t.false(prerelease.branchValidator({ name: "some-name", prerelease: false }));
t.false(prerelease.branchValidator({ name: "some-name", prerelease: "000" }));
t.false(prerelease.branchValidator({ name: "some-name", prerelease: "#beta" }));
t.false(prerelease.branchValidator({ name: "000", prerelease: true }));
t.false(prerelease.branchValidator({ name: "#beta", prerelease: true }));
});
test('The "prerelease" branches must have unique "prerelease" property', (t) => {
t.true(prerelease.branchesValidator([{prerelease: 'beta'}, {prerelease: 'alpha'}]));
t.true(prerelease.branchesValidator([{ prerelease: "beta" }, { prerelease: "alpha" }]));
t.false(prerelease.branchesValidator([{range: 'beta'}, {range: 'beta'}, {range: 'alpha'}]));
t.false(prerelease.branchesValidator([{ range: "beta" }, { range: "beta" }, { range: "alpha" }]));
});
test('A "release" branch is identified by not havin a "range" or "prerelease" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
t.true(release.filter({name: 'some-name'}));
/* eslint-disable unicorn/no-fn-reference-in-iterator */
t.true(release.filter({ name: "some-name" }));
t.false(release.filter({name: '1.x.x'}));
t.false(release.filter({name: '1.0.x'}));
t.false(release.filter({name: 'some-name', range: '1.x.x'}));
t.false(release.filter({name: 'some-name', range: '1.1.x'}));
t.false(release.filter({name: 'some-name', prerelease: true}));
t.false(release.filter({name: 'some-name', prerelease: 'beta'}));
t.false(release.filter({ name: "1.x.x" }));
t.false(release.filter({ name: "1.0.x" }));
t.false(release.filter({ name: "some-name", range: "1.x.x" }));
t.false(release.filter({ name: "some-name", range: "1.1.x" }));
t.false(release.filter({ name: "some-name", prerelease: true }));
t.false(release.filter({ name: "some-name", prerelease: "beta" }));
/* eslint-enable unicorn/no-fn-reference-in-iterator */
});
test('There must be between 1 and 3 release branches', (t) => {
t.true(release.branchesValidator([{name: 'branch1'}]));
t.true(release.branchesValidator([{name: 'branch1'}, {name: 'branch2'}]));
t.true(release.branchesValidator([{name: 'branch1'}, {name: 'branch2'}, {name: 'branch3'}]));
test("There must be between 1 and 3 release branches", (t) => {
t.true(release.branchesValidator([{ name: "branch1" }]));
t.true(release.branchesValidator([{ name: "branch1" }, { name: "branch2" }]));
t.true(release.branchesValidator([{ name: "branch1" }, { name: "branch2" }, { name: "branch3" }]));
t.false(release.branchesValidator([]));
t.false(release.branchesValidator([{name: 'branch1'}, {name: 'branch2'}, {name: 'branch3'}, {name: 'branch4'}]));
t.false(
release.branchesValidator([{ name: "branch1" }, { name: "branch2" }, { name: "branch3" }, { name: "branch4" }])
);
});
+24 -24
View File
@@ -1,15 +1,15 @@
const test = require('ava');
const plugins = require('../../lib/definitions/plugins');
const {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} = require('../../lib/definitions/constants');
import test from "ava";
import plugins from "../../lib/definitions/plugins.js";
import { RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT } from "../../lib/definitions/constants.js";
test('The "analyzeCommits" plugin output must be either undefined or a valid semver release type', (t) => {
t.false(plugins.analyzeCommits.outputValidator('invalid'));
t.false(plugins.analyzeCommits.outputValidator("invalid"));
t.false(plugins.analyzeCommits.outputValidator(1));
t.false(plugins.analyzeCommits.outputValidator({}));
t.true(plugins.analyzeCommits.outputValidator());
t.true(plugins.analyzeCommits.outputValidator(null));
t.true(plugins.analyzeCommits.outputValidator('major'));
t.true(plugins.analyzeCommits.outputValidator("major"));
});
test('The "generateNotes" plugin output, if defined, must be a string', (t) => {
@@ -18,57 +18,57 @@ test('The "generateNotes" plugin output, if defined, must be a string', (t) => {
t.true(plugins.generateNotes.outputValidator());
t.true(plugins.generateNotes.outputValidator(null));
t.true(plugins.generateNotes.outputValidator(''));
t.true(plugins.generateNotes.outputValidator('string'));
t.true(plugins.generateNotes.outputValidator(""));
t.true(plugins.generateNotes.outputValidator("string"));
});
test('The "publish" plugin output, if defined, must be an object or "false"', (t) => {
t.false(plugins.publish.outputValidator(1));
t.false(plugins.publish.outputValidator('string'));
t.false(plugins.publish.outputValidator("string"));
t.true(plugins.publish.outputValidator({}));
t.true(plugins.publish.outputValidator());
t.true(plugins.publish.outputValidator(null));
t.true(plugins.publish.outputValidator(''));
t.true(plugins.publish.outputValidator(""));
t.true(plugins.publish.outputValidator(false));
});
test('The "addChannel" plugin output, if defined, must be an object', (t) => {
t.false(plugins.addChannel.outputValidator(1));
t.false(plugins.addChannel.outputValidator('string'));
t.false(plugins.addChannel.outputValidator("string"));
t.true(plugins.addChannel.outputValidator({}));
t.true(plugins.addChannel.outputValidator());
t.true(plugins.addChannel.outputValidator(null));
t.true(plugins.addChannel.outputValidator(''));
t.true(plugins.addChannel.outputValidator(""));
});
test('The "generateNotes" plugins output are concatenated with separator and sensitive data is hidden', (t) => {
const env = {MY_TOKEN: 'secret token'};
t.is(plugins.generateNotes.postprocess(['note 1', 'note 2'], {env}), `note 1${RELEASE_NOTES_SEPARATOR}note 2`);
t.is(plugins.generateNotes.postprocess(['', 'note'], {env}), 'note');
t.is(plugins.generateNotes.postprocess([undefined, 'note'], {env}), 'note');
t.is(plugins.generateNotes.postprocess(['note 1', '', 'note 2'], {env}), `note 1${RELEASE_NOTES_SEPARATOR}note 2`);
const env = { MY_TOKEN: "secret token" };
t.is(plugins.generateNotes.postprocess(["note 1", "note 2"], { env }), `note 1${RELEASE_NOTES_SEPARATOR}note 2`);
t.is(plugins.generateNotes.postprocess(["", "note"], { env }), "note");
t.is(plugins.generateNotes.postprocess([undefined, "note"], { env }), "note");
t.is(plugins.generateNotes.postprocess(["note 1", "", "note 2"], { env }), `note 1${RELEASE_NOTES_SEPARATOR}note 2`);
t.is(
plugins.generateNotes.postprocess(['note 1', undefined, 'note 2'], {env}),
plugins.generateNotes.postprocess(["note 1", undefined, "note 2"], { env }),
`note 1${RELEASE_NOTES_SEPARATOR}note 2`
);
t.is(
plugins.generateNotes.postprocess(
[`Note 1: Exposing token ${env.MY_TOKEN}`, `Note 2: Exposing token ${SECRET_REPLACEMENT}`],
{env}
{ env }
),
`Note 1: Exposing token ${SECRET_REPLACEMENT}${RELEASE_NOTES_SEPARATOR}Note 2: Exposing token ${SECRET_REPLACEMENT}`
);
});
test('The "analyzeCommits" plugins output are reduced to the highest release type', (t) => {
t.is(plugins.analyzeCommits.postprocess(['major', 'minor']), 'major');
t.is(plugins.analyzeCommits.postprocess(['', 'minor']), 'minor');
t.is(plugins.analyzeCommits.postprocess([undefined, 'patch']), 'patch');
t.is(plugins.analyzeCommits.postprocess([null, 'patch']), 'patch');
t.is(plugins.analyzeCommits.postprocess(['wrong_type', 'minor']), 'minor');
t.is(plugins.analyzeCommits.postprocess(["major", "minor"]), "major");
t.is(plugins.analyzeCommits.postprocess(["", "minor"]), "minor");
t.is(plugins.analyzeCommits.postprocess([undefined, "patch"]), "patch");
t.is(plugins.analyzeCommits.postprocess([null, "patch"]), "patch");
t.is(plugins.analyzeCommits.postprocess(["wrong_type", "minor"]), "minor");
t.is(plugins.analyzeCommits.postprocess([]), undefined);
t.is(plugins.analyzeCommits.postprocess(['wrong_type']), undefined);
t.is(plugins.analyzeCommits.postprocess(["wrong_type"]), undefined);
});
+1 -1
View File
@@ -1 +1 @@
module.exports = () => {};
export default () => {};
+3 -3
View File
@@ -1,4 +1,4 @@
const SemanticReleaseError = require('@semantic-release/error');
import SemanticReleaseError from "@semantic-release/error";
class InheritedError extends SemanticReleaseError {
constructor(message, code) {
@@ -9,6 +9,6 @@ class InheritedError extends SemanticReleaseError {
}
}
module.exports = () => {
throw new InheritedError('Inherited error', 'EINHERITED');
export default () => {
throw new InheritedError("Inherited error", "EINHERITED");
};
+3 -3
View File
@@ -1,5 +1,5 @@
module.exports = () => {
const error = new Error('a');
error.errorProperty = 'errorProperty';
export default () => {
const error = new Error("a");
error.errorProperty = "errorProperty";
throw error;
};
+3 -3
View File
@@ -1,5 +1,5 @@
const AggregateError = require('aggregate-error');
import AggregateError from "aggregate-error";
module.exports = () => {
throw new AggregateError([new Error('a'), new Error('b')]);
export default () => {
throw new AggregateError([new Error("a"), new Error("b")]);
};
+3
View File
@@ -0,0 +1,3 @@
export async function verifyConditions(pluginConfig, context) {
context.logger.log("verifyConditions called");
}
+1 -1
View File
@@ -1 +1 @@
module.exports = (pluginConfig, context) => context;
export default (pluginConfig, context) => context;
+1 -1
View File
@@ -1,4 +1,4 @@
module.exports = (pluginConfig, {env, logger}) => {
export default (pluginConfig, { env, logger }) => {
console.log(`Console: Exposing token ${env.MY_TOKEN}`);
logger.log(`Log: Exposing token ${env.MY_TOKEN}`);
logger.error(`Error: Console token ${env.MY_TOKEN}`);
+3
View File
@@ -0,0 +1,3 @@
module.exports = function noop() {
};
-1
View File
@@ -1 +0,0 @@
module.exports = () => {};
+1 -1
View File
@@ -1 +1 @@
module.exports = (pluginConfig, context) => ({pluginConfig, context});
export default (pluginConfig, context) => ({ pluginConfig, context });
+29 -29
View File
@@ -1,39 +1,39 @@
const test = require('ava');
const {stub} = require('sinon');
const getCommits = require('../lib/get-commits');
const {gitRepo, gitCommits, gitDetachedHead} = require('./helpers/git-utils');
import test from "ava";
import { stub } from "sinon";
import getCommits from "../lib/get-commits.js";
import { gitCommits, gitDetachedHead, gitRepo } from "./helpers/git-utils.js";
test.beforeEach((t) => {
// Stub the logger functions
t.context.log = stub();
t.context.error = stub();
t.context.logger = {log: t.context.log, error: t.context.error};
t.context.logger = { log: t.context.log, error: t.context.error };
});
test('Get all commits when there is no last release', async (t) => {
test("Get all commits when there is no last release", async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
const { cwd } = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second'], {cwd});
const commits = await gitCommits(["First", "Second"], { cwd });
// Retrieve the commits with the commits module
const result = await getCommits({cwd, lastRelease: {}, logger: t.context.logger});
const result = await getCommits({ cwd, lastRelease: {}, logger: t.context.logger });
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.deepEqual(result, commits);
});
test('Get all commits since gitHead (from lastRelease)', async (t) => {
test("Get all commits since gitHead (from lastRelease)", async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
const { cwd } = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second', 'Third'], {cwd});
const commits = await gitCommits(["First", "Second", "Third"], { cwd });
// Retrieve the commits with the commits module, since commit 'First'
const result = await getCommits({
cwd,
lastRelease: {gitHead: commits[commits.length - 1].hash},
lastRelease: { gitHead: commits[commits.length - 1].hash },
logger: t.context.logger,
});
@@ -42,18 +42,18 @@ test('Get all commits since gitHead (from lastRelease)', async (t) => {
t.deepEqual(result, commits.slice(0, 2));
});
test('Get all commits since gitHead (from lastRelease) on a detached head repo', async (t) => {
test("Get all commits since gitHead (from lastRelease) on a detached head repo", async (t) => {
// Create a git repository, set the current working directory at the root of the repo
let {cwd, repositoryUrl} = await gitRepo();
let { cwd, repositoryUrl } = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second', 'Third'], {cwd});
const commits = await gitCommits(["First", "Second", "Third"], { cwd });
// Create a detached head repo at commit 'feat: Second'
cwd = await gitDetachedHead(repositoryUrl, commits[1].hash);
// Retrieve the commits with the commits module, since commit 'First'
const result = await getCommits({
cwd,
lastRelease: {gitHead: commits[commits.length - 1].hash},
lastRelease: { gitHead: commits[commits.length - 1].hash },
logger: t.context.logger,
});
@@ -66,17 +66,17 @@ test('Get all commits since gitHead (from lastRelease) on a detached head repo',
t.truthy(result[0].committer.name);
});
test('Get all commits between lastRelease.gitHead and a shas', async (t) => {
test("Get all commits between lastRelease.gitHead and a shas", async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
const { cwd } = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second', 'Third'], {cwd});
const commits = await gitCommits(["First", "Second", "Third"], { cwd });
// Retrieve the commits with the commits module, between commit 'First' and 'Third'
const result = await getCommits({
cwd,
lastRelease: {gitHead: commits[commits.length - 1].hash},
nextRelease: {gitHead: commits[1].hash},
lastRelease: { gitHead: commits[commits.length - 1].hash },
nextRelease: { gitHead: commits[1].hash },
logger: t.context.logger,
});
@@ -85,16 +85,16 @@ test('Get all commits between lastRelease.gitHead and a shas', async (t) => {
t.deepEqual(result, commits.slice(1, -1));
});
test('Return empty array if lastRelease.gitHead is the last commit', async (t) => {
test("Return empty array if lastRelease.gitHead is the last commit", async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
const { cwd } = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second'], {cwd});
const commits = await gitCommits(["First", "Second"], { cwd });
// Retrieve the commits with the commits module, since commit 'Second' (therefore none)
const result = await getCommits({
cwd,
lastRelease: {gitHead: commits[0].hash},
lastRelease: { gitHead: commits[0].hash },
logger: t.context.logger,
});
@@ -102,12 +102,12 @@ test('Return empty array if lastRelease.gitHead is the last commit', async (t) =
t.deepEqual(result, []);
});
test('Return empty array if there is no commits', async (t) => {
test("Return empty array if there is no commits", async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
const { cwd } = await gitRepo();
// Retrieve the commits with the commits module
const result = await getCommits({cwd, lastRelease: {}, logger: t.context.logger});
const result = await getCommits({ cwd, lastRelease: {}, logger: t.context.logger });
// Verify no commit is retrieved
t.deepEqual(result, []);

Some files were not shown because too many files have changed in this diff Show More