on:
  push:
    tags:
      - "v*"
name: Release
jobs:
  build:
    name: Release (crates.io & github.com)
    runs-on: ubuntu-latest
    env:
      BINARY_NAME: cidrrr
      CARGO_TERM_COLOR: always
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6
      - run: cargo login ${CARGO_RELEASE_TOKEN}
        env:
          CARGO_RELEASE_TOKEN: ${{ secrets.CARGO_RELEASE_TOKEN }}
      - run: cargo publish
      - uses: docker://messense/rust-musl-cross:x86_64-musl
        with:
          args: cargo build --release
      - uses: docker://messense/rust-musl-cross:x86_64-musl
        with:
          args: musl-strip target/x86_64-unknown-linux-musl/release/cidrrr
      - run: cp ./target/x86_64-unknown-linux-musl/release/cidrrr cidrrr
      - run: sha512sum cidrrr > cidrrr.sha512sum
      - id: github_release
        uses: softprops/action-gh-release@v2
        with:
          name: Release cidrrr ${{ github.ref_name }}
          generate_release_notes: true
          draft: false
          prerelease: false
          files: |
            cidrrr
            cidrrr.sha512sum
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
