stages: - build - test - version - deploy build: stage: build image: rust:1.95 script: - cargo build --release - ls -R target/release/ artifacts: paths: - target/release/ expire_in: 1 week cache: key: "cargo-cache" paths: - target/ - ~/.cargo/ test: stage: test image: rust:1.95 script: - cargo test cache: key: "cargo-cache" paths: - target/ - ~/.cargo/ test_variable: stage: test image: rust:1.95 script: - echo "Checking CARGO_LOGIN_TOKEN..." - if [[ -z "$CARGO_LOGIN_TOKEN" ]]; then echo "CARGO_LOGIN_TOKEN is empty!"; exit 1; else echo "CARGO_LOGIN_TOKEN is set."; fi - env rules: - if: '$CI_COMMIT_TAG' extract_version: stage: version image: alpine:latest script: - apk add --no-cache jq - VERSION=$(grep 'version = "' Cargo.toml | awk -F'"' '{print $2}' | head -n 1) - VER_HASH=${CI_COMMIT_SHA:0:10} - VERSION="$VERSION-$VER_HASH" - if [ $? -ne 0 ]; then echo "Error extracting version"; exit 1; fi - echo "Extracted version is" - echo "$VERSION" - echo "VERSION=$VERSION" > version.env artifacts: reports: dotenv: version.env