scratch-io 0.1.3

A command-line tool for managing, downloading, and launching games from itch.io
Documentation
name: Build

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        target:
          [
            x86_64-unknown-linux-gnu,
            aarch64-unknown-linux-gnu,
            x86_64-apple-darwin,
            aarch64-apple-darwin,
            x86_64-pc-windows-msvc,
            aarch64-pc-windows-msvc,
          ]
    runs-on: ${{ (contains(matrix.target, 'apple-darwin') && 'macos-latest') ||
      (contains(matrix.target, 'linux-gnu') && 'ubuntu-latest') ||
      (contains(matrix.target, 'pc-windows') && 'windows-latest') }}
    steps:
      - uses: actions/checkout@v4

      - name: Install deps (aarch64 linux only)
        if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

          mkdir -p .cargo
          cat <<EOF > .cargo/config.toml
          [target.aarch64-unknown-linux-gnu]
          linker = "aarch64-linux-gnu-gcc"
          EOF

      - name: Setup target
        run: rustup target add ${{ matrix.target }}

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

      - name: Package binary
        shell: bash
        run: |
          BIN_NAME="scratch-io"
          TARGET="${{ matrix.target }}"
          
          if [[ -f "target/$TARGET/release/$BIN_NAME" ]]; then
              cp "target/$TARGET/release/$BIN_NAME" "$BIN_NAME-$TARGET"
          else
              cp "target/$TARGET/release/$BIN_NAME.exe" "$BIN_NAME-$TARGET.exe"
          fi

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.target }}
          path: |
            scratch-io-${{ matrix.target }}
            scratch-io-${{ matrix.target }}.exe

  draft-release:
    permissions:
      contents: write
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: build
    steps:
      - name: Download builds
        uses: actions/download-artifact@v4
        with:
          merge-multiple: true

      - name: Create draft release
        uses: softprops/action-gh-release@v2
        with:
          draft: true
          generate_release_notes: true
          files: |
            scratch-io-*