name: release

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

jobs:
  Release-on-Windows:
    name: Release on Windows
    runs-on: windows-latest
    steps:
      - name: Install V
        uses: vlang/setup-v@v1
        with:
          check-latest: true

      - name: Install Task
        uses: arduino/setup-task@v1

      - name: Checkout ${{ github.event.repository.name }}
        uses: actions/checkout@v3

      - name: Install deps
        run: task setup

      - name: Build ${{ github.event.repository.name }}
        run: task dist

      - name: Release
        uses: softprops/action-gh-release@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: |
            dist/**

  Release-on-Ubuntu:
    name: Release on Ubuntu 
    runs-on: ubuntu-latest
    steps:
      - name: Install V
        uses: vlang/setup-v@v1
        with:
          check-latest: true

      - name: Install Task
        uses: arduino/setup-task@v1

      - name: Checkout ${{ github.event.repository.name }}
        uses: actions/checkout@v3

      - name: Install deps
        run: task setup

      - name: Build ${{ github.event.repository.name }}
        run: task dist

      - name: Release
        uses: softprops/action-gh-release@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: |
            dist/**

  Release-on-Darwin:
    name: Release on Darwin
    runs-on: macos-latest
    steps:
      - name: Install V
        uses: vlang/setup-v@v1
        with:
          check-latest: true

      - name: Install Task
        uses: arduino/setup-task@v1

      - name: Checkout ${{ github.event.repository.name }}
        uses: actions/checkout@v3

      - name: Install deps
        run: task setup

      - name: Build ${{ github.event.repository.name }}
        run: task dist

      - name: Release
        uses: softprops/action-gh-release@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: |
            dist/**
