name: Build

on:
  - push
  - pull_request

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@v3
        with:
          submodules: true
      - name: Setup Go
        uses: actions/setup-go@v2
        with:
          go-version: '1.18.8'
      - 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@v2
        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@v2
        if: matrix.goos != 'windows'
        with:
          name: hilbish-${{ matrix.goos }}-${{ matrix.goarch }}
          path: |
            hilbish
            LICENSE
            README.md
            CHANGELOG.md
            .hilbishrc.lua
            nature
            libs
            docs
            emmyLuaDocs
