Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preverify release version #3859

Merged
merged 6 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ commands:
key: "<< pipeline.parameters.merge_version >>-lint"
paths:
- target
xtask_release_preverify:
steps:
- run: xtask release pre-verify

xtask_check_helm:
steps:
Expand Down Expand Up @@ -525,6 +528,18 @@ jobs:
cargo fetch
- xtask_test:
variant: "updated"
pre_verify_release:
environment:
<<: *common_job_environment
parameters:
platform:
type: executor
executor: << parameters.platform >>
steps:
- checkout
- setup_environment:
platform: << parameters.platform >>
- xtask_release_preverify

build_release:
parameters:
Expand Down Expand Up @@ -839,6 +854,15 @@ workflows:
when:
not: << pipeline.parameters.nightly >>
jobs:
- pre_verify_release:
matrix:
parameters:
platform: [ amd_linux_build ]
filters:
branches:
ignore: /.*/
tags:
only: /v.*/
- build_release:
matrix:
parameters:
Expand Down
44 changes: 44 additions & 0 deletions xtask/src/commands/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ use crate::commands::changeset::slurp_and_remove_changesets;
pub enum Command {
/// Prepare a new release
Prepare(Prepare),

/// Verify that a release is ready to be published
PreVerify,
}

impl Command {
pub fn run(&self) -> Result<()> {
match self {
Command::Prepare(command) => command.run(),
Command::PreVerify => PreVerify::run(),
}
}
}
Expand Down Expand Up @@ -410,3 +414,43 @@ impl Prepare {
Ok(())
}
}

struct PreVerify();

impl PreVerify {
fn run() -> Result<()> {
let version = format!("v{}", *PKG_VERSION);

// Get the git tag name as a string
let tags_output = std::process::Command::new("git")
.args(["describe", "--tags", "--exact-match"])
.output()
.map_err(|e| {
anyhow!(
"failed to execute 'git describe --tags --exact-match': {}",
e
)
})?
.stdout;
let tags_raw = String::from_utf8_lossy(&tags_output);
let tags_list = tags_raw
.split("\n")
.filter(|s| !s.trim().is_empty())
.collect::<Vec<_>>();

// If the tags contains the version, then we're good
if tags_list.is_empty() {
return Err(anyhow!(
"release cannot be performed because current git tree is not tagged"
));
}
if !tags_list.contains(&version.as_str()) {
return Err(anyhow!(
"the git tree tags {{{}}} does not contain the version {} from the Cargo.toml",
tags_list.join(", "),
version
));
}
Ok(())
}
}