From 411a44d06859b937bdb22925bffd7352e0d11548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Mon, 6 May 2024 09:30:42 +0200 Subject: [PATCH] bump version to {version} --- Cargo.lock | 47 +++++++++++++++++++++++++++++++-- Cargo.toml | 2 +- editor/vscode/package-lock.json | 4 +-- editor/vscode/package.json | 2 +- xtask/Cargo.toml | 1 + xtask/src/bin/xtask.rs | 38 +++++++++++++++++++++++++- 6 files changed, 87 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ae617f..58b1cc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,7 +222,7 @@ dependencies = [ [[package]] name = "earthlyls" -version = "0.2.2" +version = "0.2.3" dependencies = [ "clap", "clean-path", @@ -242,6 +242,12 @@ dependencies = [ "tree-sitter-earthfile", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.8" @@ -396,6 +402,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -852,6 +868,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.22.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -1147,6 +1180,15 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +[[package]] +name = "winnow" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +dependencies = [ + "memchr", +] + [[package]] name = "xshell" version = "0.2.6" @@ -1164,9 +1206,10 @@ checksum = "9d422e8e38ec76e2f06ee439ccc765e9c6a9638b9e7c9f2e8255e4d41e8bd852" [[package]] name = "xtask" -version = "0.2.2" +version = "0.2.3" dependencies = [ "anyhow", "clap", + "toml_edit", "xshell", ] diff --git a/Cargo.toml b/Cargo.toml index c9ef237..fa39881 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ categories = ["development-tools"] members = ["xtask"] [workspace.package] -version = "0.2.2" +version = "0.2.3" [dependencies] clap = { version = "4.5.4", features = ["derive"] } diff --git a/editor/vscode/package-lock.json b/editor/vscode/package-lock.json index 852331a..b986381 100644 --- a/editor/vscode/package-lock.json +++ b/editor/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "earthlyls", - "version": "0.2.2", + "version": "0.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "earthlyls", - "version": "0.2.2", + "version": "0.2.3", "license": "MIT", "dependencies": { "vsce": "^2.15.0", diff --git a/editor/vscode/package.json b/editor/vscode/package.json index e750776..cf13496 100644 --- a/editor/vscode/package.json +++ b/editor/vscode/package.json @@ -5,7 +5,7 @@ "icon": "logo.png", "author": "Gaëtan Lehmann", "license": "MIT", - "version": "0.2.2", + "version": "0.2.3", "repository": { "type": "git", "url": "https://github.com/glehmann/earthlyls" diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 8007357..aee1fba 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -9,4 +9,5 @@ authors = ["Gaëtan Lehmann "] [dependencies] anyhow = "1.0.82" clap = { version = "4.5.4", features = ["derive", "env", "wrap_help"] } +toml_edit = "0.22.12" xshell = "0.2" diff --git a/xtask/src/bin/xtask.rs b/xtask/src/bin/xtask.rs index 720288b..e654477 100644 --- a/xtask/src/bin/xtask.rs +++ b/xtask/src/bin/xtask.rs @@ -1,4 +1,7 @@ -use clap::Parser; +use std::io::Write; + +use clap::{Args, Parser}; +use toml_edit::{value, DocumentMut}; use xshell::{cmd, Shell}; /// Utility commands @@ -9,12 +12,21 @@ use xshell::{cmd, Shell}; enum Command { /// Generate the earthly command description files GenerateDescriptions, + /// Bump the version and create a new draft release on github + Release(Release), +} + +#[derive(Args, Debug)] +struct Release { + /// The new version number + version: String, } fn main() -> anyhow::Result<()> { let args = Command::parse(); match args { Command::GenerateDescriptions => generate_descriptions()?, + Command::Release(args) => release(&args)?, }; Ok(()) } @@ -34,3 +46,27 @@ fn generate_descriptions() -> anyhow::Result<()> { cmd!(sh, "cp -r {docs...} {src_dir}/src/descriptions/").run()?; Ok(()) } + +fn release(args: &Release) -> anyhow::Result<()> { + let sh = Shell::new()?; + // update the workspace Cargo.toml + let toml = std::fs::read_to_string("Cargo.toml")?; + let mut doc = toml.parse::()?; + doc["workspace"]["package"]["version"] = value(&args.version); + std::fs::File::create("Cargo.toml")?.write_all(doc.to_string().as_bytes())?; + cmd!(sh, "cargo test").run()?; + // update vscode extension’s package.json + sh.change_dir("editor/vscode"); + let version = &args.version; + cmd!(sh, "npm version {version}").run()?; + // commit, tag and push + cmd!(sh, "git commit -am 'bump version to {version}'").run()?; + cmd!(sh, "git tag -am {version} {version}").run()?; + cmd!(sh, "git push").run()?; + cmd!(sh, "git push --tags").run()?; + eprintln!( + "now wait for the release worflow to complete and publish the release on \ + https://github.com/glehmann/earthlyls/releases/tag/{version}" + ); + Ok(()) +}