Compare commits
2 commits
1908c5ce73
...
0b7011b839
Author | SHA1 | Date | |
---|---|---|---|
Aode (lion) | 0b7011b839 | ||
Aode (lion) | f8b9b9fcb9 |
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -906,7 +906,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
|||
|
||||
[[package]]
|
||||
name = "release-checker"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"color-eyre",
|
||||
"regex",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "release-checker"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
9
examples/github/Check.toml
Normal file
9
examples/github/Check.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[project]
|
||||
kind = "github"
|
||||
namespace = "nolanlawson"
|
||||
repository = "pinafore"
|
||||
|
||||
[gitea]
|
||||
domain = "git.asonix.dog"
|
||||
owner = "asonix"
|
||||
repo = "docker-pinafore"
|
|
@ -13,6 +13,12 @@ pub(crate) struct CheckConfig {
|
|||
pub(crate) enum ProjectConfig {
|
||||
None,
|
||||
|
||||
#[serde(rename = "github")]
|
||||
Github {
|
||||
namespace: String,
|
||||
repository: String,
|
||||
},
|
||||
|
||||
#[serde(rename = "dockerhub")]
|
||||
DockerHub {
|
||||
namespace: String,
|
||||
|
|
40
src/github.rs
Normal file
40
src/github.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
use crate::{revision::Revision, BuildDirective};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct Release {
|
||||
tag_name: String,
|
||||
}
|
||||
|
||||
pub(crate) async fn check_github_release(
|
||||
namespace: String,
|
||||
repository: String,
|
||||
previous_revision: &Revision,
|
||||
) -> color_eyre::eyre::Result<BuildDirective> {
|
||||
let github_client = reqwest::Client::builder()
|
||||
.user_agent("release-checker (+https://git.asonix.dog/asonix/release-checker)")
|
||||
.build()?;
|
||||
|
||||
let url = format!(
|
||||
"https://api.github.com/repos/{}/{}/releases",
|
||||
namespace, repository,
|
||||
);
|
||||
|
||||
let releases: Vec<Release> = github_client
|
||||
.get(url)
|
||||
.header("Accept", "application/vnd.github.v3+json")
|
||||
.send()
|
||||
.await?
|
||||
.json()
|
||||
.await?;
|
||||
|
||||
if let Some(release) = releases.get(0) {
|
||||
if release.tag_name.trim_start_matches('v')
|
||||
== previous_revision.version.trim_start_matches('v')
|
||||
{
|
||||
return Ok(BuildDirective::ShouldIgnore);
|
||||
}
|
||||
return Ok(BuildDirective::ShouldBuild(Some(release.tag_name.clone())));
|
||||
}
|
||||
|
||||
Ok(BuildDirective::ShouldIgnore)
|
||||
}
|
|
@ -3,6 +3,7 @@ mod config;
|
|||
mod dockerhub;
|
||||
mod git;
|
||||
mod gitea;
|
||||
mod github;
|
||||
mod init_tracing;
|
||||
mod revision;
|
||||
|
||||
|
@ -11,6 +12,7 @@ use config::{CheckConfig, ProjectConfig};
|
|||
use dockerhub::check_dockerhub_image;
|
||||
use git::check_git_project;
|
||||
use gitea::{build_client, create_tag, get_previous_revision};
|
||||
use github::check_github_release;
|
||||
use init_tracing::init_tracing;
|
||||
use revision::Revision;
|
||||
|
||||
|
@ -39,6 +41,10 @@ async fn check_project(
|
|||
repository,
|
||||
regex,
|
||||
} => check_dockerhub_image(namespace, repository, regex, previous_revision).await,
|
||||
ProjectConfig::Github {
|
||||
namespace,
|
||||
repository,
|
||||
} => check_github_release(namespace, repository, previous_revision).await,
|
||||
ProjectConfig::None => Ok(BuildDirective::ShouldBuild(None)),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue