name: Release on: push: tags: - 'v*' jobs: build: strategy: matrix: goos: [linux, darwin, freebsd] goarch: [amd64, arm64] runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v6 - name: Set up Go uses: actions/setup-go@v6 with: go-version-file: go.mod cache: true - name: Build env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} run: | go build \ -ldflags="-s -w -X main.Version=${{ github.ref_name }} -X main.Commit=${{ github.sha }}" -o watchdog-${GOOS}-${GOARCH} . - name: Create artifact run: | tar -czvf watchdog-${GOOS}-${{ matrix.goarch }}.tar.gz watchdog-${GOOS}-${{ matrix.goarch }} env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} - name: Upload artifact uses: actions/upload-artifact@v4 with: name: watchdog-${{ matrix.goos }}-${{ matrix.goarch }} path: watchdog-* release: needs: build runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v6 - name: Download all artifacts uses: actions/download-artifact@v8 with: path: artifacts - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: files: artifacts/**/*.tar.gz artifacts/**/*.zip generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}