From 4e95e9ea514b0ac2f7fb20452a471f90eee2fde3 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 20 Mar 2022 11:08:33 +0800 Subject: [PATCH] Add process for beta release --- CONTRIBUTING.md | 9 ++++++ extra/beta/reset-version.js | 16 ++++++++++ extra/beta/update-version.js | 58 ++++++++++++++++++++++++++++++++++++ extra/press-any-key.js | 6 ++++ package.json | 9 +++--- 5 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 extra/beta/reset-version.js create mode 100644 extra/beta/update-version.js create mode 100644 extra/press-any-key.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 123cd0499..4ecf79333 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -211,6 +211,15 @@ Checking: - Try the Docker image with tag 1.X.X (Clean install / amd64 / arm64 / armv7) - Try clean installation with Node.js +### Release Beta Procedures + +1. Draft a release note, check "This is a pre-release" +2. Make sure the repo is cleared +3. `npm run release-beta` with env vars: `VERSION` and `GITHUB_TOKEN` +4. `git push` +5. Publish the release note as 1.X.X-beta.X +6. Press any key to continue + ### Release Wiki #### Setup Repo diff --git a/extra/beta/reset-version.js b/extra/beta/reset-version.js new file mode 100644 index 000000000..da4f1306b --- /dev/null +++ b/extra/beta/reset-version.js @@ -0,0 +1,16 @@ +const pkg = require("../../package.json"); +const fs = require("fs"); +const util = require("../../src/util"); + +util.polyfill(); + +const oldVersion = pkg.oldVersion; + +if (!oldVersion) { + console.log("Error: no old version?"); + process.exit(1); +} + +delete pkg.oldVersion; +pkg.version = oldVersion; +fs.writeFileSync("package.json", JSON.stringify(pkg, null, 4) + "\n"); diff --git a/extra/beta/update-version.js b/extra/beta/update-version.js new file mode 100644 index 000000000..9f770691b --- /dev/null +++ b/extra/beta/update-version.js @@ -0,0 +1,58 @@ +const pkg = require("../../package.json"); +const fs = require("fs"); +const child_process = require("child_process"); +const util = require("../../src/util"); + +util.polyfill(); + +const oldVersion = pkg.version; +const version = process.env.VERSION; + +console.log("Beta Version: " + version); + +if (!oldVersion || oldVersion.includes("-beta.")) { + console.error("Error: old version should not be a beta version?"); + process.exit(1); +} + +if (!version || !version.includes("-beta.")) { + console.error("invalid version, beta version only"); + process.exit(1); +} + +const exists = tagExists(version); + +if (! exists) { + // Process package.json + pkg.oldVersion = oldVersion; + pkg.version = version; + fs.writeFileSync("package.json", JSON.stringify(pkg, null, 4) + "\n"); + tag(version); + +} else { + console.log("version tag exists, please delete the tag or use another tag"); + process.exit(1); +} + +function tag(version) { + let res = child_process.spawnSync("git", ["tag", version]); + console.log(res.stdout.toString().trim()); +} + +function tagExists(version) { + if (! version) { + throw new Error("invalid version"); + } + + let res = child_process.spawnSync("git", ["tag", "-l", version]); + + return res.stdout.toString().trim() === version; +} + +function safeDelete(dir) { + if (fs.existsSync(dir)) { + fs.rmdirSync(dir, { + recursive: true, + }); + } +} diff --git a/extra/press-any-key.js b/extra/press-any-key.js new file mode 100644 index 000000000..038cafcab --- /dev/null +++ b/extra/press-any-key.js @@ -0,0 +1,6 @@ +console.log("Publish the release note on github, then press any key to continue"); + +process.stdin.setRawMode(true); +process.stdin.resume(); +process.stdin.on("data", process.exit.bind(process, 0)); + diff --git a/package.json b/package.json index 23f7acde6..d789617e5 100644 --- a/package.json +++ b/package.json @@ -30,13 +30,13 @@ "build-docker": "npm run build && npm run build-docker-debian && npm run build-docker-alpine", "build-docker-alpine-base": "docker buildx build -f docker/alpine-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-alpine . --push", "build-docker-debian-base": "docker buildx build -f docker/debian-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-debian . --push", - "build-docker-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.12.1-alpine --target release . --push", - "build-docker-debian": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.12.1 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.12.1-debian --target release . --push", + "build-docker-alpine": "cross-env-shell docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:$npm_package_version-alpine --target release . --push", + "build-docker-debian": "cross-env-shell docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:$npm_package_version -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:$npm_package_version-debian --target release . --push", "build-docker-nightly": "npm run build && docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push", "build-docker-nightly-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly-alpine --target nightly . --push", "build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain", "upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain", - "setup": "git checkout 1.12.1 && npm ci --production && npm run download-dist", + "setup": "cross-env-shell git checkout $npm_package_version && npm ci --production && npm run download-dist", "download-dist": "node extra/download-dist.js", "update-version": "node extra/update-version.js", "mark-as-nightly": "node extra/mark-as-nightly.js", @@ -51,7 +51,8 @@ "simple-dns-server": "node extra/simple-dns-server.js", "update-language-files-with-base-lang": "cd extra/update-language-files && node index.js %npm_config_base_lang% && eslint ../../src/languages/**.js --fix", "update-language-files": "cd extra/update-language-files && node index.js && eslint ../../src/languages/**.js --fix", - "ncu-patch": "ncu -u -t patch" + "ncu-patch": "ncu -u -t patch", + "release-beta": "cross-env-shell node extra/beta/update-version.js && npm run build && docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:$VERSION . --push && node extra/press-any-key.js && npm run upload-artifacts&& node extra/beta/reset-version.js" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "~1.2.36",