Skip to content

Commit

Permalink
Update to release-plz-v0.3.90
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoieni committed Sep 16, 2024
1 parent 61d4f42 commit ec4be37
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 34 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
74 changes: 74 additions & 0 deletions updater/Cargo.lock

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

1 change: 1 addition & 0 deletions updater/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 6 additions & 1 deletion updater/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
43 changes: 12 additions & 31 deletions updater/src/pr.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
use std::process::Command;

use crate::{latest_release, ACTION_YML_PATH};

fn release_plz_line(action_yml: &str) -> Option<String> {
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<String> {
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(&current_release_plz_version, release_plz_tag);
// TODO update cargo-semver-checks
std::fs::write(ACTION_YML_PATH, action_yml).unwrap();
}

Expand Down

0 comments on commit ec4be37

Please sign in to comment.