Compare commits

..

20 Commits

Author SHA1 Message Date
20f340e14f Merge branch 'jenkins' into installer
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	Jenkinsfile
#	src/main.rs
#	src/update.rs
2023-02-13 20:11:14 +01:00
208a4e9e79 Use Jenkins for updates
Some checks failed
Gitea Organization/dotfiles/pipeline/head This commit looks good
Gitea Organization/dotfiles/pipeline/pr-installer There was a failure building this commit
2023-02-13 20:05:20 +01:00
1c235d1949 Fixed warnings
All checks were successful
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good
2023-02-12 23:32:30 +01:00
60fce326dd Use commit for version again
All checks were successful
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good
2023-02-12 23:30:26 +01:00
cb8ef1e2e8 Switched update to gitea
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good
2023-02-12 23:15:09 +01:00
577d9519fa Removed gitlab CI 2023-02-12 22:39:29 +01:00
6fed41de0a Testing with Jenkins
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
2023-02-12 22:36:36 +01:00
d5abe0c38a Testing with Jenkins
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
2023-02-12 22:21:58 +01:00
5657c570df Testing with Jenkins
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
2023-02-12 22:13:29 +01:00
4f09a0eb81 Testing with Jenkins
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
2023-02-11 16:59:41 +01:00
8461871d7a Testing with Jenkins
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
2023-02-11 16:44:55 +01:00
a2bdd281cc Testing with Jenkins
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
2023-02-11 16:36:38 +01:00
181a2e3753 Testing with Jenkins
Some checks failed
Gitea Organization/dotfiles/pipeline/head There was a failure building this commit
2023-02-11 16:34:41 +01:00
5ad952d37e Testing with Jenkins
Some checks failed
Gitea Organization/dotfiles/pipeline/head There was a failure building this commit
2023-02-11 13:47:23 +01:00
9798dfe5cb Testing with Jenkins
All checks were successful
Gitea Organization/dotfiles/pipeline/head This commit looks good
2023-02-11 13:02:39 +01:00
c587705f5a Testing with Jenkins
Some checks failed
Gitea Organization/dotfiles/pipeline/head There was a failure building this commit
2023-02-11 12:44:44 +01:00
21b30a441f Testing with Jenkins
Some checks failed
Gitea Organization/dotfiles/pipeline/head There was a failure building this commit
2023-02-11 12:44:02 +01:00
ff18cd16ce Testing with Jenkins
Some checks failed
Gitea Organization/dotfiles/pipeline/head There was a failure building this commit
2023-02-11 12:40:40 +01:00
0b7af4e3d7 Testing with Jenkins
Some checks failed
Gitea Organization/dotfiles/pipeline/head There was a failure building this commit
2023-02-11 12:22:46 +01:00
77b6e2aba3 Testing with Jenkins
Some checks failed
Gitea Organization/dotfiles/pipeline/head There was a failure building this commit
2023-02-11 12:21:44 +01:00
5 changed files with 35 additions and 48 deletions

43
Cargo.lock generated
View File

