Use commit for version again
All checks were successful
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good
All checks were successful
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good
This commit is contained in:
parent
cb8ef1e2e8
commit
60fce326dd
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -87,6 +87,7 @@ dependencies = [
|
||||
"dialoguer",
|
||||
"indicatif",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"toml",
|
||||
]
|
||||
|
||||
@ -354,9 +355,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.91"
|
||||
version = "1.0.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
|
||||
checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
|
@ -9,6 +9,7 @@ edition = "2021"
|
||||
dialoguer = "0.10.3"
|
||||
indicatif = "0.17.3"
|
||||
toml = "0.6.0"
|
||||
serde_json = "1.0.93"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0.152"
|
||||
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -13,7 +13,7 @@ pipeline {
|
||||
sh 'apk add pkgconf musl-dev curl'
|
||||
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/${BUILD_NUMBER}/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'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ impl ToString for MainMenu {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if let Some(version) = option_env!("BUILD_NUMBER") {
|
||||
if let Some(version) = option_env!("GIT_COMMIT") {
|
||||
println!("Starting installer version {}", version);
|
||||
update::check_for_updates(version);
|
||||
} else {
|
||||
|
@ -10,19 +10,16 @@ struct PackageEntry {
|
||||
version: String
|
||||
}
|
||||
|
||||
const GITEA_KEY: &str = "1e9527c38c98b297dbdaaf39c060e075b2729464";
|
||||
const GITEA_KEY: &str = "786666bd8bce93c562c4fc4c83933faa6cbdc802";
|
||||
|
||||
pub fn check_for_updates(version: &str) {
|
||||
let version: u64 = version.parse().unwrap();
|
||||
print!("Checking for updates... ");
|
||||
let resp: Vec<PackageEntry> = attohttpc::get("https://gitea.mattv.de/api/v1/packages/root?type=generic&q=installer")
|
||||
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.into_iter()
|
||||
.map(|entry| entry.version.parse::<u64>().unwrap())
|
||||
.max().unwrap();
|
||||
if newest > version {
|
||||
let newest = resp["commit"]["id"].as_str().unwrap();
|
||||
if newest != version {
|
||||
println!("New version {newest}");
|
||||
let exe = current_exe().unwrap();
|
||||
let temp = Path::new("temp");
|
||||
|
Loading…
Reference in New Issue
Block a user