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 # CARGO_HOME: $CI_PROJECT_DIR/cargo
APT_CACHE_DIR: $CI_PROJECT_DIR/apt APT_CACHE_DIR: $CI_PROJECT_DIR/apt
stages:
- lint
- test
- build
- upload
- release
# install build dependencies # install build dependencies
before_script: before_script:
@ -26,6 +33,7 @@ before_script:
# Use clippy to lint the project # Use clippy to lint the project
lint:clippy: lint:clippy:
stage: lint
allow_failure: true allow_failure: true
script: script:
- rustc --version && cargo --version # Print version info for debugging - rustc --version && cargo --version # Print version info for debugging
@ -40,6 +48,7 @@ lint:clippy:
# Use rustfmt to check formating of the project # Use rustfmt to check formating of the project
lint:fmt: lint:fmt:
stage: lint
allow_failure: true allow_failure: true
script: script:
- rustc --version && cargo --version # Print version info for debugging - rustc --version && cargo --version # Print version info for debugging
@ -54,6 +63,7 @@ lint:fmt:
# Use cargo to test the project # Use cargo to test the project
test:cargo: test:cargo:
stage: test
script: script:
- rustc --version && cargo --version # Print version info for debugging - rustc --version && cargo --version # Print version info for debugging
- cargo test --workspace --verbose - cargo test --workspace --verbose
@ -65,41 +75,41 @@ test:cargo:
- linux - linux
- docker - docker
build:docker-master: # build:docker-master:
image: # image:
name: gcr.io/kaniko-project/executor:v1.6.0-debug # name: gcr.io/kaniko-project/executor:v1.6.0-debug
entrypoint: [""] # entrypoint: [""]
before_script: # before_script:
- '' # - ''
script: # script:
- mkdir -p /kaniko/.docker # - mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json # - 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 # - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest
only: # only:
- master # - master
tags: # tags:
- linux # - linux
- docker # - docker
build:docker-releases: # build:docker-releases:
image: # image:
name: gcr.io/kaniko-project/executor:v1.6.0-debug # name: gcr.io/kaniko-project/executor:v1.6.0-debug
entrypoint: [""] # entrypoint: [""]
before_script: # before_script:
- '' # - ''
script: # script:
- mkdir -p /kaniko/.docker # - mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json # - 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 # - /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
only: # only:
- tags # - tags
tags: # tags:
- linux # - linux
- docker # - docker
build:binary: build:binary:
image: rust:latest image: rust:latest
stage: build
before_script: before_script:
- cp cargo-cross-config /usr/local/cargo/config - cp cargo-cross-config /usr/local/cargo/config
- dpkg --add-architecture armhf - dpkg --add-architecture armhf
@ -127,11 +137,27 @@ build:binary:
- linux - linux
- docker - docker
upload: upload:nightly:
stage: upload stage: upload
image: curlimages/curl:latest image: curlimages/curl:latest
variables: 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: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
script: 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/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}" 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: release:
# Caution, as of 2021-02-02 these assets links require a login, see: # Caution, as of 2021-02-02 these assets links require a login, see:
@ -146,7 +175,7 @@ release:
stage: release stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest image: registry.gitlab.com/gitlab-org/release-cli:latest
variables: 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: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
script: script:
@ -154,6 +183,9 @@ release:
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \ 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-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}\"}" --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 dependencies and build environment to speed up setup
cache: cache: