semantic-release-npm-github-publish 1.5.5 → 1.7.1

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.
Files changed (3) hide show
  1. package/commit-transform.js +26 -33
  2. package/package.json +30 -11
  3. package/readme.md +87 -42
@@ -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
- if (commit.notes) {
16
- commit.notes.forEach(note => {
17
- note.title = 'Breaking changes';
18
- });
19
- }
20
-
21
- if (types.types[commit.type] && (types.types[commit.type].changelog || (commit.notes && commit.notes.length > 0))) {
22
- commit.groupType = `${types.types[commit.type].emoji ? `${types.types[commit.type].emoji} ` : ''}${
23
- types.types[commit.type].title
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
- if (commit.scope === '*') {
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 commit.subject === 'string') {
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
- commit.subject = commit.subject.replace(/#(\d+)/g, (_, issue) => {
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
- commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9]){0,38})/g, `[@$1](${context.host}/$1)`);
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
- if (commit.references) {
58
- // Remove references that already appear in the subject
59
- commit.references = commit.references.filter(reference => {
60
- if (!references.includes(reference.issue)) {
61
- return true;
62
- }
63
-
64
- return false;
65
- });
66
- }
67
-
68
- return commit;
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,28 @@
1
1
  {
2
2
  "author": "Oleg Koval <kvl.olg@gmail.com>",
3
+ "engines": {
4
+ "node": "^22.14.0 || >=24.10.0"
5
+ },
3
6
  "peerDependencies": {
4
- "@semantic-release/changelog": ">=6.0.0",
5
- "@semantic-release/commit-analyzer": ">=9.0.0",
6
- "@semantic-release/git": ">=10.0.0",
7
- "@semantic-release/github": ">=8.0.0",
8
- "@semantic-release/npm": ">=9.0.0",
9
- "@semantic-release/release-notes-generator": ">=10.0.0",
10
- "semantic-release": ">=20.0.0"
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"
11
14
  },
12
- "description": "Sharable configuration for semantic-release, extends experience for publishing to NPM & Github: generates release-notes, changelog, publishes new version with Github actions.",
15
+ "description": "Opinionated semantic-release shareable configuration for npm and GitHub publishing with changelog generation and release commits.",
13
16
  "devDependencies": {
14
- "@snyk/protect": "^1.1097.0"
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"
15
26
  },
16
27
  "files": [
17
28
  "types.js",
@@ -46,10 +57,18 @@
46
57
  "url": "https://github.com/oleg-koval/semantic-release-npm-github-publish.git"
47
58
  },
48
59
  "scripts": {
49
- "semantic-release": "semantic-release",
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",
50
66
  "snyk-protect": "snyk-protect",
51
67
  "prepare": "npm run snyk-protect"
52
68
  },
53
- "version": "1.5.5",
69
+ "docsIndexKeeper": {
70
+ "indexFile": "docs/README.md"
71
+ },
72
+ "version": "1.7.1",
54
73
  "snyk": true
55
74
  }
package/readme.md CHANGED
@@ -1,85 +1,130 @@
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="Version" src="https://github.com/oleg-koval/semantic-release-npm-github-publish/workflows/Publish/badge.svg?branch=master">
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://www.npmjs.com/package/semantic-release-npm-github-publish" target="_blank">
8
- <img alt="Version" src="https://img.shields.io/npm/v/semantic-release-npm-github-publish.svg">
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://github.com/oleg-koval/semantic-release-npm-github-publish/graphs/commit-activity" target="_blank">
14
- <img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
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/master/LICENSE" target="_blank">
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
- > Semantic-release shareable configuration for easy publishing to NPM, Github or Github Package Registry.
18
+ > Opinionated `semantic-release` shareable configuration for npm + GitHub publishing with changelog generation and release commits.
22
19
 
23
20
  ## About
24
21
 
25
- > This [sharable configuration](https://github.com/semantic-release/semantic-release/blob/master/docs/extending/shareable-configurations-list.md) conforms to [angular standard](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular)
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
- - Using [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer) ensures that commits are conformed to the [conventional commits specification](https://www.conventionalcommits.org/en/v1.0.0-beta.4/).
28
- - **PATCH** version created if any of **build, ci, chore, docs, refactor, style, test** commit types pushed to master
29
- - **MINOR** version created if **fix** commit type pushed
30
- - **MAJOR** version created if **feat** commit type pushed
31
- - Publishes the new version to [NPM](https://npmjs.org).
32
- - Bumps a version in package.json.
33
- - Generates or updates a [changelog](https://github.com/semantic-release/changelog) file including all **PATCH** keywords (not included in default angular package).
34
- - Releases new release for NPM & Github.
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
- **This repository can be also used as a [template repository](https://help.github.com/en/articles/creating-a-template-repository) for creation of sharable semantic-release configurations.**
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
- - Install `semantic-release`:
62
+ Install `semantic-release`, this preset, and the peer plugins it expects:
41
63
 
42
64
  ```sh
43
- npm install --save-dev semantic-release
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
- - Add `semantic-release` to scripts:
76
+ Add a release script:
47
77
 
48
78
  ```json
49
- "scripts": {
50
- "semantic-release": "semantic-release"
79
+ {
80
+ "scripts": {
81
+ "semantic-release": "semantic-release"
82
+ }
51
83
  }
52
84
  ```
53
85
 
54
- - Install `semantic-release-npm-github-publish`:
86
+ Run `npx semantic-release` in your release workflow.
55
87
 
56
- ```sh
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
- To use this sharable config, extend your semantic release configuration in `.releaserc.yaml`:
92
+ Example `.releaserc.yaml`:
65
93
 
66
94
  ```yaml
67
- branch: master
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
- ## Contributing
103
+ If your repository releases from a different branch, set `branches` explicitly in your repo-local config.
75
104
 
76
- Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/oleg-koval/semantic-release-npm-github-publish/issues).
105
+ ## When To Use This Preset
77
106
 
78
- ## Build with
107
+ Use this package when you want:
79
108
 
80
- - [Github actions](https://github.com/features/actions)
81
- - [semantic-release](https://github.com/semantic-release/semantic-release)
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
- _This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
118
+ - Consumer-facing examples now use `main`.
119
+ - Repository automation publishes stable releases from `main` and prereleases from `beta`.
120
+ - Dependabot PRs can auto-refresh `package-lock.json` through the dedicated lockfile-fixer workflow.
121
+ - 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.
122
+
123
+ ## Contributing
124
+
125
+ Issues and pull requests are welcome.
126
+
127
+ ## Built With
128
+
129
+ - [GitHub Actions](https://github.com/features/actions)
130
+ - [semantic-release](https://github.com/semantic-release/semantic-release)