name: Publish crate
on:
release:
types: [published]
jobs:
static-analysis:
strategy:
matrix:
rust: [stable, nightly]
runs-on:
- windows-2022
- windows-2025
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update toolchain
run: |
rustup update --no-self-update ${{ matrix.rust }}
rustup default ${{ matrix.rust }}
rustup component add clippy
- name: Run cargo static analysis checks
run: |
cargo check
cargo clippy --all-targets --all-features -- -D clippy::all
cargo test
publish:
needs: static-analysis
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update toolchain
run: |
rustup update --no-self-update stable
rustup default stable
- name: Sanity check tag equals crate version
shell: bash
run: |
pkg_version=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2); exit; }' Cargo.toml)
if [[ "${{ github.ref_name }}" = "$pkg_version" ]]; then
echo "GitHub ref ${{ github.ref_name }} equals parsed crate version $pkg_version. Continuing..."
else
echo "GitHub ref ${{ github.ref_name }} differs from parsed crate version $pkg_version! Aborting..."
exit 1
fi
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}