name: Build & Release
on:
  push:
    tags:
      - 'v*'

env:
  GO_VERSION: "1.22.x"

jobs:
  build:
    runs-on: "windows-2019"
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: ${{ env.GO_VERSION }}

      - run: go build ./cmd/dmverity-vhd
      - run: go build ./cmd/dmverity-vhd
        env: 
          GOOS: linux
          GOARCH: amd64

      - uses: actions/upload-artifact@v4
        with:
          name: binaries
          path: |
            dmverity-vhd.exe
            dmverity-vhd

  create_release:
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          name: binaries
          
      - name: Publish release
        uses: softprops/action-gh-release@v2.0.4
        with:
          prerelease: ${{ contains(github.ref, 'rc') }}
          files: |
            dmverity-vhd.exe
            dmverity-vhd