@ -8,11 +8,10 @@ version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b85f766c20e6ae766956f7a2fcc4e0931e79a7e1f48b29132b5d647021114914"
dependencies = [
"base64",
"http",
"log",
"rustls",
"serde",
"serde_json",
"url",
"webpki",
"webpki-roots",
@ -24,6 +23,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "bitflags"
version = "1.3.2"
@ -87,7 +92,6 @@ dependencies = [
"dialoguer",
"indicatif",
"serde",
"serde_json",
"toml",
]
@ -317,12 +321,6 @@ dependencies = [
"webpki",
]
[[package]]
name = "ryu"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
[[package]]
name = "sct"
version = "0.7.0"
@ -353,22 +351,11 @@ dependencies = [
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c68e921cef53841b8925c2abadd27c9b891d9613bdc43d6b823062866df38e8"
checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
dependencies = [
"serde",
]
@ -427,9 +414,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "toml"
version = "0.6.0"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb9d890e4dc9298b70f740f615f2e05b9db37dce531f6b24fb77ac993f9f217"
checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6"
dependencies = [
"serde",
"serde_spanned",
@ -439,18 +426,18 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "0.5.1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.18.0"
version = "0.19.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "729bfd096e40da9c001f778f5cdecbd2957929a24e10e5883d9392220a751581"
checksum = "5e6a7712b49e1775fb9a7b998de6635b299237f48b404dde71704f2e0e7f37e5"
dependencies = [
"indexmap",
"nom8",

View File

@ -8,8 +8,7 @@ edition = "2021"
[dependencies]
dialoguer = "0.10.3"
indicatif = "0.17.3"
toml = "0.6.0"
serde_json = "1.0.93"
toml = "0.7.2"
[dependencies.serde]
version = "1.0.152"
@ -19,6 +18,6 @@ features = ["derive"]
version = "0.24.0"
default_features = false
features = [
"json",
"basic-auth",
"tls-rustls-webpki-roots"
]

4
Jenkinsfile vendored
View File

@ -10,10 +10,10 @@ pipeline {
TOKEN = credentials('abd7020c-43d6-485b-ae09-2f9b484d9c15')
}
steps {
sh 'apk add pkgconf musl-dev curl'
sh 'apk add pkgconf musl-dev'
sh 'cargo build --release --target x86_64-unknown-linux-musl'
sh 'cp target/x86_64-unknown-linux-musl/release/dotfiles_installer ./installer-amd64'
sh 'curl -H "Authorization: token ${TOKEN_PSW}" --upload-file ./installer-amd64 https://gitea.mattv.de/api/packages/root/generic/installer/${GIT_COMMIT}/installer-amd64'
archiveArtifacts artifacts: 'installer-amd64', allowEmptyArchive: false, onlyIfSuccessful: true
}
}
}

View File

@ -29,9 +29,9 @@ impl ToString for MainMenu {
}
fn main() {
if let Some(version) = option_env!("GIT_COMMIT") {
println!("Starting installer version {}", version);
update::check_for_updates(version);
if let (Some(version), Some(name)) = (option_env!("BUILD_ID"), option_env!("JOB_BASE_NAME")) {
println!("Starting installer version {name}-{version}");
update::check_for_updates(version.parse().unwrap(), name);
} else {
println!("Starting installer version unknown");
}

View File

@ -4,24 +4,25 @@ use std::fs::File;
use std::os::unix::process::CommandExt;
use std::path::Path;
const GITEA_KEY: &str = "786666bd8bce93c562c4fc4c83933faa6cbdc802";
const JENKINS_KEY: &str = "1196373359a3f17bbb8f0f5685b8152276";
pub fn check_for_updates(version: &str) {
pub fn check_for_updates(version: u64, name: &str) {
print!("Checking for updates... ");
let resp: serde_json::Value = attohttpc::get("https://gitea.mattv.de/api/v1/repos/root/dotfiles/branches/installer")
.header("accept", "application/json")
.header("Authorization", format!("token {GITEA_KEY}"))
.send().unwrap().json().unwrap();
let newest = resp["commit"]["id"].as_str().unwrap();
if newest != version {
println!("New version {newest}");
let newest: u64 = attohttpc::get(format!("https://jenkins.mattv.de/job/Gitea%20Organization/job/dotfiles/job/{name}/lastSuccessfulBuild/buildNumber"))
.basic_auth("root", Some(JENKINS_KEY))
.send().unwrap()
.text().unwrap()
.parse().unwrap();
if newest > version {
println!("New version {name}-{newest}");
let exe = current_exe().unwrap();
let temp = Path::new("temp");
print!("Downloading... ");
attohttpc::get(format!("https://gitea.mattv.de/api/packages/root/generic/installer/{newest}/installer-amd64"))
.header("Authorization", format!("token {GITEA_KEY}"))
.send().unwrap().write_to(File::create(temp).unwrap()).unwrap();
attohttpc::get(format!("https://jenkins.mattv.de/job/Gitea%20Organization/job/dotfiles/job/{name}/{newest}/artifact/installer-amd64"))
.basic_auth("root", Some(JENKINS_KEY))
.send().unwrap()
.write_to(File::create(temp).unwrap()).unwrap();
println!("Done");
fs::set_permissions(&temp, exe.metadata().unwrap().permissions()).unwrap();