diff --git a/extra/beta/update-version.js b/extra/beta/update-version.js index 9ab00155b..4af645e0e 100644 --- a/extra/beta/update-version.js +++ b/extra/beta/update-version.js @@ -24,9 +24,7 @@ if (! exists) { // Also update package-lock.json const npm = /^win/.test(process.platform) ? "npm.cmd" : "npm"; childProcess.spawnSync(npm, [ "install" ]); - commit(version); - tag(version); } else { console.log("version tag exists, please delete the tag or use another tag"); @@ -54,19 +52,6 @@ function commit(version) { console.log(res.stdout.toString().trim()); } -/** - * Create a tag with the specified version - * @param {string} version Tag to create - * @returns {void} - */ -function tag(version) { - let res = childProcess.spawnSync("git", [ "tag", version ]); - console.log(res.stdout.toString().trim()); - - res = childProcess.spawnSync("git", [ "push", "origin", version ]); - console.log(res.stdout.toString().trim()); -} - /** * Check if a tag exists for the specified version * @param {string} version Version to check diff --git a/extra/release/beta.mjs b/extra/release/beta.mjs index 7ea13b9b4..f629f2c3f 100644 --- a/extra/release/beta.mjs +++ b/extra/release/beta.mjs @@ -8,7 +8,7 @@ import { checkVersionFormat, getRepoNames, pressAnyKey, - execSync, uploadArtifacts, + execSync, uploadArtifacts, checkReleaseBranch, } from "./lib.mjs"; import semver from "semver"; @@ -23,6 +23,9 @@ if (!githubToken) { process.exit(1); } +// Check if the current branch is "release" +checkReleaseBranch(); + // Check if the version is a valid semver checkVersionFormat(version); diff --git a/extra/release/final.mjs b/extra/release/final.mjs index bf0ec2b0c..73c5a4cab 100644 --- a/extra/release/final.mjs +++ b/extra/release/final.mjs @@ -7,7 +7,7 @@ import { checkTagExists, checkVersionFormat, getRepoNames, - pressAnyKey, execSync, uploadArtifacts + pressAnyKey, execSync, uploadArtifacts, checkReleaseBranch } from "./lib.mjs"; const repoNames = getRepoNames(); @@ -21,6 +21,9 @@ if (!githubToken) { process.exit(1); } +// Check if the current branch is "release" +checkReleaseBranch(); + // Check if the version is a valid semver checkVersionFormat(version); diff --git a/extra/release/lib.mjs b/extra/release/lib.mjs index 81b9f11b3..e390ce820 100644 --- a/extra/release/lib.mjs +++ b/extra/release/lib.mjs @@ -249,3 +249,16 @@ export function execSync(cmd) { console.info(`[DRY RUN] ${cmd}`); } } + +/** + * Check if the current branch is "release" + * @returns {void} + */ +export function checkReleaseBranch() { + const res = childProcess.spawnSync("git", [ "rev-parse", "--abbrev-ref", "HEAD" ]); + const branch = res.stdout.toString().trim(); + if (branch !== "release") { + console.error(`Current branch is ${branch}, please switch to "release" branch`); + process.exit(1); + } +} diff --git a/extra/update-version.js b/extra/update-version.js index f9aead09d..9e4593446 100644 --- a/extra/update-version.js +++ b/extra/update-version.js @@ -28,9 +28,7 @@ if (! exists) { // Also update package-lock.json const npm = /^win/.test(process.platform) ? "npm.cmd" : "npm"; childProcess.spawnSync(npm, [ "install" ]); - commit(newVersion); - tag(newVersion); } else { console.log("version exists"); @@ -54,16 +52,6 @@ function commit(version) { } } -/** - * Create a tag with the specified version - * @param {string} version Tag to create - * @returns {void} - */ -function tag(version) { - let res = childProcess.spawnSync("git", [ "tag", version ]); - console.log(res.stdout.toString().trim()); -} - /** * Check if a tag exists for the specified version * @param {string} version Version to check diff --git a/package.json b/package.json index 2ab21cac2..44332c219 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uptime-kuma", - "version": "2.0.0-beta.3", + "version": "2.0.0-beta.4", "license": "MIT", "repository": { "type": "git",