Skip to content

Commit

Permalink
Merge pull request #1482 from hannobraun/automation
Browse files Browse the repository at this point in the history
Expand and clean up release automation
  • Loading branch information
hannobraun authored Jan 5, 2023
2 parents f28205f + 86743da commit 4e1ebf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 35 deletions.
14 changes: 9 additions & 5 deletions tools/automator/src/announcement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub async fn create_release_announcement(
let now = Utc::now();

let year = now.year();
let week = now.iso_week().week();
let week = format!("{:02}", now.iso_week().week());
let date = format!("{year}-{:02}-{:02}", now.month(), now.day());

let pull_requests_since_last_release =
Expand All @@ -42,9 +42,9 @@ pub async fn create_release_announcement(
.await?
.as_markdown(min_dollars, for_readme)?;

let mut file = create_file(year, week).await?;
let mut file = create_file(year, &week).await?;
generate_announcement(
week,
&week,
date,
version.to_string(),
sponsors,
Expand All @@ -56,11 +56,15 @@ pub async fn create_release_announcement(
Ok(())
}

async fn create_file(year: i32, week: u32) -> anyhow::Result<File> {
async fn create_file(year: i32, week: &str) -> anyhow::Result<File> {
let dir =
PathBuf::from(format!("content/blog/weekly-release/{year}-w{week}"));
let file = dir.join("index.md");

// VS Code (and probably other editors/IDEs) renders the path in the output
// as a clickable link, so the user can open the file easily.
println!("Generating release announcement at {}", file.display());

fs::create_dir_all(&dir).await.with_context(|| {
format!("Failed to create directory `{}`", dir.display())
})?;
Expand All @@ -72,7 +76,7 @@ async fn create_file(year: i32, week: u32) -> anyhow::Result<File> {
}

async fn generate_announcement(
week: u32,
week: &str,
date: String,
version: String,
sponsors: String,
Expand Down
30 changes: 0 additions & 30 deletions tools/release-operator/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,36 +219,6 @@ impl Crate {
break;
}

let delay = Duration::from_secs(10);
let start_time = Instant::now();
let timeout = Duration::from_secs(600);

log::info!(
"{self} should appear as {ours} on the registry, waiting... [{delay:?}|{timeout:?}]"
);

loop {
if Instant::now() - start_time > timeout {
return Err(anyhow!("{self} did not appear as {ours} on the registry within {timeout:?}"));
}

let theirs = self.get_upstream_version()?;

match theirs.cmp(&ours) {
std::cmp::Ordering::Less => (),
std::cmp::Ordering::Equal => {
log::info!("{self} appeared as {ours} on the registry");
break;
}
std::cmp::Ordering::Greater => {
return Err(anyhow!("{self} appeared as {theirs} on the registry which is newer than the current release ({ours})"))
},
}

log::info!("{self} waiting for {ours}...");
std::thread::sleep(delay);
}

Ok(())
}
}
Expand Down

0 comments on commit 4e1ebf1

Please sign in to comment.