Files
wasmtime/ci/find-latest-release.rs
Alex Crichton bea0433b54 Fix the release process's latest step (#4055)
* Fix the release process's latest step

The automated release of 0.36.0 was attempted last night but it failed
due to a [failure on CI][bad]. This failure comes about because it was
trying to change the release date of 0.35.0 which ended up not modifying
any fails so `git` failed to commit as no files were changed.

The original bug though was that 0.35.0 was being changed instead of
0.36.0. The reason for this is that the script used
`--sort=-committerdate` to determine the latest branch. I forgot,
though, that with backports it's possible for 0.35.0 to have a more
recent commit date than 0.36.0 (as is currently the case). This commit
updates the script to perform a numerical sort outside of git to get the
latest release branch.

Additionally this adds in some `set -ex` commands for the shell which
should help print out commands as they're run and assist in future
debugging.

[bad]: https://github.com/bytecodealliance/wasmtime/runs/6087188708

* Replace sed with rust
2022-04-20 13:31:38 -05:00

27 lines
891 B
Rust

use std::process::Command;
fn main() {
let output = Command::new("git")
.arg("for-each-ref")
.arg("refs/remotes/origin")
.arg("--format")
.arg("%(refname)")
.output()
.unwrap();
assert!(output.status.success());
let mut releases = std::str::from_utf8(&output.stdout)
.unwrap()
.lines()
.filter_map(|l| l.strip_prefix("refs/remotes/origin/release-"))
.filter_map(|l| {
let mut parts = l.split('.');
let major = parts.next()?.parse::<u32>().ok()?;
let minor = parts.next()?.parse::<u32>().ok()?;
let patch = parts.next()?.parse::<u32>().ok()?;
Some((major, minor, patch))
})
.collect::<Vec<_>>();
releases.sort();
let (major, minor, patch) = releases.last().unwrap();
println!("{}.{}.{}", major, minor, patch);
}