diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-03-30 16:37:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-30 16:37:00 -0400 |
commit | 5cab3e7dba54643f95c147b48696c8af8a26632c (patch) | |
tree | 249fd42319c121523e17835b85b13ef922d07d38 /tools/release/01_bump_crate_versions.ts | |
parent | f61b2c0b1169ef2345738723583d8335638aeff2 (diff) |
build: use workflows for bumping versions and cargo publishing on the CI (#13995)
Diffstat (limited to 'tools/release/01_bump_crate_versions.ts')
-rwxr-xr-x | tools/release/01_bump_crate_versions.ts | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/tools/release/01_bump_crate_versions.ts b/tools/release/01_bump_crate_versions.ts index eea49279f..70c92637e 100755 --- a/tools/release/01_bump_crate_versions.ts +++ b/tools/release/01_bump_crate_versions.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo +#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo,git --allow-net --no-check // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. import { DenoWorkspace } from "./deno_workspace.ts"; import { GitLogOutput, path, semver } from "./deps.ts"; @@ -8,8 +8,19 @@ const repo = workspace.repo; const cliCrate = workspace.getCliCrate(); const originalCliVersion = cliCrate.version; +// update the std version used in the code +await updateStdVersion(); + // increment the cli version -await cliCrate.promptAndIncrement(); +if (Deno.args.some((a) => a === "--patch")) { + await cliCrate.increment("patch"); +} else if (Deno.args.some((a) => a === "--minor")) { + await cliCrate.increment("minor"); +} else if (Deno.args.some((a) => a === "--major")) { + await cliCrate.increment("major"); +} else { + await cliCrate.promptAndIncrement(); +} // increment the dependency crate versions for (const crate of workspace.getCliDependencyCrates()) { @@ -17,7 +28,7 @@ for (const crate of workspace.getCliDependencyCrates()) { } // update the lock file -await workspace.getCliCrate().cargoCheck(); +await workspace.getCliCrate().cargoUpdate("--workspace"); // try to update the Releases.md markdown text try { @@ -101,3 +112,26 @@ async function getGitLog() { ); } } + +async function updateStdVersion() { + const newStdVersion = await getLatestStdVersion(); + const compatFilePath = path.join(cliCrate.folderPath, "compat/mod.rs"); + const text = Deno.readTextFileSync(compatFilePath); + Deno.writeTextFileSync( + compatFilePath, + text.replace(/std@[0-9]+\.[0-9]+\.[0-9]+/, `std@${newStdVersion}`), + ); +} + +async function getLatestStdVersion() { + const url = + "https://raw.githubusercontent.com/denoland/deno_std/main/version.ts"; + const result = await fetch(url); + const text = await result.text(); + const version = /"([0-9]+\.[0-9]+\.[0-9]+)"/.exec(text); + if (version == null) { + throw new Error(`Could not find version in text: ${text}`); + } else { + return version[1]; + } +} |