diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4bc5791 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build on Main + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + 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.sha }} + 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 github.com/komari-monitor/komari-agent/update.CurrentVersion=${VERSION}" -o $BINARY_NAME + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: komari-agent-${{ matrix.goos }}-${{ matrix.goarch }} + path: komari-agent-${{ matrix.goos }}-${{ matrix.goarch }}*