From ec4be37d6b10216d224ca4421d67973c4d653356 Mon Sep 17 00:00:00 2001 From: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com> Date: Mon, 16 Sep 2024 23:08:06 +0200 Subject: [PATCH] Update to release-plz-v0.3.90 --- action.yml | 4 +-- updater/Cargo.lock | 74 +++++++++++++++++++++++++++++++++++++++++++++ updater/Cargo.toml | 1 + updater/src/main.rs | 7 ++++- updater/src/pr.rs | 43 ++++++++------------------ 5 files changed, 95 insertions(+), 34 deletions(-) diff --git a/action.yml b/action.yml index fd356da..3e44bf4 100644 --- a/action.yml +++ b/action.yml @@ -24,8 +24,8 @@ inputs: description: "Deprecated. Use `manifest_path` instead." required: false version: - description: "Release-plz version to use. (Default: `0.3.90`)." - default: "0.3.90" + description: "Release-plz version to use. (Default: `release-plz-v0.3.90`)." + default: "release-plz-v0.3.90" required: false token: description: "Token used to publish to the cargo registry" diff --git a/updater/Cargo.lock b/updater/Cargo.lock index 5826084..7f44727 100644 --- a/updater/Cargo.lock +++ b/updater/Cargo.lock @@ -199,6 +199,12 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "generic-array" version = "0.14.7" @@ -219,12 +225,28 @@ dependencies = [ "tracing", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "indexmap" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "inquire" version = "0.6.2" @@ -241,6 +263,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "lazy_static" version = "1.4.0" @@ -413,6 +441,12 @@ dependencies = [ "bitflags", ] +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + [[package]] name = "scopeguard" version = "1.2.0" @@ -425,6 +459,39 @@ version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +[[package]] +name = "serde" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha2" version = "0.10.8" @@ -570,6 +637,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "updater" version = "0.1.0" @@ -579,6 +652,7 @@ dependencies = [ "inquire", "next_version", "semver", + "serde_yaml", ] [[package]] diff --git a/updater/Cargo.toml b/updater/Cargo.toml index aaa6619..42196ff 100644 --- a/updater/Cargo.toml +++ b/updater/Cargo.toml @@ -11,3 +11,4 @@ semver = "1.0.21" inquire = "0.6.2" next_version = "0.2.13" git_cmd = "0.4.20" +serde_yaml = "0.9.33" diff --git a/updater/src/main.rs b/updater/src/main.rs index 6576880..3ad56ce 100644 --- a/updater/src/main.rs +++ b/updater/src/main.rs @@ -32,7 +32,12 @@ pub fn latest_release(repo: &str) -> String { let last_tag = String::from_utf8(last_tag.stdout).unwrap(); let last_tag = last_tag.trim(); println!("latest tag: {repo}: `{}`", last_tag); - last_tag.split_whitespace().next().unwrap().to_string() + last_tag + .split_whitespace() + .next() + .unwrap() + .trim_start_matches("v") + .to_string() } fn verify_release_plz_tag(release_plz_tag: &str) { diff --git a/updater/src/pr.rs b/updater/src/pr.rs index e070b15..6825b84 100644 --- a/updater/src/pr.rs +++ b/updater/src/pr.rs @@ -1,40 +1,21 @@ use std::process::Command; -use crate::{latest_release, ACTION_YML_PATH}; - -fn release_plz_line(action_yml: &str) -> Option { - for line in action_yml.lines() { - if line.starts_with(" default: \"release-plz-v") { - return Some(line.to_string()); - } - } - None -} - -fn cargo_semver_checks_line(action_yml: &str) -> Option { - for line in action_yml.lines() { - if line.starts_with(" tag: v") { - return Some(line.to_string()); - } - } - None -} - -fn new_release_plz_line(latest_release: &str) -> String { - format!(" default: \"{}\"", latest_release) -} - -fn new_cargo_semver_checks_line() -> String { - let cargo_semver_checks_tag = latest_release("obi1kenobi/cargo-semver-checks"); - format!(" tag: {}", cargo_semver_checks_tag) +use crate::ACTION_YML_PATH; + +fn release_plz_version() -> String { + let action_yml = std::fs::read_to_string(ACTION_YML_PATH).unwrap(); + let yml: serde_yaml::Value = serde_yaml::from_str(&action_yml).unwrap(); + yml["inputs"]["version"]["default"] + .as_str() + .unwrap() + .to_string() } pub fn update_action_yml(release_plz_tag: &str) { let mut action_yml = std::fs::read_to_string(ACTION_YML_PATH).unwrap(); - let release_plz_line = release_plz_line(&action_yml).unwrap(); - action_yml = action_yml.replace(&release_plz_line, &new_release_plz_line(release_plz_tag)); - let cargo_semver_checks_line = cargo_semver_checks_line(&action_yml).unwrap(); - action_yml = action_yml.replace(&cargo_semver_checks_line, &new_cargo_semver_checks_line()); + let current_release_plz_version = release_plz_version(); + action_yml = action_yml.replace(¤t_release_plz_version, release_plz_tag); + // TODO update cargo-semver-checks std::fs::write(ACTION_YML_PATH, action_yml).unwrap(); }