Use semver
This commit is contained in:
parent
eec66f6e54
commit
09462974e1
|
@ -35,4 +35,4 @@ jobs:
|
|||
# setup the username and email.
|
||||
git config --global user.name "Budibase Staging Release Bot"
|
||||
git config --global user.email "<>"
|
||||
./scripts/versionCommit.sh alpha
|
||||
./scripts/versionCommit.sh prerelease
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
"prettier-plugin-svelte": "^2.3.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup-plugin-replace": "^2.2.0",
|
||||
"semver": "^7.5.0",
|
||||
"svelte": "^3.38.2",
|
||||
"typescript": "4.7.3"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const fs = require("fs")
|
||||
const semver = require("semver")
|
||||
|
||||
const filePath = "lerna.json"
|
||||
const versionBump = process.argv[2] || "patch"
|
||||
|
@ -7,36 +8,9 @@ const versionBump = process.argv[2] || "patch"
|
|||
const fileData = fs.readFileSync(filePath)
|
||||
const lernaData = JSON.parse(fileData)
|
||||
|
||||
// Get current version and split into major, minor, patch, and alpha components
|
||||
const currentVersion = lernaData.version
|
||||
const [versionWithoutPrerelease, alpha] = currentVersion.split("-")
|
||||
const [major, minor, patch] = versionWithoutPrerelease.split(".").map(Number)
|
||||
|
||||
// Calculate new version based on specified version bump
|
||||
let newVersion = currentVersion
|
||||
switch (versionBump) {
|
||||
case "major":
|
||||
newVersion = `${major + 1}.0.0`
|
||||
break
|
||||
case "minor":
|
||||
newVersion = `${major}.${minor + 1}.0`
|
||||
break
|
||||
case "patch":
|
||||
newVersion = `${major}.${minor}.${patch + 1}`
|
||||
break
|
||||
case "alpha":
|
||||
let newAlphaVersion = 0
|
||||
if (alpha) {
|
||||
const [_, alphaVersion] = alpha.split(".")
|
||||
newAlphaVersion = +alphaVersion + 1
|
||||
}
|
||||
newVersion = `${versionWithoutPrerelease}-alpha.${newAlphaVersion}`
|
||||
|
||||
break
|
||||
default:
|
||||
console.error(`Invalid version bump '${versionBump}' specified.`)
|
||||
process.exit(1)
|
||||
}
|
||||
const newVersion = semver.inc(currentVersion, versionBump, "alpha")
|
||||
|
||||
// Update lerna.json file with new version
|
||||
lernaData.version = newVersion
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Error: version number is required. Usage: $0 [major|minor|patch|alpha]"
|
||||
echo "Error: version number is required. Usage: $0 [major|minor|patch|prerelease]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -21718,6 +21718,13 @@ semver@^7.2.1, semver@^7.3.5:
|
|||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
semver@^7.5.0:
|
||||
version "7.5.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.0.tgz#ed8c5dc8efb6c629c88b23d41dc9bf40c1d96cd0"
|
||||
integrity sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
semver@~2.3.1:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-2.3.2.tgz#b9848f25d6cf36333073ec9ef8856d42f1233e52"
|
||||
|
|
Loading…
Reference in New Issue