name: CI on: push: branches: [main, master] pull_request: branches: [main, master] jobs: test: name: Test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: go-version: '1.22' cache: true - name: Download dependencies run: go mod download - name: Run vet run: make vet - name: Run tests run: make test - name: Check formatting run: | if [ -n "$(gofmt -l -s .)" ]; then echo "Files not properly formatted:" gofmt -l -s . exit 1 fi - name: Build run: make build build: name: Build runs-on: ubuntu-latest needs: test strategy: matrix: goos: [linux, darwin, windows] goarch: [amd64, arm64] exclude: # Exclude darwin/amd64 - Apple Silicon is the future - goos: darwin goarch: amd64 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: go-version: '1.22' cache: true - name: Build binary env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 run: | VERSION=$(cat VERSION) BINARY_NAME="obm" if [ "$GOOS" = "windows" ]; then BINARY_NAME="obm.exe" fi LDFLAGS="-s -w -X main.version=$VERSION" GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "$LDFLAGS" -o "bin/${GOOS}_${GOARCH}/$BINARY_NAME" ./cmd/obm - name: Upload artifact uses: actions/upload-artifact@v4 with: name: obm-${{ matrix.goos }}-${{ matrix.goarch }} path: bin/${{ matrix.goos }}_${{ matrix.goarch }}/ retention-days: 7