name: Build Binaries

on:
  workflow_dispatch:
    inputs:
      tag:
        description: Release tag (e.g. v0.3.4)
        required: true
        type: string

permissions:
  contents: write

jobs:
  upload:
    name: Upload ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-apple-darwin
            os: macos-13
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ inputs.tag }}

      - uses: taiki-e/setup-cross-toolchain-action@v1
        with:
          target: ${{ matrix.target }}
        if: matrix.target == 'aarch64-unknown-linux-gnu'

      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: auberge
          target: ${{ matrix.target }}
          ref: refs/tags/${{ inputs.tag }}
          token: ${{ secrets.GITHUB_TOKEN }}
