diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index eab3f29..5bf1c2b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,28 +1,29 @@ -name: Go Build +name: Build on: push: branches: [ "master" ] - pull_request: - branches: [ "master" ] jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + goarch: [amd64, arm64] steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v5 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v4 with: - go-version: "1.24" + go-version: '1.24' - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 - with: - version: latest - - name: Build - run: go build . + - name: Build binary + run: | + echo "Building for ${{ matrix.goarch }}" + GOOS=linux GOARCH=${{ matrix.goarch }} go build -o observer-${{ matrix.goarch }} . diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d0ae241..46c5cba 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,16 +7,49 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + goarch: [amd64, arm64] steps: - name: Checkout uses: actions/checkout@v5 - - name: Build - run: go build -o observer . + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.24' + + - name: Build binary + run: | + echo "Building for ${{ matrix.goarch }}" + GOOS=linux GOARCH=${{ matrix.goarch }} go build -o observer-${{ matrix.goarch }} . + + - name: Package binary as tar.gz with release tag + run: | + TAG=${GITHUB_REF#refs/tags/} + tar -czf observer-${{ matrix.goarch }}-$TAG.tar.gz observer-${{ matrix.goarch }} - - name: Release + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: observer-${{ matrix.goarch }}-${GITHUB_REF#refs/tags/}.tar.gz + path: observer-${{ matrix.goarch }}-${GITHUB_REF#refs/tags/}.tar.gz + + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: . + + - name: Create GitHub Release uses: softprops/action-gh-release@v2 if: github.ref_type == 'tag' with: - files: observer + files: | + observer-amd64-${GITHUB_REF#refs/tags/}.tar.gz + observer-arm64-${GITHUB_REF#refs/tags/}.tar.gz +