diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index 19cdbb6..902f59d 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -14,6 +14,7 @@ on: - prepatch - preminor - premajor + - prerelease required: true jobs: diff --git a/README.md b/README.md index b2dc864..f704030 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,12 @@ -# release_up +[![deno module](https://shield.deno.dev/x/release_up)](https://deno.land/x/release_up) + +

+ 🌱 release_up +

+ +

+ Automate semver releases in Deno 🦕 +

A fork of [release](https://github.com/denosaurs/release), by [denosaurs](https://github.com/denosaurs), with more config options @@ -27,6 +35,7 @@ $ deno install -A -f --no-check -n release_up https://deno.land/x/release_up@0.4 * prepatch eg: 1.2.3 -> 1.2.4-name.0 * preminor eg: 1.2.3 -> 1.3.0-name.0 * premajor eg: 1.2.3 -> 2.0.0-name.0 + * prerelease eg: 1.2.3-name.0 -> 1.2.3-name.1 Options: diff --git a/cli.test.ts b/cli.test.ts new file mode 100644 index 0000000..8f068ac --- /dev/null +++ b/cli.test.ts @@ -0,0 +1,24 @@ +import { assertEquals } from "https://deno.land/std@0.141.0/testing/asserts.ts"; +import { semver } from "./deps.ts"; + +Deno.test("semver", () => { + assertEquals(semver.inc("1.0.0", "patch", undefined, undefined), "1.0.1"); + assertEquals(semver.inc("1.0.0", "minor", undefined, undefined), "1.1.0"); + assertEquals(semver.inc("1.0.0", "major", undefined, undefined), "2.0.0"); + assertEquals( + semver.inc("1.0.0", "prepatch", undefined, "canary"), + "1.0.1-canary.0", + ); + assertEquals( + semver.inc("1.0.0-canary.1", "patch", undefined, "canary"), + "1.0.0", + ); + assertEquals( + semver.inc("1.0.0", "prerelease", undefined, "canary"), + "1.0.1-canary.0", + ); + assertEquals( + semver.inc("1.0.1-canary.0", "prerelease", undefined, "canary"), + "1.0.1-canary.1", + ); +}); diff --git a/cli.ts b/cli.ts index c154c74..407e4df 100644 --- a/cli.ts +++ b/cli.ts @@ -21,15 +21,18 @@ export type ReleaseType = | "major" | "prepatch" | "preminor" - | "premajor"; + | "premajor" + | "prerelease"; -const actions: ReleaseType[] = [ +const release_type: ReleaseType[] = [ "patch", "minor", "major", "prepatch", "preminor", "premajor", + "premajor", + "prerelease", ]; const DEFAULT_CONFIG_PATH = ".release_up.json"; @@ -47,8 +50,9 @@ await new Command() * major ${colors.dim("eg: 1.2.3 -> 2.0.0")} * prepatch ${colors.dim("eg: 1.2.3 -> 1.2.4-name.0")} * preminor ${colors.dim("eg: 1.2.3 -> 1.3.0-name.0")} - * premajor ${colors.dim("eg: 1.2.3 -> 2.0.0-name.0")}`) - .type("semver", new EnumType(actions)) + * premajor ${colors.dim("eg: 1.2.3 -> 2.0.0-name.0")} + * prerelease ${colors.dim("eg: 1.2.3-name.0 -> 1.2.3-name.1")}`) + .type("semver", new EnumType(release_type)) .arguments(" [name:string]") .option("--config ", "Define the path of the config.", { default: `${DEFAULT_CONFIG_PATH}`, @@ -58,7 +62,8 @@ await new Command() .option("--versionFile", "Enable VersionFile plugin.") .option( "--regex ", - "Enable Regex plugin. The regex need to be provided as string.", + "Enable Regex plugin. The regex need to be provided as string. --regex can be specified multiple times", + { collect: true }, ) .option("--dry", "Dry run, Does not commit any changes.") .option("--allowUncommitted", "Allow uncommited change in the repo.") @@ -68,7 +73,9 @@ await new Command() log.debug(opts, release_type, name); let suffix: string | undefined = undefined; - if (["prepatch", "preminor", "premajor"].includes(release_type)) { + if ( + ["prepatch", "preminor", "premajor", "prerelease"].includes(release_type) + ) { suffix = (name as string | undefined) ?? "canary"; } @@ -102,7 +109,7 @@ await new Command() if (opts.regex) { pluginsList.regex = regex; // deno-lint-ignore no-explicit-any - (config as any).regex = { patterns: [opts.regex] }; + (config as any).regex = { patterns: opts.regex }; } if (opts.versionFile) pluginsList.versionFile = versionFile; diff --git a/deno.jsonc b/deno.jsonc index 66a9f4b..4c7f705 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,7 +1,9 @@ { "tasks": { - "test": "deno run -A ./cli.ts --dry --allowUncommitted --regex \"(?<=@)(.*)(?=\/cli)\" --changelog --github", - "release": "deno fmt --check && deno lint && deno run -A ./cli.ts --regex \"(?<=@)(.*)(?=\/cli)\" --github --versionFile --changelog" + "dev": "deno run -A ./cli.ts --dry --allowUncommitted --regex \"(?<=@)(.*)(?=\/cli)\" --regex \"(?<=Version: )(.*)\n\" --changelog --github", + "release": "deno fmt --check && deno lint && deno run -A ./cli.ts --regex \"(?<=@)(.*)(?=\/cli)\" --regex \"(?<=Version: )(.*)$\" --github --versionFile --changelog", + "test": "deno test -A", + "check": "deno fmt && deno lint" }, "fmt": { "files": {