Skip to content

Commit

Permalink
bump version to {version}
Browse files Browse the repository at this point in the history
  • Loading branch information
glehmann committed May 6, 2024
1 parent bb09488 commit 411a44d
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 7 deletions.
47 changes: 45 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
4 changes: 2 additions & 2 deletions editor/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion editor/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ authors = ["Gaëtan Lehmann <gaetan.lehmann@gmail.com>"]
[dependencies]
anyhow = "1.0.82"
clap = { version = "4.5.4", features = ["derive", "env", "wrap_help"] }
toml_edit = "0.22.12"
xshell = "0.2"
38 changes: 37 additions & 1 deletion xtask/src/bin/xtask.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(())
}
Expand All @@ -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::<DocumentMut>()?;
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(())
}

0 comments on commit 411a44d

Please sign in to comment.