-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This update includes: - full switch to comventional commits - auto-generated conventional CHANGELOG.md - custom changelog template - helper function for changelog to transform data - npm package configuration to ensure proper generation process - custom script to: - autmatically bump package.json version - tag the latest commit with the bumped version - generate changelog - commit changes as chore(release) - push commit to the main branch along with the tag
- Loading branch information
1 parent
7e22233
commit 24665d4
Showing
6 changed files
with
353 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Changelog | ||
|
||
This document outlines the summary of all notable changes to the project. | ||
|
||
{{#each releases}} | ||
{{#if href}} | ||
## [{{title}}]({{href}}) - {{niceDate}} | ||
{{else}} | ||
## {{title}} - {{niceDate}} | ||
{{/if}} | ||
|
||
{{#commit-list commits heading='### Breaking Changes ⚠️' message='BREAKING CHANGE'}} | ||
{{subject}} ([`{{shorthash}}`]({{href}})) | ||
{{/commit-list}} | ||
|
||
{{#commit-list commits heading='### New ✨' message='feat(\([\w-]*?\))?:'}} | ||
- {{subject}} ([`{{shorthash}}`]({{href}})) | ||
{{/commit-list}} | ||
|
||
{{#commit-list commits heading='### Bug fixes 🐛' message='fix(\([\w-]*?\))?:'}} | ||
- {{subject}} ([`{{shorthash}}`]({{href}})) | ||
{{/commit-list}} | ||
|
||
{{#commit-list commits heading='### Documentation 📚' message='docs(\([\w-]*?\))?:'}} | ||
- {{subject}} ([`{{shorthash}}`]({{href}})) | ||
{{/commit-list}} | ||
|
||
{{#commit-list commits heading='### Improvements 📈' message='(build|chore|ci|perf|refactor|revert|style|test)(\([\w-]*?\))?:' exclude='chore\(release\): '}} | ||
- {{#emoji subject }}{{/emoji}}{{#if href}} ([`{{shorthash}}`]({{href}})){{/if}} | ||
{{/commit-list}} | ||
|
||
---- | ||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = (Handlebars) => { | ||
Handlebars.registerHelper('emoji', (message, options) => { | ||
const emojies = { | ||
build: '⚙️', | ||
chore: 'ℹ️', | ||
ci: '🚀', | ||
perf: '🚄', | ||
refactor: '♻️', | ||
revert: '⏮️', | ||
style: '🎨', | ||
test: '✅' | ||
} | ||
|
||
let match = message.match(/(\w*)(\([\w-]*?\))?:/); | ||
return match ? emojies[match[1]] + ' ' + message : message | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
git-tag-version=false | ||
sign-git-commit=true | ||
sign-git-tag=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { execSync } = require('child_process'); | ||
|
||
// Check the type of the latest commit to know what version should be bumped | ||
const latestCommitMessage = execSync('git log -1 --format=%s').toString('utf-8'); | ||
const commitParts = latestCommitMessage.matchAll(/(?<type>build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(?<scope>\(\w*?\))?(?<breaking>!)?:/g); | ||
|
||
let newBumbedVersion = ''; | ||
|
||
for (const commitPart of commitParts) { | ||
if (commitPart.groups.breaking) { | ||
newBumbedVersion = execSync('npm version major').toString('utf-8'); | ||
} else if (commitPart.groups.type === 'feat') { | ||
newBumbedVersion = execSync('npm version minor').toString('utf-8'); | ||
} else if (commitPart.groups.type === 'fix') { | ||
newBumbedVersion = execSync('npm version patch').toString('utf-8'); | ||
} else { | ||
newBumbedVersion = execSync('npm version minor').toString('utf-8'); | ||
} | ||
|
||
newBumbedVersion = newBumbedVersion.trim(); | ||
|
||
// Create a new tag and assign it to the latest commit | ||
execSync(`git tag ${newBumbedVersion}`); | ||
|
||
// Generate changelog for the latest release | ||
execSync('npm run changelog'); | ||
|
||
// Commit bumped package.jspon and generated CHANGELOG as a chore(release) | ||
execSync(`git add package.json package-lock.json CHANGELOG.md && git commit -q -m "chore(release): ${newBumbedVersion}"`); | ||
|
||
// Push commit along with the tag to the main branch | ||
execSync('git push --follow-tags origin main'); | ||
// execSync('git push origin --tags'); | ||
} |
Oops, something went wrong.