Update .gitlab-ci.yml file

This commit is contained in:
Kai Kriegel 2021-12-28 00:47:24 +00:00
parent 3f0c45b802
commit c17faf9ba2

View File

@ -15,6 +15,13 @@ variables:
# CARGO_HOME: $CI_PROJECT_DIR/cargo
APT_CACHE_DIR: $CI_PROJECT_DIR/apt
stages:
- lint
- test
- build
- upload
- release
# install build dependencies
before_script:
@ -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
@ -127,11 +137,27 @@ build:binary:
- 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: