Skip to content

Commit

Permalink
feat: add auto release with emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Apr 22, 2021
1 parent dfec1f2 commit 139cf9a
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 40 deletions.
67 changes: 67 additions & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const { promisify } = require('util')
const path = require('path');
const dateFormat = require('dateformat')
const readFileAsync = promisify(require('fs').readFile)

// Given a `const` variable `TEMPLATE_DIR` which points to "<semantic-release-gitmoji>/lib/assets/templates"
const TEMPLATE_DIR = '/lib/assets/templates'

// the *.hbs template and partials should be passed as strings of contents
const template = readFileAsync(path.join(TEMPLATE_DIR, 'default-template.hbs'))
const commitTemplate = readFileAsync(path.join(TEMPLATE_DIR, 'commit-template.hbs'))

module.exports = {
branches: ['master', 'dev'],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/changelog',
{
changelogFile: 'docs/CHANGELOG.md',
},
],
[
'@semantic-release/git',
{
assets: ['docs/CHANGELOG.md'],
},
],
[
'@semantic-release/github',
{
assets: [
{
path: 'src',
label: 'styled-roam',
},
],
addReleases: 'top',
},
],
[
'semantic-release-gitmoji',
{
releaseRules: {
major: [':boom:'],
minor: [':sparkles:'],
patch: [':bug:', ':ambulance:', ':lock:'],
},
releaseNotes: {
template,
partials: { commitTemplate },
helpers: {
datetime: function (format = 'UTC:yyyy-mm-dd') {
return dateFormat(new Date(), format)
},
},
issueResolution: {
template: '{baseUrl}/{owner}/{repo}/issues/{ref}',
baseUrl: 'https://github.com',
source: 'github.com',
},
},
},
],
],
}
3 changes: 3 additions & 0 deletions lib/assets/templates/commit-template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[`{{commit.short}}`](https://github.com/{{owner}}/{{repo}}/commit/{{commit.short}}) {{subject}} {{#if issues}}(Issues:{{#each issues}} [`{{text}}`]({{link}}){{/each}}){{/if}}{{#if wip}}{{#each wip}}
- [`{{commit.short}}`](https://github.com/{{owner}}/{{repo}}/commit/{{commit.short}}) {{subject}}{{/each}}
{{/if}}
42 changes: 42 additions & 0 deletions lib/assets/templates/default-template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{#if compareUrl}}
# [v{{nextRelease.version}}]({{compareUrl}}) ({{datetime "UTC:yyyy-mm-dd"}})
{{else}}
# v{{nextRelease.version}} ({{datetime "UTC:yyyy-mm-dd"}})
{{/if}}

{{#with commits}}
{{#if sparkles}}
## ✨ New Features
{{#each sparkles}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bug}}
## 🐛 Bug Fixes
{{#each bug}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if ambulance}}
## 🚑 Critical Hotfixes
{{#each ambulance}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if lock}}
## 🔒 Security Issues
{{#each lock}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if boom}}
## 💥 Breaking Changes
{{#each boom}}
- {{> commitTemplate}}
{{/each}}
{{/if}}
{{/with}}
40 changes: 3 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,6 @@
"deploy": "gh-pages -d public",
"release": "semantic-release"
},
"release": {
"branches": [
"master",
"dev"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "docs/CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"assets": [
"docs/CHANGELOG.md"
]
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "src",
"label": "styled-roam"
}
],
"addReleases": "top"
}
]
]
},
"husky": {
"hooks": {
"pre-push": "echo 'npm run build && npm run deploy'"
Expand Down Expand Up @@ -79,7 +43,8 @@
"less": "^4.0.0",
"marked": "^2.0.3",
"parcel-bundler": "^1.12.4",
"semantic-release": "^17.4.2"
"semantic-release": "^17.4.2",
"semantic-release-gitmoji": "^1.3.4"
},
"dependencies": {
"@blueprintjs/core": "^3.41.0",
Expand All @@ -97,6 +62,7 @@
"@uppy/utils": "^3.5.0",
"@uppy/webcam": "^1.8.8",
"@uppy/xhr-upload": "^1.7.2",
"dateformat": "^4.5.1",
"dayjs": "^1.9.8",
"dropbox": "^9.6.0",
"dropbox-dropins": "^1.0.4",
Expand Down
Binary file removed preview/git hash.png
Binary file not shown.
Loading

1 comment on commit 139cf9a

@vercel
Copy link

@vercel vercel bot commented on 139cf9a Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.