semantic-release-npm-github-publish 1.5.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commit-transform.js +26 -33
- package/package.json +34 -17
- package/readme.md +88 -42
package/commit-transform.js
CHANGED
|
@@ -12,37 +12,30 @@ const COMMIT_HASH_LENGTH = 7;
|
|
|
12
12
|
* @return {Object} the transformed commit.
|
|
13
13
|
*/
|
|
14
14
|
module.exports = (commit, context) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}`;
|
|
25
|
-
} else {
|
|
15
|
+
const commitType = types.types[commit.type];
|
|
16
|
+
const notes = Array.isArray(commit.notes)
|
|
17
|
+
? commit.notes.map(note => ({
|
|
18
|
+
...note,
|
|
19
|
+
title: 'Breaking changes',
|
|
20
|
+
}))
|
|
21
|
+
: [];
|
|
22
|
+
|
|
23
|
+
if (!commitType || (!commitType.changelog && notes.length === 0)) {
|
|
26
24
|
return null;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
commit.scope = '';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (typeof commit.hash === 'string') {
|
|
34
|
-
commit.shortHash = commit.hash.slice(0, COMMIT_HASH_LENGTH);
|
|
35
|
-
}
|
|
27
|
+
const groupType = `${commitType.emoji ? `${commitType.emoji} ` : ''}${commitType.title}`;
|
|
36
28
|
|
|
37
29
|
const references = [];
|
|
30
|
+
let subject = commit.subject;
|
|
38
31
|
|
|
39
|
-
if (typeof
|
|
32
|
+
if (typeof subject === 'string') {
|
|
40
33
|
let url = context.repository ? `${context.host}/${context.owner}/${context.repository}` : context.repoUrl;
|
|
41
34
|
|
|
42
35
|
if (url) {
|
|
43
36
|
url += '/issues/';
|
|
44
37
|
// Issue URLs.
|
|
45
|
-
|
|
38
|
+
subject = subject.replace(/#(\d+)/g, (_, issue) => {
|
|
46
39
|
references.push(issue);
|
|
47
40
|
return `[#${issue}](${url}${issue})`;
|
|
48
41
|
});
|
|
@@ -50,20 +43,20 @@ module.exports = (commit, context) => {
|
|
|
50
43
|
|
|
51
44
|
if (context.host) {
|
|
52
45
|
// User URLs.
|
|
53
|
-
|
|
46
|
+
subject = subject.replace(/\B@([a-z0-9](?:-?[a-z0-9]){0,38})/g, `[@$1](${context.host}/$1)`);
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
return {
|
|
51
|
+
...commit,
|
|
52
|
+
groupType,
|
|
53
|
+
type: groupType,
|
|
54
|
+
scope: commit.scope === '*' ? '' : commit.scope,
|
|
55
|
+
shortHash: typeof commit.hash === 'string' ? commit.hash.slice(0, COMMIT_HASH_LENGTH) : commit.shortHash,
|
|
56
|
+
subject,
|
|
57
|
+
notes,
|
|
58
|
+
references: Array.isArray(commit.references)
|
|
59
|
+
? commit.references.filter(reference => !references.includes(reference.issue))
|
|
60
|
+
: commit.references,
|
|
61
|
+
};
|
|
69
62
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Oleg Koval <kvl.olg@gmail.com>",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"@semantic-release/
|
|
8
|
-
"@semantic-release/
|
|
9
|
-
"@semantic-release/
|
|
10
|
-
"semantic-release": "^
|
|
11
|
-
"
|
|
3
|
+
"engines": {
|
|
4
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
5
|
+
},
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
8
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
9
|
+
"@semantic-release/git": "^10.0.1",
|
|
10
|
+
"@semantic-release/github": "^12.0.6",
|
|
11
|
+
"@semantic-release/npm": "^13.1.5",
|
|
12
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
13
|
+
"semantic-release": "^25.0.3"
|
|
14
|
+
},
|
|
15
|
+
"description": "Opinionated semantic-release shareable configuration for npm and GitHub publishing with changelog generation and release commits.",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@semantic-release/changelog": "6.0.3",
|
|
18
|
+
"@semantic-release/commit-analyzer": "13.0.1",
|
|
19
|
+
"@semantic-release/git": "10.0.1",
|
|
20
|
+
"@semantic-release/github": "12.0.6",
|
|
21
|
+
"@semantic-release/npm": "13.1.5",
|
|
22
|
+
"@semantic-release/release-notes-generator": "14.1.0",
|
|
23
|
+
"@snyk/protect": "^1.1097.0",
|
|
24
|
+
"docs-index-keeper": "^1.1.0",
|
|
25
|
+
"semantic-release": "25.0.3"
|
|
12
26
|
},
|
|
13
|
-
"description": "Sharable configuration for semantic-release, extends experience for publishing to NPM & Github: generates release-notes, changelog, publishes new version with Github actions.",
|
|
14
|
-
"devDependencies": {},
|
|
15
27
|
"files": [
|
|
16
28
|
"types.js",
|
|
17
29
|
"commit-transform.js",
|
|
@@ -37,9 +49,6 @@
|
|
|
37
49
|
"license": "MIT",
|
|
38
50
|
"main": "release.config.js",
|
|
39
51
|
"name": "semantic-release-npm-github-publish",
|
|
40
|
-
"peerDependencies": {
|
|
41
|
-
"semantic-release": ">=18.0.0"
|
|
42
|
-
},
|
|
43
52
|
"publishConfig": {
|
|
44
53
|
"access": "public"
|
|
45
54
|
},
|
|
@@ -48,10 +57,18 @@
|
|
|
48
57
|
"url": "https://github.com/oleg-koval/semantic-release-npm-github-publish.git"
|
|
49
58
|
},
|
|
50
59
|
"scripts": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
60
|
+
"docs:index:check": "docs-index-keeper check",
|
|
61
|
+
"docs:index:update": "docs-index-keeper update",
|
|
62
|
+
"release:dry-run": "node ./scripts/release-dry-run.mjs",
|
|
63
|
+
"test": "node --test",
|
|
64
|
+
"test:config": "node -e \"const config = require('./release.config.js'); if (!Array.isArray(config.plugins) || config.plugins.length === 0) { throw new Error('release config did not load plugins'); }\"",
|
|
65
|
+
"semantic-release": "semantic-release --extends ./release.repo.config.js",
|
|
66
|
+
"snyk-protect": "snyk-protect",
|
|
53
67
|
"prepare": "npm run snyk-protect"
|
|
54
68
|
},
|
|
55
|
-
"
|
|
69
|
+
"docsIndexKeeper": {
|
|
70
|
+
"indexFile": "docs/README.md"
|
|
71
|
+
},
|
|
72
|
+
"version": "1.7.0",
|
|
56
73
|
"snyk": true
|
|
57
74
|
}
|
package/readme.md
CHANGED
|
@@ -1,85 +1,131 @@
|
|
|
1
1
|
# semantic-release-npm-github-publish
|
|
2
2
|
|
|
3
3
|
<p>
|
|
4
|
-
<a href="https://github.com/oleg-koval/semantic-release-npm-github-publish/actions" target="_blank">
|
|
5
|
-
<img alt="
|
|
4
|
+
<a href="https://github.com/oleg-koval/semantic-release-npm-github-publish/actions/workflows/ci.yml" target="_blank">
|
|
5
|
+
<img alt="CI" src="https://github.com/oleg-koval/semantic-release-npm-github-publish/actions/workflows/ci.yml/badge.svg?branch=main">
|
|
6
6
|
</a>
|
|
7
|
-
<a href="https://
|
|
8
|
-
<img alt="
|
|
9
|
-
</a>
|
|
10
|
-
<a href="https://github.com/oleg-koval/semantic-release-npm-github-publish#readme" target="_blank">
|
|
11
|
-
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
|
|
7
|
+
<a href="https://github.com/oleg-koval/semantic-release-npm-github-publish/actions/workflows/release.yml" target="_blank">
|
|
8
|
+
<img alt="Publish" src="https://github.com/oleg-koval/semantic-release-npm-github-publish/actions/workflows/release.yml/badge.svg?branch=main">
|
|
12
9
|
</a>
|
|
13
|
-
<a href="https://
|
|
14
|
-
<img alt="
|
|
10
|
+
<a href="https://www.npmjs.com/package/semantic-release-npm-github-publish" target="_blank">
|
|
11
|
+
<img alt="npm" src="https://img.shields.io/npm/v/semantic-release-npm-github-publish.svg">
|
|
15
12
|
</a>
|
|
16
|
-
<a href="https://github.com/oleg-koval/semantic-release-npm-github-publish/blob/
|
|
13
|
+
<a href="https://github.com/oleg-koval/semantic-release-npm-github-publish/blob/main/LICENSE" target="_blank">
|
|
17
14
|
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
|
|
18
15
|
</a>
|
|
19
16
|
</p>
|
|
20
17
|
|
|
21
|
-
>
|
|
18
|
+
> Opinionated `semantic-release` shareable configuration for npm + GitHub publishing with changelog generation and release commits.
|
|
22
19
|
|
|
23
20
|
## About
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
This package is useful if you want one maintained preset instead of repeating the same `semantic-release` plugin composition in every repository.
|
|
23
|
+
|
|
24
|
+
It adds value beyond native plugin composition by shipping:
|
|
25
|
+
|
|
26
|
+
- extra patch release rules for `build`, `ci`, `chore`, `docs`, `refactor`, `style`, and `test`
|
|
27
|
+
- curated changelog grouping, titles, and emojis via [`commit-transform.js`](./commit-transform.js) and [`types.js`](./types.js)
|
|
28
|
+
- a fixed publish chain for npm + GitHub, including changelog updates and a release commit
|
|
29
|
+
|
|
30
|
+
## Default Behavior
|
|
31
|
+
|
|
32
|
+
The exported config uses this exact plugin chain:
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
1. `@semantic-release/commit-analyzer`
|
|
35
|
+
with custom `releaseRules` for additional patch-triggering commit types
|
|
36
|
+
2. `@semantic-release/release-notes-generator`
|
|
37
|
+
3. `@semantic-release/changelog`
|
|
38
|
+
4. `@semantic-release/npm`
|
|
39
|
+
5. `@semantic-release/git`
|
|
40
|
+
commits `package.json`, `package-lock.json`, and `CHANGELOG.md`
|
|
41
|
+
with `release(version): Release ${nextRelease.version} [skip ci]`
|
|
42
|
+
6. `@semantic-release/github`
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
Release semantics match standard Conventional Commits and SemVer:
|
|
45
|
+
|
|
46
|
+
- `fix` => patch
|
|
47
|
+
- `feat` => minor
|
|
48
|
+
- `BREAKING CHANGE` footer or `!` => major
|
|
49
|
+
- `build`, `ci`, `chore`, `docs`, `refactor`, `style`, and `test` => patch in this preset
|
|
50
|
+
|
|
51
|
+
## Compatibility
|
|
52
|
+
|
|
53
|
+
This preset is actively maintained against the current stable `semantic-release` major.
|
|
54
|
+
|
|
55
|
+
- tested with Node `22` and `24`
|
|
56
|
+
- publish workflow runs on Node `24`
|
|
57
|
+
- peer dependency ranges are pinned to the currently supported plugin majors
|
|
58
|
+
- this repository also validates a `beta` prerelease branch with a repo-only release config
|
|
37
59
|
|
|
38
60
|
## Install
|
|
39
61
|
|
|
40
|
-
|
|
62
|
+
Install `semantic-release`, this preset, and the peer plugins it expects:
|
|
41
63
|
|
|
42
64
|
```sh
|
|
43
|
-
npm install --save-dev
|
|
65
|
+
npm install --save-dev \
|
|
66
|
+
semantic-release \
|
|
67
|
+
semantic-release-npm-github-publish \
|
|
68
|
+
@semantic-release/changelog \
|
|
69
|
+
@semantic-release/commit-analyzer \
|
|
70
|
+
@semantic-release/git \
|
|
71
|
+
@semantic-release/github \
|
|
72
|
+
@semantic-release/npm \
|
|
73
|
+
@semantic-release/release-notes-generator
|
|
44
74
|
```
|
|
45
75
|
|
|
46
|
-
|
|
76
|
+
Add a release script:
|
|
47
77
|
|
|
48
78
|
```json
|
|
49
|
-
|
|
50
|
-
|
|
79
|
+
{
|
|
80
|
+
"scripts": {
|
|
81
|
+
"semantic-release": "semantic-release"
|
|
82
|
+
}
|
|
51
83
|
}
|
|
52
84
|
```
|
|
53
85
|
|
|
54
|
-
|
|
86
|
+
Run `npx semantic-release` in your release workflow.
|
|
55
87
|
|
|
56
|
-
|
|
57
|
-
npm install --save-dev semantic-release-npm-github-publish
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
- Add `npx semantic-release` to a "Release" step of your CD setup
|
|
88
|
+
For this repository itself, stable releases come from `main` and prereleases come from `beta` via `release.repo.config.js`. The exported shareable config remains branch-agnostic for consumers.
|
|
61
89
|
|
|
62
90
|
## Usage
|
|
63
91
|
|
|
64
|
-
|
|
92
|
+
Example `.releaserc.yaml`:
|
|
65
93
|
|
|
66
94
|
```yaml
|
|
67
|
-
|
|
95
|
+
branches:
|
|
96
|
+
- main
|
|
97
|
+
extends: "semantic-release-npm-github-publish"
|
|
68
98
|
ci: false
|
|
69
99
|
dryRun: false
|
|
70
100
|
debug: false
|
|
71
|
-
extends: "semantic-release-npm-github-publish"
|
|
72
101
|
```
|
|
73
102
|
|
|
74
|
-
|
|
103
|
+
If your repository releases from a different branch, set `branches` explicitly in your repo-local config.
|
|
75
104
|
|
|
76
|
-
|
|
105
|
+
## When To Use This Preset
|
|
77
106
|
|
|
78
|
-
|
|
107
|
+
Use this package when you want:
|
|
79
108
|
|
|
80
|
-
-
|
|
81
|
-
-
|
|
109
|
+
- the exact plugin chain documented above
|
|
110
|
+
- extra patch releases for maintenance-only commit types
|
|
111
|
+
- the opinionated changelog formatting in this repository
|
|
112
|
+
- a maintained upgrade path for this preset over time
|
|
113
|
+
|
|
114
|
+
Use repo-local plugin composition instead when your team wants different plugins, different release rules, or full control over upgrade timing.
|
|
82
115
|
|
|
83
|
-
|
|
116
|
+
## Repository Maintenance Notes
|
|
84
117
|
|
|
85
|
-
|
|
118
|
+
- Consumer-facing examples now use `main`.
|
|
119
|
+
- Repository automation currently supports both `master` and `main` so maintenance is not blocked before the branch rename.
|
|
120
|
+
- Repository automation also supports `beta` for prerelease validation and publishing.
|
|
121
|
+
- Renaming this repository's default branch to `main` is still recommended to align hosted defaults, badges, and examples.
|
|
122
|
+
- The old README wording that inverted `fix` and `feat` was documentation drift. The actual release behavior has been corrected and is now covered by tests.
|
|
123
|
+
|
|
124
|
+
## Contributing
|
|
125
|
+
|
|
126
|
+
Issues and pull requests are welcome.
|
|
127
|
+
|
|
128
|
+
## Built With
|
|
129
|
+
|
|
130
|
+
- [GitHub Actions](https://github.com/features/actions)
|
|
131
|
+
- [semantic-release](https://github.com/semantic-release/semantic-release)
|