name: Rust Test

on:
  push:
    branches:
      - main
    tags:
      - '*.*.*'
jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Set up Rust
        run: |
          curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
          export PATH="$HOME/.cargo/bin:$PATH"
          rustup default stable

      - name: Build and Test
        run: |
          cargo build
          cargo test --verbose

      - name: Publish
        run: |
          cargo publish --token ${{ secrets.CRATES_TOKEN }}