diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59acd0d..9f52b3b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,10 @@ on: jobs: build: - runs-on: windows-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} permissions: contents: write steps: @@ -18,25 +21,47 @@ jobs: with: go-version: '1.22' - - name: Build - run: go build -ldflags "-s -w" -o mhr-cfw-go.exe ./cmd/mhr-cfw + - name: Build Linux + if: matrix.os == 'ubuntu-latest' + run: GOOS=linux go build -ldflags "-s -w" -o mhr-cfw-go ./cmd/mhr-cfw + + - name: Build Windows + if: matrix.os == 'windows-latest' + run: GOOS=windows go build -ldflags "-s -w" -o mhr-cfw-go.exe ./cmd/mhr-cfw - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: mhr-cfw-go - path: mhr-cfw-go.exe + name: mhr-cfw-go-${{ matrix.os }} + path: mhr-cfw-go* - - name: Download artifact + release: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Download Linux artifact uses: actions/download-artifact@v4 with: - name: mhr-cfw-go + name: mhr-cfw-go-ubuntu-latest + path: . + + - name: Download Windows artifact + uses: actions/download-artifact@v4 + with: + name: mhr-cfw-go-windows-latest path: . - name: Release uses: softprops/action-gh-release@v2 with: - files: mhr-cfw-go.exe + files: | + mhr-cfw-go + mhr-cfw-go.exe body: "Built from commit ${{ github.sha }}" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}