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.
This commit is contained in:
Evan Simkowitz 2024-09-18 13:12:34 -07:00 committed by GitHub
parent 3901aa7163
commit 479414fbd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 18 deletions

View File

@ -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:
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`).
- "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.

View File

@ -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:

View File

@ -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"

View File

@ -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":