name: Rust
on:
push:
branches: [ "main" ]
tags:
- 'v*'
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
commit_id:
description: 'Branch or Commit ID (optional)'
required: false
type: string
schedule:
- cron: '20 09 * * *'
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
- run: cargo fmt --check
- run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --verbose --locked
- name: Run tests
run: cargo test --verbose
msrv:
name: MSRV Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@1.87.0
with:
components: clippy
- run: cargo build --verbose --locked
- run: cargo test --verbose --locked
- run: cargo clippy --all-targets --all-features -- -D warnings
crates:
name: Upload to crates.io
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
environment: pkg
needs: [build]
steps:
- uses: actions/checkout@v6
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}