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

Feature/caddy #70

Merged
merged 10 commits into from
Jul 14, 2024
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
7 changes: 5 additions & 2 deletions .github/workflows/gg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ jobs:
target: x86_64-apple-darwin
stage4: x86_64-apple-darwin
# TODO: Version too new
- os: macos-12
target: x86_64-apple-darwin
stage4: x86_64-apple-darwin
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
stage4: x86_64-unknown-linux-musl
Expand Down Expand Up @@ -252,7 +255,7 @@ jobs:
needs: stage1
strategy:
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022, macOS-11, macOS-12 ]
os: [ ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022, macOS-12 ]
cmd: [ "node -v", "java -version", "gradle -version", "maven -v", "openapi version", "rat -V", "run:java@14 java -version", "deno -V" ]

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -341,7 +344,7 @@ jobs:
needs: stage1
strategy:
matrix:
container: [ ubuntu, debian, alpine, archlinux, 'ubuntu:14.04', 'ubuntu:18.04' ]
container: [ ubuntu, debian, alpine, archlinux ]
cmd: [ "node@14 -v", "java -version", "gradle -version", "maven -v", "openapi version", "rat -V", "run:java@14 java -version" ]

runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion src/stage4/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use semver::{Version, VersionReq};
use serde::{Deserialize, Serialize};
use which::which_in;
use crate::bloody_indiana_jones::BloodyIndianaJones;

use crate::executors::caddy::Caddy;
use crate::executors::custom_command::CustomCommand;
use crate::executors::deno::Deno;
use crate::executors::go::Go;
Expand Down Expand Up @@ -151,6 +151,7 @@ impl dyn Executor {
"run" => Some(Box::new(CustomCommand { executor_cmd })),
"deno" => Some(Box::new(Deno { executor_cmd })),
"go" => Some(Box::new(Go { executor_cmd })),
"caddy" => Some(Box::new(Caddy { executor_cmd })),
_ => None,
}
}
Expand Down
73 changes: 73 additions & 0 deletions src/stage4/src/executors/caddy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use std::collections::HashSet;
use std::future::Future;
use std::pin::Pin;

use crate::executor::{AppInput, Download, Executor, ExecutorCmd, GgVersion};
use crate::target::{Arch, Os, Variant};
use crate::target::Os::Windows;

pub struct Caddy {
pub executor_cmd: ExecutorCmd,
}

impl Executor for Caddy {
fn get_executor_cmd(&self) -> &ExecutorCmd {
&self.executor_cmd
}

fn get_download_urls<'a>(&self, _input: &'a AppInput) -> Pin<Box<dyn Future<Output=Vec<Download>> + 'a>> {
Box::pin(async move {
let mut downloads: Vec<Download> = vec!();
let octocrab = octocrab::Octocrab::builder().base_uri("https://ghapi.ggcmd.io/").unwrap().build().unwrap();
let mut page: u32 = 1;
loop {
let releases = octocrab.repos("caddyserver", "caddy")
.releases().list().page(page).per_page(100).send().await.unwrap();
for release in releases.items {
for asset in release.assets {
let os = if asset.name.contains("windows") {
Some(Windows)
} else if asset.name.contains("linux") {
Some(Os::Linux)
} else if asset.name.contains("apple") {
Some(Os::Mac)
} else {
None
};
let arch = if asset.name.contains("amd64") {
Some(Arch::X86_64)
} else {
None
};
if os.is_some() && arch.is_some() {
downloads.push(Download {
download_url: asset.browser_download_url.to_string(),
version: GgVersion::new(release.tag_name.as_str()),
os,
arch,
tags: HashSet::new(),
variant: Some(Variant::Any),
});
}
}
}
if releases.next == None {
break;
}
page += 1;
}
downloads
})
}

fn get_bins(&self, input: &AppInput) -> Vec<String> {
vec!(match &input.target.os {
Windows => "caddy.exe",
_ => "caddy"
}.to_string())
}

fn get_name(&self) -> &str {
"caddy"
}
}
2 changes: 1 addition & 1 deletion src/stage4/src/executors/deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Executor for Deno {
fn get_download_urls<'a>(&self, _input: &'a AppInput) -> Pin<Box<dyn Future<Output=Vec<Download>> + 'a>> {
Box::pin(async move {
let mut downloads: Vec<Download> = vec!();
let octocrab = octocrab::Octocrab::builder().base_uri("https://ggcmddenogithubreleases.azureedge.net/").unwrap().build().unwrap();
let octocrab = octocrab::Octocrab::builder().base_uri("https://ghapi.ggcmd.io/").unwrap().build().unwrap();
let mut page: u32 = 1;
loop {
let releases = octocrab.repos("denoland", "deno")
Expand Down
1 change: 0 additions & 1 deletion src/stage4/src/executors/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct Root2 {
pub features: Vec<String>,
#[serde(rename = "hw_bitness")]
pub hw_bitness: String,
pub id: i64,
#[serde(rename = "java_version")]
pub java_version: Vec<i64>,
pub javafx: bool,
Expand Down
1 change: 1 addition & 0 deletions src/stage4/src/executors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub mod node;
pub mod deno;
pub mod gradle_properties;
pub mod go;
pub mod caddy;
Loading