name: Rust
on:
push:
branches: [main]
tags:
- v*
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build & test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt update -y
sudo apt install -y gdal-bin proj-bin
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Formatting
if: runner.os == 'Linux'
run: cargo fmt --check
- name: Linting
if: runner.os == 'Linux'
run: cargo clippy --bin ridal -- -D warnings --no-deps
- name: Build
run: cargo build --bin ridal --verbose
- name: Test
run: cargo test --bin ridal -- --nocapture
- name: Dry-run cargo publish
if: runner.os == 'Linux' && !startsWith(github.ref, 'refs/tags/')
run: cargo publish --dry-run
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish crate
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish