name: Create Release

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

on:
  push:
    tags:
      - '[0-9]+.[0-9]+.[0-9]+'

jobs:
  build_and_publish:
    name: Build
    runs-on: ubuntu-latest
    environment: Cargo
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v6
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - run: rustup target add aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu i686-unknown-linux-gnu powerpc-unknown-linux-gnu riscv64gc-unknown-linux-gnu
      - run: rustup component add clippy
      - run: RUSTFLAGS="-C target-feature=+neon,-fp16" cargo build --target aarch64-unknown-linux-gnu
      - run: RUSTFLAGS="-C target-feature=+neon,+fp16" cargo build --target aarch64-unknown-linux-gnu
      - run: RUSTFLAGS="-C target-feature=+sse4.1" cargo build --target i686-unknown-linux-gnu
      - run: cargo build --target powerpc-unknown-linux-gnu
      - run: cargo build --target riscv64gc-unknown-linux-gnu
      - run: cargo clippy
      - run: cargo clippy --target aarch64-unknown-linux-gnu
      - run: RUSTFLAGS="-C target-feature=+sse4.1" cargo build  --target x86_64-unknown-linux-gnu
      - uses: rust-lang/crates-io-auth-action@v1
        id: auth
      - name: Make a release
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
        run: cargo publish --manifest-path Cargo.toml