forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.js
133 lines (104 loc) · 3.54 KB
/
release.js
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
How to do a release:
1. Make sure you have publish access for all packages:
- You must be in the CLI team in the npm @vue organization
- You must have publish access to vue-cli-version-marker
- Make sure you DO NOT have npm per-publish 2-factor / OTP enabled, as it
does not work with Lerna (which we use for batch publishing).
2. Run `yarn release`, follow prompts
3A. If everything works properly, the tag should have been auto-pushed and a
local changelog commit should have been generated. Go to 4.
3B. If the publish fails half-way, things have gotten hairy. Now you need to
go to npm to check which packages have been published and manually publish
the ones that have not been published yet. After all have been published:
3B.1. Push the release git tag to GitHub.
3B.2. Run `yarn changelog` to generate changelog commit.
4. Push the changelog commit to `dev` branch.
5. Go to GitHub and verify that the changelog is live.
6. Go to GitHub releases page and publish the release (this is required for
the release to show up in the issue helper)
Note: eslint-config-* packages should be released separately & manually.
*/
process.env.VUE_CLI_RELEASE = true
const execa = require('execa')
const semver = require('semver')
const inquirer = require('inquirer')
const minimist = require('minimist')
const { syncDeps } = require('./syncDeps')
// const { buildEditorConfig } = require('./buildEditorConfig')
const cliOptions = minimist(process.argv)
if (cliOptions['local-registry']) {
inquirer.prompt = () => ({
bump: 'minor',
yes: true
})
}
const curVersion = require('../lerna.json').version
const release = async () => {
console.log(`Current version: ${curVersion}`)
const bumps = ['patch', 'minor', 'major', 'prerelease']
const versions = {}
bumps.forEach(b => { versions[b] = semver.inc(curVersion, b) })
const bumpChoices = bumps.map(b => ({ name: `${b} (${versions[b]})`, value: b }))
const { bump, customVersion } = await inquirer.prompt([
{
name: 'bump',
message: 'Select release type:',
type: 'list',
choices: [
...bumpChoices,
{ name: 'custom', value: 'custom' }
]
},
{
name: 'customVersion',
message: 'Input version:',
type: 'input',
when: answers => answers.bump === 'custom'
}
])
const version = customVersion || versions[bump]
const { yes } = await inquirer.prompt([{
name: 'yes',
message: `Confirm releasing ${version}?`,
type: 'confirm'
}])
if (yes) {
await syncDeps({
version,
local: true,
skipPrompt: true
})
delete process.env.PREFIX
// buildEditorConfig()
try {
await execa('git', ['add', '-A'], { stdio: 'inherit' })
await execa('git', ['commit', '-m', 'chore: pre release sync'], { stdio: 'inherit' })
} catch (e) {
// if it's a patch release, there may be no local deps to sync
}
}
const releaseType = semver.diff(curVersion, version)
let distTag = 'latest'
if (releaseType.startsWith('pre') && !cliOptions['local-registry']) {
distTag = 'next'
}
const lernaArgs = [
'publish',
version,
'--dist-tag',
distTag
]
// keep packages' minor version in sync
if (releaseType !== 'patch') {
lernaArgs.push('--force-publish')
}
if (cliOptions['local-registry']) {
lernaArgs.push('--no-git-tag-version', '--no-commit-hooks', '--no-push', '--yes')
}
await execa(require.resolve('lerna/cli'), lernaArgs, { stdio: 'inherit' })
}
release().catch(err => {
console.error(err)
process.exit(1)
})