From c17faf9ba267022d2571d53f6534fe1c0d9feb7e Mon Sep 17 00:00:00 2001 From: Kai Kriegel Date: Tue, 28 Dec 2021 00:47:24 +0000 Subject: [PATCH] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 102 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 35 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 226885c..7169810 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,13 @@ variables: GIT_SUBMODULE_STRATEGY: recursive # CARGO_HOME: $CI_PROJECT_DIR/cargo APT_CACHE_DIR: $CI_PROJECT_DIR/apt + +stages: + - lint + - test + - build + - upload + - release # install build dependencies @@ -26,6 +33,7 @@ before_script: # Use clippy to lint the project lint:clippy: + stage: lint allow_failure: true script: - rustc --version && cargo --version # Print version info for debugging @@ -40,6 +48,7 @@ lint:clippy: # Use rustfmt to check formating of the project lint:fmt: + stage: lint allow_failure: true script: - rustc --version && cargo --version # Print version info for debugging @@ -54,6 +63,7 @@ lint:fmt: # Use cargo to test the project test:cargo: + stage: test script: - rustc --version && cargo --version # Print version info for debugging - cargo test --workspace --verbose @@ -65,41 +75,41 @@ test:cargo: - linux - docker -build:docker-master: - image: - name: gcr.io/kaniko-project/executor:v1.6.0-debug - entrypoint: [""] - before_script: - - '' - script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest - only: - - master - tags: - - linux - - docker +# build:docker-master: +# image: +# name: gcr.io/kaniko-project/executor:v1.6.0-debug +# entrypoint: [""] +# before_script: +# - '' +# script: +# - mkdir -p /kaniko/.docker +# - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json +# - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest +# only: +# - master +# tags: +# - linux +# - docker -build:docker-releases: - image: - name: gcr.io/kaniko-project/executor:v1.6.0-debug - entrypoint: [""] - before_script: - - '' - script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG - only: - - tags - tags: - - linux - - docker +# build:docker-releases: +# image: +# name: gcr.io/kaniko-project/executor:v1.6.0-debug +# entrypoint: [""] +# before_script: +# - '' +# script: +# - mkdir -p /kaniko/.docker +# - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json +# - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG +# only: +# - tags +# tags: +# - linux +# - docker build:binary: image: rust:latest - + stage: build before_script: - cp cargo-cross-config /usr/local/cargo/config - dpkg --add-architecture armhf @@ -126,12 +136,28 @@ build:binary: tags: - linux - docker - -upload: + +upload:nightly: stage: upload image: curlimages/curl:latest variables: - - PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/${CI_COMMIT_TAG}" + PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/nightly" + rules: + - if: $CI_COMMIT_TAG + script: + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/armv7-unknown-linux-gnueabihf/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-armv7-nightly" + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/x86_64-unknown-linux-gnu/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-amd64-nightly" + tags: + - linux + - docker + +upload:releases: + stage: upload + image: curlimages/curl:latest + variables: + PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/${CI_COMMIT_TAG}" rules: - if: $CI_COMMIT_TAG script: @@ -139,6 +165,9 @@ upload: curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/armv7-unknown-linux-gnueabihf/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-armv7-${CI_COMMIT_TAG}" - | curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/x86_64-unknown-linux-gnu/release/diflouroborane "${PACKAGE_REGISTRY_URL}/diflouroborane-linux-amd64-${CI_COMMIT_TAG}" + tags: + - linux + - docker release: # Caution, as of 2021-02-02 these assets links require a login, see: @@ -146,7 +175,7 @@ release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest variables: - - PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/${CI_COMMIT_TAG}" + PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/diflouroborane/${CI_COMMIT_TAG}" rules: - if: $CI_COMMIT_TAG script: @@ -154,6 +183,9 @@ release: release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \ --assets-link "{\"name\":\"diflouroborane-linux-armv7-${CI_COMMIT_TAG}\",\"url\":\"${PACKAGE_REGISTRY_URL}/diflouroborane-linux-armv7-${CI_COMMIT_TAG}\"}" \ --assets-link "{\"name\":\"diflouroborane-linux-amd64-${CI_COMMIT_TAG}\",\"url\":\"${PACKAGE_REGISTRY_URL}/diflouroborane-linux-amd64-${CI_COMMIT_TAG}\"}" + tags: + - linux + - docker # cache dependencies and build environment to speed up setup cache: