bfom 0.1.21

Brendan's Flavor of Markdown: I'll build my own markdown format, what could go wrong?
Documentation
# a good chunk of this is from my trove project
# https://gitlab.com/silver_rust/trove_downloader/-/blob/master/.gitlab-ci.yml
# also https://gitlab.com/pJunger/dlt-proto/blob/master/.gitlab-ci.yml

# all images using stable, unless otehrwise specificated
image: rust:latest

stages:
  - lint
  - build
  - release

cache:
  key: "$CI_JOB_NAME"
  paths:
    - target/

# Set any required environment variables here
variables:
  #APT_CACHE_DIR: apt-cache
  #CARGO_HOME: $CI_PROJECT_DIR/cargo
  RUST_BACKTRACE: FULL

# Do any pre-flight requirements here, such as updating $PATH installing dependencies
before_script:
  - export PATH="$CI_PROJECT_DIR/cargo/bin:$PATH"


# clippy and fmt are magic
# runs on all commits/branches
lint-clippy:
  stage: lint
  script:
    - rustup component add clippy
    - rustc --version
    - cargo version
    - cargo clippy
  rules:
    - changes:
        - src/*
        - cargo.*
      when: always

lint-fmt:
  stage: lint
  script:
    - rustup component add rustfmt
    - rustc --version
    - cargo version
    - cargo fmt -- --check
  rules:
    - changes:
        - src/*
        - cargo.*
      when: always

# has to actually compile
build:
  stage: build
  script:
    - rustc --version
    - cargo version
    - cargo build --verbose
    - RUST_BACKTRACE=1 cargo test --verbose
  rules:
    - changes:
        - src/*
        - cargo.*
      when: always


# publish to crates.io on version change
publish:
  stage: release
  script:
    - rustc --version
    - cargo version
    - cargo publish --token="$CRATES_LOGIN"
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      if: $CI_COMMIT_TAG
      changes:
        - src/*
        - cargo.*
      when: always