Merge pull request #1325 from hannobraun/release

Fix bugs in release automation
This commit is contained in:
Hanno Braun 2022-11-08 11:26:30 +01:00 committed by GitHub
commit 88a0266c6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 11 deletions

View File

@ -95,14 +95,12 @@ async fn generate_announcement(
title,
url,
author,
..
} = pull_request;
let author = if authors.contains(&author.name)
|| author_blacklist.contains(author.name.as_str())
{
let author = if author_blacklist.contains(author.name.as_str()) {
None
} else {
authors.insert(author.name.clone());
Some(author)
};
@ -118,8 +116,12 @@ async fn generate_announcement(
pull_request_links.push_str(&link);
if let Some(Author { name, profile }) = author {
if !authors.contains(&name) {
let author_link = format!("[@{name}]: {profile}\n");
author_links.push_str(&author_link);
authors.insert(name.clone());
}
}
}

View File

@ -2,6 +2,7 @@ use std::collections::BTreeMap;
use anyhow::anyhow;
use autolib::find_version_in_str;
use chrono::{DateTime, Utc};
use octocrab::{
models::pulls::PullRequest as OctoPullRequest,
params::{pulls::Sort, Direction, State},
@ -19,7 +20,7 @@ impl PullRequestsSinceLastRelease {
let mut pull_requests = BTreeMap::new();
let mut page = 1u32;
let version_of_last_release = 'outer: loop {
let (version_of_last_release, time_of_last_release) = 'outer: loop {
const MAX_RESULTS_PER_PAGE: u8 = 100;
println!("Fetching page {}...", page);
@ -50,8 +51,8 @@ impl PullRequestsSinceLastRelease {
pull_request.title.ok_or_else(|| {
anyhow!("Release PR is missing title")
})?;
let version = find_version_in_str(&title)?;
let version = find_version_in_str(&title)?;
let version = version.ok_or_else(|| {
anyhow!(
"Pull request title contains no version:\
@ -59,15 +60,20 @@ impl PullRequestsSinceLastRelease {
)
})?;
break 'outer version;
let time =
pull_request.merged_at.ok_or_else(|| {
anyhow!("Release PR is missing merge time")
})?;
break 'outer (version, time);
}
}
}
if pull_request.merged_at.is_none() {
let Some(merged_at) = pull_request.merged_at else {
// If it wasn't merged, we're not interested.
continue;
}
};
let number = pull_request.number;
let title = pull_request
@ -85,6 +91,7 @@ impl PullRequestsSinceLastRelease {
title,
url,
author,
merged_at,
};
pull_requests.insert(pull_request.number, pull_request);
@ -97,6 +104,10 @@ impl PullRequestsSinceLastRelease {
}
};
pull_requests.retain(|_, pull_request| {
pull_request.merged_at > time_of_last_release
});
Ok(Self {
pull_requests,
version_of_last_release,
@ -109,6 +120,7 @@ pub struct PullRequest {
pub title: String,
pub url: Url,
pub author: Author,
pub merged_at: DateTime<Utc>,
}
pub struct Author {