name: Release

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

env:
  GOPRIVATE: git.sr.ht

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        build:
          [
            {
              name: strimertul-linux-amd64,
              platform: linux/amd64,
              os: ubuntu-latest,
            },
            { name: "strimertul", platform: windows/amd64, os: windows-latest },
            {
              name: "strimertul",
              platform: darwin/universal,
              os: macos-latest,
            },
          ]
    runs-on: ${{ matrix.build.os }}
    steps:
      - uses: actions/checkout@v2
      - name: Process version tag
        id: version
        uses: ncipollo/semantic-version-action@v1
      - name: Update wails.json fileVersion
        uses: jossef/action-set-json-field@v2.1
        with:
          file: wails.json
          field: info.productVersion
          value: "${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}"
      - uses: ashkeel/wails-build-action@0faaf35c690d88c3463349c6bf0bbdc53af5e5a8
        with:
          build-name: ${{ matrix.build.name }}
          build-platform: ${{ matrix.build.platform }}
          windows-nsis-installer: false
          macos-package-file-name: strimertul
          macos-package-type: dmg
          go-version: "1.20"
          draft: true
          ldflags: "-X main.appVersion=${{ github.ref_name }}"
