A shareable semantic-release configuration for standardizing release management across projects.
- Automated version management based on Conventional Commits
- Changelog generation
- Git release tagging
- NPM publishing support
- Commitizen integration for standardized commit messages
# Using npm
npm install --save-dev @jdhillen/release-config
# Run the setup script
npx setup-release-config
The setup script will automatically:
- Create
release.config.js
with the proper configuration - Add Commitizen configuration to your
package.json
- Add the commit script to your
package.json
- Add the semantic-release script to your
package.json
If you prefer to set up manually, follow these steps:
- Create
release.config.js
:
export default {
extends: '@jdhillen/release-config'
};
- Add Commitizen configuration to your
package.json
:
{
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
Add this workflow to .github/workflows/publish.yml
:
name: Publish to NPM
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run semantic-release
This package includes the following semantic-release plugins:
@semantic-release/commit-analyzer
@semantic-release/release-notes-generator
@semantic-release/changelog
@semantic-release/npm
@semantic-release/git
@semantic-release/github
export default {
branches: ['main'],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
'@semantic-release/npm',
['@semantic-release/git', {
assets: ['package.json', 'CHANGELOG.md'],
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}],
"@semantic-release/github", {
"assets": [
{"path": "bin/**"},
{"path": "src/**"},
{"path": "LICENSE"},
{"path": "README.md"}
]
}
]
};
This configuration uses the Conventional Commits specification. Commit messages should be structured as follows:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
-
feat
: New feature (triggers minor version) -
fix
: Bug fix (triggers patch version) -
docs
: Documentation changes -
style
: Code style changes (formatting, etc) -
refactor
: Code refactoring -
perf
: Performance improvements -
test
: Adding or updating tests -
chore
: Maintenance tasks
Add BREAKING CHANGE:
in the commit body to trigger a major version bump:
feat: allow config object to include user preferences
BREAKING CHANGE: `preferences` key in config object is now required
MIT
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.