-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.js
More file actions
45 lines (39 loc) · 943 Bytes
/
Copy pathrelease.js
File metadata and controls
45 lines (39 loc) · 943 Bytes
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
const cmd = require('child_process')
const fs = require('node:fs')
const pkg = require('./composer.json')
const { version } = require('os')
let [major, minor, patch] = (pkg.version ?? '0.0.0').split('.').map(x => Number(x))
const scope = process.argv[2].split('=')[1]
switch (scope) {
case 'major':
major += 1
minor = 0
patch = 0
break
case 'minor':
minor += 1
patch = 0
break
case 'patch':
patch += 1
break
default:
break
}
const v = `${major}.${minor}.${patch}`
pkg.version = v
try {
fs.writeFileSync(
'./composer.json',
JSON.stringify(pkg, null, 2)
)
console.log(`Version bumped to ${v}`)
cmd.execSync(`git add *`)
cmd.execSync(`git commit -m "Version bumped to ${v}"`)
cmd.execSync('git push')
console.log('Changes pushed. Creating release...')
cmd.execSync(`gh release create v${v}`)
console.log('Release created')
} catch (error) {
console.error(error)
}