name: build binary for all platforms

on:
  push:
    tags:
      - '*'

permissions:
  contents: write

jobs:
  make-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/create-release@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
  build-all-for-all:
    runs-on: ubuntu-latest
    needs:
      - make-release
    strategy:
      matrix:
        goos: [linux, freebsd, darwin, windows]
        goarch: [amd64, arm64]
        exclude:
          - goarch: arm64
            goos: windows
    steps:
      - uses: actions/checkout@v3
      - run: wget https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.5/tailwindcss-linux-x64
      - run: chmod +x tailwindcss-linux-x64
      - run: ./tailwindcss-linux-x64 -i tailwind.css -o static/tailwind-bundle.min.css --minify
      - uses: wangyoucao577/go-release-action@v1.41
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          goos: ${{ matrix.goos }}
          goarch: ${{ matrix.goarch }}
          overwrite: true
          md5sum: false
          sha256sum: false
          compress_assets: true
