image: rockylinux:9

stages: [lint, build, publish]

before_script:
  - dnf install -y clang-devel llvm-devel
  - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
  - source "$HOME/.cargo/env"
  - rustup component add rustfmt clippy
  
fmt:
  stage: lint
  script:
    - cargo fmt --all -- --check

clippy:
  stage: lint
  script:
    - cargo clippy --all-targets --all-features

build:
  stage: build
  script:
    - cargo build

publish:
  stage: publish
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: manual
    - when: never
  script:
    - cargo publish --locked