name: Release Binaries on: release: types: [published] permissions: contents: write jobs: build-and-attach: runs-on: ubuntu-latest strategy: matrix: exclude: - goos: windows goarch: arm - goos: darwin goarch: 386 - goos: darwin goarch: arm goos: [windows, linux, darwin, freebsd] goarch: [amd64, arm64, 386, arm] steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.23' - name: Build binary env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 VERSION: ${{ github.event.release.tag_name }} run: | BINARY_NAME=komari-agent-${{ matrix.goos }}-${{ matrix.goarch }} if [ "${{ matrix.goos }}" = "windows" ]; then BINARY_NAME=${BINARY_NAME}.exe elif [ "${{ matrix.goos }}" = "darwin" ]; then # macOS binaries typically do not have a file extension true fi go build -trimpath -ldflags="-s -w -X github.com/komari-monitor/komari-agent/update.CurrentVersion=${VERSION}" -o $BINARY_NAME - name: Upload binary to release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | BINARY_NAME=komari-agent-${{ matrix.goos }}-${{ matrix.goarch }} if [ "${{ matrix.goos }}" = "windows" ]; then BINARY_NAME=${BINARY_NAME}.exe elif [ "${{ matrix.goos }}" = "darwin" ]; then true fi gh release upload ${{ github.event.release.tag_name }} $BINARY_NAME --repo ${{ github.repository }} shell: bash