mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
improve release script safety
This commit is contained in:
parent
7a08794de5
commit
2331e578f7
@ -126,6 +126,22 @@ async function uploadAssets({ release, bundlePath }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
// check if no GITHUB_TOKEN env
|
||||||
|
if (!process.env.GITHUB_TOKEN) {
|
||||||
|
console.error("🆘 Missing GITHUB_TOKEN env")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if is any changes pending to commit
|
||||||
|
const gitStatus = child_process.execSync("git status --porcelain", {
|
||||||
|
cwd: process.cwd()
|
||||||
|
}).toString().trim()
|
||||||
|
|
||||||
|
if (gitStatus.length > 0) {
|
||||||
|
console.error("🆘 There are pending changes to commit, please commit first.")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
let currentVersion = packagejson.version
|
let currentVersion = packagejson.version
|
||||||
|
|
||||||
// check if currentVersion match with current latest release on github
|
// check if currentVersion match with current latest release on github
|
||||||
@ -141,8 +157,12 @@ async function main() {
|
|||||||
if (process.argv.includes("--bump")) {
|
if (process.argv.includes("--bump")) {
|
||||||
const bumpType = process.argv[process.argv.indexOf("--bump") + 1]
|
const bumpType = process.argv[process.argv.indexOf("--bump") + 1]
|
||||||
|
|
||||||
const newVersion = await bumpVersion(bumpType, 1).catch((err) => {
|
const newVersion = await bumpVersion({
|
||||||
console.error(`🆘 Failed to bump version: ${err}`)
|
root: process.cwd(),
|
||||||
|
type: bumpType,
|
||||||
|
count: 1
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(`🆘 Failed to bump version >`, error)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ async function bumpVersion({
|
|||||||
|
|
||||||
let newVersion = rootPkgjson.version
|
let newVersion = rootPkgjson.version
|
||||||
|
|
||||||
newVersion = rootPkgjson.version.split(".")
|
newVersion = newVersion.split(".")
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "patch":
|
case "patch":
|
||||||
@ -39,7 +39,7 @@ async function bumpVersion({
|
|||||||
newVersion[2] = 0
|
newVersion[2] = 0
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
console.error("Invalid version type")
|
console.error("Cannot bump version, invalid type")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ async function bumpVersion({
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return await fs.writeFileSync(path.resolve(packagesPath, package, "package.json"), JSON.stringify(pkgjson, null, 4))
|
await fs.writeFileSync(path.resolve(packagesPath, package, "package.json"), JSON.stringify(pkgjson, null, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
// write root package.json
|
// write root package.json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user