From 479414fbd1a240062be71ffa513c3bcb7ce60cfe Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Wed, 18 Sep 2024 13:12:34 -0700 Subject: [PATCH] If prerelease is false and action is none, remove the prerelease version string (#395) Updates the version.cjs script so that if the arguments are "none 0" and a prerelease version is already set, it will be removed. This is equivalent the behavior of "patch 0", but better aligns with the default behavior of the Bump Version worklow. --- RELEASES.md | 11 ++++++++--- Taskfile.yml | 11 +---------- package.json | 2 +- version.cjs | 25 +++++++++++++++++++++---- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 2bc7dc91..acc3da1d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -3,9 +3,14 @@ ## Step-by-step guide 1. Go to the [Actions tab](https://github.com/wavetermdev/thenextwave/actions) and select "Bump Version" from the left sidebar. -2. Click on "Run workflow". You will see two options: - - "SemVer Bump": This defaults to `none`. Adjust this if you want to increment the version number according to semantic versioning rules (`patch`, `minor`, `major`). - - "Is Prerelease": This defaults to `true`. If set to `true`, a `-beta.X` version will be appended to the end of the version. If one is already present and the base SemVer is not being incremented, the `-beta` version will be incremented (i.e. `0.1.13-beta.0` to `0.1.13-beta.1`). +2. Click on "Run workflow". + - You will see two options: + - "SemVer Bump": This defaults to `none`. Adjust this if you want to increment the version number according to semantic versioning rules (`patch`, `minor`, `major`). + - "Is Prerelease": This defaults to `true`. If set to `true`, a `-beta.X` version will be appended to the end of the version. If one is already present and the base SemVer is not being incremented, the `-beta` version will be incremented (i.e. `0.1.13-beta.0` to `0.1.13-beta.1`). If set to `false`, the `-beta.X` suffix will be removed from the version number. If one was not already present, it will remain absent. + - Some examples: + - If you are creating a new prerelease following an official release, you would set "SemVer Bump" to to the expected version bump (`patch`, `minor`, or `major`) and "Is Prerelease" to `true`. + - If you are bumping an existing prerelease to a new prerelease under the same version, you would set "SemVer Bump" to `none` and "Is Prerelease" to `true`. + - If you are promoting a prerelease version to an official release, you would set "SemVer Bump" to `none` and "Is Prerelease" to `false`. 3. After "Bump Version" a "Build Helper" run will kick off automatically for the new version. When this completes, it will generate a draft GitHub Release with all the built artifacts. 4. Review the artifacts in the release and test them locally. 5. When you are confident that the build is good, edit the GitHub Release to add a changelog and release summary and publish the release. diff --git a/Taskfile.yml b/Taskfile.yml index 8e488482..280d632f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -203,16 +203,7 @@ tasks: - frontend/app/store/wshserver.ts version: - desc: Get the current package version, or bump version if args are present. To pass args to `version.cjs`, add them after `--`. - summary: | - If no arguments are present, the current version will be returned. - If only a single argument is given, the following are valid inputs: - - `none`: No-op. - - `patch`: Bumps the patch version. - - `minor`: Bumps the minor version. - - `major`: Bumps the major version. - - '1', 'true': Bumps the prerelease version. - If two arguments are given, the first argument must be either `none`, `patch`, `minor`, or `major`. The second argument must be `1` or `true` to bump the prerelease version. + desc: Get the current package version, or bump version if args are present. To pass args to `version.cjs`, add them after `--`. See `version.cjs` for usage definitions for the arguments. cmd: node version.cjs {{.CLI_ARGS}} artifacts:upload: diff --git a/package.json b/package.json index ab6b82b5..7e5fd498 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "productName": "TheNextWave", "description": "An Open-Source, AI-Native, Terminal Built for Seamless Workflows", "license": "Apache-2.0", - "version": "0.1.13", + "version": "0.1.18", "homepage": "https://waveterm.dev", "build": { "appId": "dev.commandline.thenextwave" diff --git a/version.cjs b/version.cjs index fca8c93e..a90caa17 100644 --- a/version.cjs +++ b/version.cjs @@ -8,7 +8,14 @@ * - `minor`: Bumps the minor version. * - `major`: Bumps the major version. * - '1', 'true': Bumps the prerelease version. - * If two arguments are given, the first argument must be either `none`, `patch`, `minor`, or `major`. The second argument must be `1` or `true` to bump the prerelease version. + * If two arguments are given, the following are valid inputs for the first argument: + * - `none`: No-op. + * - `patch`: Bumps the patch version. + * - `minor`: Bumps the minor version. + * - `major`: Bumps the major version. + * The following are valid inputs for the second argument: + * - `0`, 'false': The release is not a prerelease, will remove any prerelease identifier from the version, if one was present. + * - '1', 'true': The release is a prerelease (any value other than `0` or `false` will be interpreted as `true`). */ const path = require("path"); @@ -23,11 +30,21 @@ if (typeof require !== "undefined" && require.main === module) { const fs = require("fs"); const semver = require("semver"); - const action = process.argv[2]; + let action = process.argv[2]; + + // If prerelease argument is not explicitly set, mark it as undefined. const isPrerelease = process.argv.length > 3 - ? process.argv[3] === "true" || process.argv[3] === "1" - : action === "true" || action === "1"; + ? process.argv[3] !== "false" && process.argv[3] !== "0" + : action === "true" || action === "1" + ? true + : undefined; + + // This will remove the prerelease version string (i.e. 0.1.13-beta.1 -> 0.1.13) if the arguments are `none 0` and the current version is a prerelease. + if (action === "none" && isPrerelease === false && semver.prerelease(VERSION)) { + action = "patch"; + } + let newVersion = packageJson.version; switch (action) { case "major":