image: "rust:latest"

default:
  before_script:
    - rustc --version 
    - cargo --version

stages:
  - check
  - build


# check stage
test:
  stage: check
  rules:
    - changes:
      - src/*
  script:
    - cargo test

lint:
  stage: check
  rules:
    - changes:
      - src/*
  script:
    - rustup component add clippy
    - cargo clippy -- -D warnings


# build stage
build:amd64:
  stage: build
  rules:
    - changes:
        - Cargo.toml
      when: manual
  script:
    - cargo build --release
  artifacts:
    paths:
      - target/release/isw

publish:
  stage: build
  rules:
    - changes:
        - Cargo.toml
      when: manual
  script:
    - cargo publish --token "$CRATESIO_TOKEN"
