name: Build and Attach Binaries to Release on: release: types: [published] permissions: contents: write jobs: build-and-attach: runs-on: ubuntu-latest strategy: matrix: goos: [windows, linux] goarch: [amd64, arm64] 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 fi go build -trimpath -ldflags="-s -w -X 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 fi gh release upload ${{ github.event.release.tag_name }} $BINARY_NAME --repo ${{ github.repository }} shell: bash