add updater

This commit is contained in:
Kasper Juul Hermansen 2023-04-03 00:18:32 +02:00
parent 79ef3ecc43
commit 2f687b633a
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
4 changed files with 35 additions and 20 deletions

10
Cargo.lock generated
View File

@ -478,15 +478,6 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "111.25.1+1.1.1t"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ef9a9cc6ea7d9d5e7c4a913dc4b48d0e359eddf01af1dfec96ba7064b4aba10"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.84" version = "0.9.84"
@ -495,7 +486,6 @@ checksum = "3a20eace9dc2d82904039cb76dcf50fb1a0bba071cfd1629720b5d6f1ddba0fa"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
"openssl-src",
"pkg-config", "pkg-config",
"vcpkg", "vcpkg",
] ]

View File

@ -6,14 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
git2 = { version = "0.16.1" }
clap = "4.2.1" clap = "4.2.1"
color-eyre = "0.6.2" color-eyre = "0.6.2"
dotenv = "0.15.0" dotenv = "0.15.0"
eyre = "0.6.8" eyre = "0.6.8"
git2 = { version = "0.16.1", features = [
"vendored-libgit2",
"vendored-openssl",
] }
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.159", features = ["derive"] }
serde_json = "1.0.95" serde_json = "1.0.95"
serde_yaml = "0.9.19" serde_yaml = "0.9.19"

View File

@ -12,11 +12,11 @@ async fn main() -> eyre::Result<()> {
let src = client.host().directory_opts( let src = client.host().directory_opts(
".", ".",
HostDirectoryOptsBuilder::default() HostDirectoryOptsBuilder::default()
.exclude(vec!["target/", ".git/"]) .exclude(vec!["target/", ".git/", "ci/"])
.build()?, .build()?,
); );
let variants = vec!["linux/amd64", "linux/arm64"]; let variants = vec![/*"linux/amd64", */ "linux/arm64"];
let platform_variants = Arc::new(Mutex::new(Vec::new())); let platform_variants = Arc::new(Mutex::new(Vec::new()));
tokio_scoped::scope(|s| { tokio_scoped::scope(|s| {
@ -35,6 +35,31 @@ async fn main() -> eyre::Result<()> {
) )
.from("rustlang/rust:nightly") .from("rustlang/rust:nightly")
.with_workdir("/app") .with_workdir("/app")
//.with_exec(vec!["apt-get", "update"])
//.with_exec(vec![
// "apt-get",
// "install",
// "-y",
// "build-essential",
// "cmake",
// "curl",
// "file",
// "git",
// "sudo",
// "xutils-dev",
// "unzip",
// "ca-certificates",
// "python3",
// "python3-pip",
// "autoconf",
// "autoconf-archive",
// "automake",
// "flex",
// "bison",
// "llvm-dev",
// "libclang-dev",
// "clang",
//])
.with_directory(".", src.id().await.unwrap()) .with_directory(".", src.id().await.unwrap())
.with_exec(vec!["cargo", "build", "--release"]); .with_exec(vec!["cargo", "build", "--release"]);
@ -46,6 +71,8 @@ async fn main() -> eyre::Result<()> {
.unwrap(), .unwrap(),
) )
.from("debian:bullseye") .from("debian:bullseye")
.with_exec(vec!["apt-get", "update"])
.with_exec(vec!["apt-get", "install", "-y", "openssl", "git"])
.with_file( .with_file(
"/usr/bin/update-deployment", "/usr/bin/update-deployment",
rust_dep_image rust_dep_image
@ -53,7 +80,8 @@ async fn main() -> eyre::Result<()> {
.id() .id()
.await .await
.unwrap(), .unwrap(),
); )
.with_exec(vec!["update-deployment", "--help"]);
let mut platform_variants = platform_variants.lock().await; let mut platform_variants = platform_variants.lock().await;
platform_variants.push(dep_image.id().await.unwrap()) platform_variants.push(dep_image.id().await.unwrap())

View File

@ -1,12 +1,12 @@
use git2::build::{CheckoutBuilder, RepoBuilder}; use git2::build::{CheckoutBuilder, RepoBuilder};
use git2::{Cred, FetchOptions, PushOptions, RemoteCallbacks}; use git2::{Cred, FetchOptions, PushOptions, RemoteCallbacks, Signature};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_yaml::Value; use serde_yaml::Value;
use tempdir::TempDir; use tempdir::TempDir;
#[tokio::main] #[tokio::main]
async fn main() -> eyre::Result<()> { async fn main() -> eyre::Result<()> {
dotenv::dotenv()?; let _ = dotenv::dotenv();
color_eyre::install().unwrap(); color_eyre::install().unwrap();
tracing_subscriber::fmt().pretty().init(); tracing_subscriber::fmt().pretty().init();
@ -98,7 +98,7 @@ async fn main() -> eyre::Result<()> {
index.write_tree()? index.write_tree()?
}; };
let sig = repo.signature()?; let sig = Signature::now("kjuulh", "contact@kjuulh.io")?;
let tree = repo.find_tree(tree_id)?; let tree = repo.find_tree(tree_id)?;
let head = repo.head()?; let head = repo.head()?;