Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 2b9ee39

Browse files
committed
update releasing way
1 parent fde106f commit 2b9ee39

File tree

3 files changed

+1749
-22
lines changed

3 files changed

+1749
-22
lines changed

package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99
"bugs": {
1010
"url": "https://github.com/kazupon/vue-i18n-jest/issues"
1111
},
12+
"changelog": {
13+
"labels": {
14+
"Type: Feature": ":star: Features",
15+
"Type: Bug": ":bug: Bug Fixes",
16+
"Type: Security": ":lock: Security Fixes",
17+
"Type: Performance": ":chart_with_upwards_trend: Performance Fixes",
18+
"Type: Improvement": ":zap: Improvement Features",
19+
"Type: Breaking": ":boom: Breaking Change",
20+
"Type: Deprecated": ":warning: Deprecated Features",
21+
"Type: I18n": ":globe_with_meridians: Internationalization",
22+
"Type: A11y": ":wheelchair: Accessibility",
23+
"Type: Documentation": ":pencil: Documentation"
24+
}
25+
},
1226
"dependencies": {
1327
"@vue/cli-plugin-unit-jest": "^4.0.5",
1428
"debug": "^4.1.1",
@@ -27,13 +41,12 @@
2741
"@typescript-eslint/eslint-plugin": "^2.7.0",
2842
"@typescript-eslint/parser": "^2.7.0",
2943
"@typescript-eslint/typescript-estree": "^2.7.0",
30-
"conventional-changelog-cli": "^2.0.27",
31-
"conventional-github-releaser": "^3.1.3",
3244
"eslint": "^6.6.0",
3345
"eslint-plugin-vue-libs": "^4.0.0",
34-
"git-commit-message-convention": "git://github.com/kazupon/git-commit-message-convention.git",
3546
"jest": "^24.9.0",
47+
"lerna-changelog": "^1.0.1",
3648
"opener": "^1.5.1",
49+
"shipjs": "^0.18.4",
3750
"ts-jest": "^24.1.0",
3851
"typescript": "^3.7.2",
3952
"vue": "^2.5"
@@ -68,7 +81,8 @@
6881
"clean": "rm -rf ./coverage && rm -rf ./lib/*.js*",
6982
"coverage": "opener coverage/lcov-report/index.html",
7083
"lint": "eslint ./src ./test --ext .ts",
71-
"release": "conventional-github-releaser -n ./node_modules/git-commit-message-convention/convention.js",
84+
"release:prepare": "shipjs prepare",
85+
"release:trigger": "shipjs trigger",
7286
"test": "npm run lint && npm run test:cover",
7387
"test:cover": "npm run test:unit -- --coverage",
7488
"test:unit": "jest --env node",

ship.config.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const execa = require(require.resolve('execa'))
2+
const { promisify } = require('util')
3+
const fs = require('fs')
4+
const path = require('path')
5+
const read = promisify(fs.readFile)
6+
const write = fs.writeFileSync
7+
8+
function extractSpecificChangelog(changelog, version) {
9+
if (!changelog) {
10+
return null
11+
}
12+
const escapedVersion = version.replace(/\./g, '\\.')
13+
const regex = new RegExp(
14+
`(#+?\\s\\[?v?${escapedVersion}\\]?[\\s\\S]*?)(#+?\\s\\[?v?\\d\\.\\d\\.\\d\\]?)`,
15+
'g'
16+
)
17+
const matches = regex.exec(changelog)
18+
return matches ? matches[1] : null
19+
}
20+
21+
async function commitChangelog(current, next) {
22+
const { stdout } = await execa('npx', [
23+
'lerna-changelog',
24+
'--next-version',
25+
`v${next}`
26+
])
27+
const escapedVersion = next.replace(/\./g, '\\.')
28+
const regex = new RegExp(
29+
`(#+?\\s\\[?v?${escapedVersion}\\]?[\\s\\S]*?)(#+?\\s\\[?v?\\d\\.\\d\\.\\d\\]?)`,
30+
'g'
31+
)
32+
const matches = regex.exec(stdout.toString())
33+
const head = matches ? matches[1] : stdout
34+
const changelog = await read('./CHANGELOG.md', 'utf8')
35+
return write('./CHANGELOG.md', `${head}\n\n${changelog}`)
36+
}
37+
38+
module.exports = {
39+
mergeStrategy: { toSameBranch: ['master'] },
40+
monorepo: undefined,
41+
updateChangelog: false,
42+
beforeCommitChanges: ({ nextVersion, exec, dir }) => {
43+
return new Promise(resolve => {
44+
const pkg = require('./package.json')
45+
commitChangelog(pkg.version, nextVersion).then(resolve)
46+
})
47+
},
48+
formatCommitMessage: ({ version, releaseType, mergeStrategy, baseBranch }) =>
49+
`${releaseType} release v${version}`,
50+
formatPullRequestTitle: ({ version, releaseType }) =>
51+
`${releaseType} release v${version}`,
52+
shouldRelease: () => true,
53+
releases: {
54+
extractChangelog: ({ version, dir }) => {
55+
const changelogPath = path.resolve(dir, 'CHANGELOG.md')
56+
try {
57+
const changelogFile = fs.readFileSync(changelogPath, 'utf-8').toString()
58+
const ret = extractSpecificChangelog(changelogFile, version)
59+
return ret
60+
} catch (err) {
61+
if (err.code === 'ENOENT') {
62+
return null
63+
}
64+
throw err
65+
}
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)