version-compare 0.1.0

A Rust library to easily compare version numbers, and test them against various comparison operators.
Documentation
image: "rust:slim"

stages:
  - check
  - build
  - test
  - release

# Variable defaults
variables:
  RUST_VERSION: stable

# Cache rust/cargo/build artifacts
cache:
  key: "$CI_PIPELINE_ID-$RUST_VERSION"
  paths:
    - /usr/local/cargo/registry/
    - /usr/local/rustup/toolchains/
    - /usr/local/rustup/update-hashes/
    - target/

# Install compiler and OpenSSL dependencies
before_script:
  - |
    rustup install $RUST_VERSION
    rustup default $RUST_VERSION
  - |
    rustc --version
    cargo --version

# Check on stable, beta, nightly and MSRV
.check-base: &check-base
  stage: check
  script:
    - cargo check --verbose
check-stable:
  <<: *check-base
check-beta:
  <<: *check-base
  variables:
    RUST_VERSION: beta
check-nightly:
  <<: *check-base
  variables:
    RUST_VERSION: nightly
check-msrv:
  <<: *check-base
  variables:
    RUST_VERSION: "1.42.0"

# Build on stable
build:
  stage: build
  needs: []
  dependencies: []
  script:
    - cargo build --release --verbose

# Test on stable
test:
  stage: test
  needs: []
  dependencies: []
  script:
    - cargo test --verbose

# Gather test coverage
test-coverage:
  stage: test
  only:
    - master
    - /^v(\d+\.)*\d+$/
  needs: []
  dependencies: []
  coverage: '/^\d+.\d+% coverage/'
  script:
    - apt-get update
    - apt-get install -y --no-install-recommends pkg-config libssl-dev
    - cargo install cargo-tarpaulin -f
    - cargo tarpaulin --verbose --avoid-cfg-tarpaulin --coveralls $COVERALLS_TOKEN --out Xml
  artifacts:
    reports:
      cobertura:
        - cobertura.xml

# Release crate on crates.io
release-crate:
  stage: release
  dependencies: []
  only:
    - /^v(\d+\.)*\d+$/
  script:
    - echo "Creating release crate to publish on crates.io..."
    - echo $CARGO_TOKEN | cargo login
    - echo "Publishing crate to crates.io..."
    - cargo publish --verbose --allow-dirty