areyouok 0.1.0

Fast CLI to scan Markdown/HTML/text files for broken links
name: Release build

on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

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

permissions:
  contents: write
  actions: write

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: areyouok-linux-amd64
            exe: areyouok
          - os: ubuntu-24.04-arm
            target: aarch64-unknown-linux-gnu
            artifact: areyouok-linux-arm64
            exe: areyouok
          - os: ubuntu-latest
            target: i686-unknown-linux-gnu
            artifact: areyouok-linux-386
            exe: areyouok
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact: areyouok-darwin-amd64
            exe: areyouok
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: areyouok-windows-amd64.exe
            exe: areyouok.exe

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install i686 linker
        if: matrix.target == 'i686-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-i686-linux-gnu

      - name: Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cargo config (i686)
        if: matrix.target == 'i686-unknown-linux-gnu'
        shell: bash
        run: |
          mkdir -p .cargo
          echo '[target.i686-unknown-linux-gnu]' >> .cargo/config.toml
          echo 'linker = "i686-linux-gnu-gcc"' >> .cargo/config.toml

      - name: Build
        run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Package binary
        shell: bash
        run: |
          src="target/${{ matrix.target }}/release/${{ matrix.exe }}"
          dest="${{ matrix.artifact }}"
          cp "$src" "$dest"
          if [[ "${{ matrix.os }}" != "windows-latest" ]]; then
            chmod +x "$dest"
            strip "$dest" || true
          fi

      - name: Upload binary
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.artifact }}
          path: ${{ matrix.artifact }}
          if-no-files-found: error

  attach-to-release:
    needs: build
    if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest

    steps:
      - name: Download binaries
        uses: actions/download-artifact@v4
        with:
          pattern: areyouok-*
          path: dist
          merge-multiple: true

      - name: Publish release assets
        uses: softprops/action-gh-release@v2
        with:
          files: dist/*
          generate_release_notes: true