yoo 0.6.1

A tiny developer companion for better coding sessions.
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            archive: yoo-${{ github.ref_name }}-linux-x86_64
          - os: macos-latest
            target: aarch64-apple-darwin
            archive: yoo-${{ github.ref_name }}-macos-aarch64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            archive: yoo-${{ github.ref_name }}-windows-x86_64

    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Package Unix archive
        if: runner.os != 'Windows'
        shell: bash
        run: |

          mkdir -p "staging/${{ matrix.archive }}" dist
          cp "target/${{ matrix.target }}/release/yoo" README.md LICENSE "staging/${{ matrix.archive }}/"
          tar -C staging -czf "dist/${{ matrix.archive }}.tar.gz" "${{ matrix.archive }}"

      - name: Package Windows archive
        if: runner.os == 'Windows'
        shell: pwsh
        run: |

          New-Item -ItemType Directory -Force "staging/${{ matrix.archive }}", dist
          Copy-Item "target/${{ matrix.target }}/release/yoo.exe", README.md, LICENSE "staging/${{ matrix.archive }}/"
          Compress-Archive -Path "staging/${{ matrix.archive }}/*" -DestinationPath "dist/${{ matrix.archive }}.zip"

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

  publish:
    name: Publish GitHub Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          path: release
          merge-multiple: true
      - name: Generate checksums
        working-directory: release
        run: sha256sum * > SHA256SUMS
      - uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: release/*