Skip to content

Commit f463322

Browse files
committed
🐛 Fix scaffold command, and add release setting files
1 parent 22cf296 commit f463322

File tree

14 files changed

+7316
-9
lines changed

14 files changed

+7316
-9
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
release:
8+
name: Release
9+
runs-on: ubuntu-18.04
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: 12
19+
- name: Generate Release Note Template
20+
working-directory: ./.release
21+
run: |
22+
npm install
23+
- name: Release
24+
working-directory: ./.release
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
npx semantic-release

.release/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.release/.releaserc.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// in ".releaserc.js" or "release.config.js"
2+
3+
const fs = require('fs');
4+
const path = require('path')
5+
const {promisify} = require('util')
6+
const dateFormat = require('dateformat')
7+
const readFileAsync = promisify(require('fs').readFile)
8+
9+
const templateDir = "./"
10+
const template = readFileAsync(path.join(templateDir, 'release-template.hbs'))
11+
const commitTemplate = readFileAsync(path.join(templateDir, 'commit-template.hbs'))
12+
const semverObj = JSON.parse(fs.readFileSync('./semver.json', 'utf8'));
13+
14+
const releaseRules = {
15+
major: convert(semverObj.semver.major),
16+
minor: convert(semverObj.semver.minor),
17+
patch: convert(semverObj.semver.patch)
18+
}
19+
20+
function convert(arr){
21+
const res=[]
22+
for (const v of arr) {
23+
res.push(`:${v}:`)
24+
}
25+
return res
26+
}
27+
28+
const releaseNotes = {
29+
template,
30+
partials: {commitTemplate},
31+
helpers: {
32+
datetime: function (format = 'UTC:yyyy-mm-dd') {
33+
return dateFormat(new Date(), format)
34+
},
35+
shortDate: function (date) {
36+
// See: https://www.npmjs.com/package/dateformat/v/3.0.0
37+
return dateFormat(date, 'mmm dd')
38+
},
39+
releaseTypeText: function (type) {
40+
if (type === 'major'){
41+
return "Breaking Release!"
42+
}
43+
if (type === 'minor'){
44+
return "Feature Release!"
45+
}
46+
if (type === 'patch'){
47+
return "Patch Release"
48+
}
49+
},
50+
releaseTypeEmoji: function (type) {
51+
if (type === 'major'){
52+
return ":confetti_ball: "
53+
}
54+
if (type === 'minor'){
55+
return ":star2: "
56+
}
57+
if (type === 'patch'){
58+
return ""
59+
}
60+
},
61+
},
62+
issueResolution: {
63+
template: '{baseUrl}/{owner}/{repo}/issues/{ref}',
64+
baseUrl: 'https://github.com',
65+
source: 'github.com'
66+
}
67+
}
68+
69+
module.exports = {
70+
branches: semverObj.branches,
71+
plugins: [
72+
['semantic-release-gitmoji', {releaseRules, releaseNotes}],
73+
'@semantic-release/github'
74+
]
75+
}

.release/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# .release
2+
3+
Check Next Release
4+
5+
```sh
6+
npm install
7+
npx semantic-release
8+
```
9+

.release/commit-template.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{subject}} - [`{{commit.short}}`](https://github.com/{{owner}}/{{repo}}/commit/{{commit.short}}) `{{shortDate committerDate}}`

0 commit comments

Comments
 (0)