name: Build

on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - master

jobs:
  build:
    name: ${{ matrix.goos }}-${{ matrix.goarch }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        goos: [linux, windows, darwin]
        goarch: ["386", amd64, arm64]
        exclude:
          - goarch: "386"
            goos: darwin
          - goarch: arm64
            goos: windows
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4
        with:
          submodules: true
      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.22.2'
      - name: Download Task
        run: 'sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d'
      - name: Build
        run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} ./bin/task
      - uses: actions/upload-artifact@v4
        if: matrix.goos == 'windows'
        with:
          name: hilbish-${{ matrix.goos }}-${{ matrix.goarch }}
          path: |
            hilbish.exe
            LICENSE
            README.md
            CHANGELOG.md
            .hilbishrc.lua
            nature
            libs
            docs
            emmyLuaDocs
      - uses: actions/upload-artifact@v4
        if: matrix.goos != 'windows'
        with:
          name: hilbish-${{ matrix.goos }}-${{ matrix.goarch }}
          path: |
            hilbish
            LICENSE
            README.md
            CHANGELOG.md
            .hilbishrc.lua
            nature
            libs
            docs
            emmyLuaDocs