diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5e69891..86378af 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,9 +1,8 @@
stages:
- build
- - release
variables:
- PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/installer/"
+ PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/installer"
build:
stage: build
@@ -12,43 +11,13 @@ build:
- if: $CI_COMMIT_BRANCH == "installer"
script:
- export CARGO_HOME="${PWD}/.cargo"
- - apk add pkgconf musl-dev
+ - apk add pkgconf musl-dev curl
- RUSTFLAGS='-C target-feature=+crt-static -C link-self-contained=yes -C link-arg=-s' cargo build --release --target x86_64-unknown-linux-musl
- cp target/x86_64-unknown-linux-musl/release/dotfiles_installer ./installer-amd64
+ - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file installer-amd64 "${PACKAGE_REGISTRY_URL}/dev-$CI_COMMIT_SHORT_SHA/installer-amd64"'
artifacts:
paths:
- installer-amd64
cache:
paths:
- .cargo/
-
-
-upload_assets:
- stage: release
- image: curlimages/curl:latest
- rules:
- - if: $CI_COMMIT_BRANCH == "installer"
- needs:
- - job: build
- artifacts: true
- script:
- - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file installer-amd64 "${PACKAGE_REGISTRY_URL}/dev-$CI_COMMIT_SHORT_SHA/installer-amd64"'
-
-create_release:
- stage: release
- image: registry.gitlab.com/gitlab-org/release-cli:latest
- rules:
- - if: $CI_COMMIT_BRANCH == "installer"
- needs:
- - upload_assets
- script:
- - echo "running release_job"
- release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
- tag_name: 'dev-$CI_COMMIT_SHORT_SHA'
- description: 'Release dev-$CI_COMMIT_SHORT_SHA'
- assets:
- links:
- - name: 'installer-amd64'
- url: '${PACKAGE_REGISTRY_URL}/dev-$CI_COMMIT_SHORT_SHA/installer-amd64'
- link_type: package
-
diff --git a/src/update.rs b/src/update.rs
index c851e4a..a20e201 100644
--- a/src/update.rs
+++ b/src/update.rs
@@ -6,37 +6,27 @@ use std::path::Path;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
-struct Commit {
- id: String
+struct Pipeline {
+ sha: String
}
#[derive(Debug, Deserialize)]
-struct Link {
- direct_asset_url: String
-}
-
-#[derive(Debug, Deserialize)]
-struct Assets {
- links: Vec
-}
-
-#[derive(Debug, Deserialize)]
-struct ReleaseEntry {
- commit: Commit,
- assets: Assets
+struct PackageEntry {
+ version: String,
+ pipeline: Pipeline
}
pub fn check_for_updates(version: &str) {
print!("Checking for updates... ");
- let resp: Vec = attohttpc::get("https://gitlab.mattv.de/api/v4/projects/43/releases").send().unwrap().json().unwrap();
+ let resp: Vec = attohttpc::get("https://gitlab.mattv.de/api/v4/projects/43/packages?name=installer&sort=desc").send().unwrap().json().unwrap();
let newest = resp.first().unwrap();
- if newest.commit.id != version {
+ if newest.pipeline.sha != version {
println!("New version exists");
let exe = current_exe().unwrap();
let temp = Path::new("temp");
print!("Downloading... ");
- attohttpc::get(newest.assets.links.first().unwrap().direct_asset_url.clone()).send().unwrap().write_to(File::create(temp).unwrap()).unwrap();
+ attohttpc::get(format!("https://gitlab.mattv.de/api/v4/projects/43/packages/generic/installer/{}/installer-amd64", newest.version)).send().unwrap().write_to(File::create(temp).unwrap()).unwrap();
println!("Done");
fs::set_permissions(&temp, exe.metadata().unwrap().permissions()).unwrap();