-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.js
More file actions
70 lines (63 loc) · 1.89 KB
/
release.js
File metadata and controls
70 lines (63 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const path = require('path')
const semanticRelease = require('semantic-release')
const RootDir = __dirname
require('dotenv').config({ path: path.join(RootDir, '.env') })
;(async function () {
try {
const result = await semanticRelease(
{
dryRun: process.env.SEMANTIC_RELEASE_DRY_RUN === '1',
ci: process.env.SEMANTIC_RELEASE_CI === '1',
branches: [
'master',
{ name: 'beta', prerelease: true },
{ name: 'alpha', prerelease: true },
],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
['@semantic-release/npm', {
npmPublish: false,
}],
// Execute staffs that ci should do
['@semantic-release/exec', {
// build
prepareCmd: 'yarn run build'
}],
// Commit build output
['@semantic-release/git', {
// build
assets: [
'package.json',
'CHANGELOG.md',
'dist/',
'types/'
]
}],
// Create release and push to github
['@semantic-release/github'],
]
},
{
cwd: RootDir,
}
)
if (result) {
const { lastRelease, commits, nextRelease, releases } = result
console.log(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`)
if (lastRelease.version) {
console.log(`The last release was "${lastRelease.version}".`)
}
for (const release of releases) {
console.log(`The release was published with plugin "${release.pluginName}".`)
}
}
else {
console.log('No release published.')
}
}
catch (err) {
console.error('The automated release failed with %O', err)
}
})()