image: "rust:slim"

variables:
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG

stages:
  - build
  - test
  - release

cargo-build:
  stage: build
  script:
    - cargo build

cargo-test:
  stage: test
  script:
    - rustc --version && cargo --version
    - cargo test --workspace --verbose

clippy-lint:
  stage: test
  before_script:
    - rustup component add clippy
  script:
    - cargo clippy

release-artifacts:
  stage: release
  script:
    - cargo build --release
  artifacts:
    paths:
      - target/release/kyanite
    expire_in: 1 week

release-container:
    image: quay.io/podman/stable
    stage: release
    before_script:
      - podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    script:
      - podman build -t $IMAGE_TAG -f ./Dockerfile
      - podman push $IMAGE_TAG