From e1f0465cd7ef375000097efcdad6e4af40fcdd18 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Wed, 17 Apr 2024 17:33:32 +1000 Subject: [PATCH] fix(ci): Multiarch BLS build (#300) * style: remove unnecessary environment variable in builds * chore(ci): Fix builds * chore(ci): Fix builds * chore(ci): Fix builds * style: update goreleaser versions and env variables * chore(ci): Fix builds * chore(ci): Fix builds * chore(ci): Fix builds * chore(ci): Fix builds --------- Signed-off-by: Sam Calder-Mason --- .github/workflows/goreleaser.yaml | 18 ++++---- .github/workflows/test-build.yaml | 49 ++++++++++++++++++++ .goreleaser.yaml | 77 +++++++++++++++++++++++++------ 3 files changed, 121 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/test-build.yaml diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml index f38d057d..eaa0c77d 100644 --- a/.github/workflows/goreleaser.yaml +++ b/.github/workflows/goreleaser.yaml @@ -74,12 +74,12 @@ jobs: echo " prerelease: true" >> ../.goreleaser.yaml.new echo " make_latest: false" >> ../.goreleaser.yaml.new fi - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 - with: - distribution: goreleaser - version: latest - args: release --clean --config ../.goreleaser.yaml.new - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_SUFFIX: ${{ env.RELEASE_SUFFIX }} + - name: Run GoReleaser in Docker + run: | + docker run --rm \ + -v ${{ github.workspace }}:/workspace \ + -w /workspace \ + -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -e RELEASE_SUFFIX=${{ env.RELEASE_SUFFIX }} \ + goreleaser/goreleaser-cross:v1.22.2 release --clean --config .goreleaser.yaml.new diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml new file mode 100644 index 00000000..12b6e48b --- /dev/null +++ b/.github/workflows/test-build.yaml @@ -0,0 +1,49 @@ +name: test-build + +on: + pull_request: + workflow_dispatch: + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + - uses: actions/setup-node@v3 + name: Set up Node + with: + node-version: 18 + - name: Run apt-get update + run: sudo apt-get update + - name: Install cross-compiler for linux/arm64 + run: sudo apt-get -y install gcc-aarch64-linux-gnu + - name: Install make + run: sudo apt-get -y install make + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Context for Buildx + shell: bash + id: buildx-context + run: | + docker context create builders + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + endpoint: builders + - name: Run GoReleaser in Docker + run: | + docker run --rm \ + -v ${{ github.workspace }}:/workspace \ + -w /workspace \ + -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -e RELEASE_SUFFIX="test" \ + goreleaser/goreleaser-cross:v1.22.2 release --clean --config .goreleaser.yaml --skip=publish --skip=validate diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 7030dd16..daff8389 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,23 +5,72 @@ before: - go mod tidy - go generate ./... builds: - - binary: xatu-{{.Version}} + - id: linux-amd64 + env: + - CGO_ENABLED=1 + - CC=x86_64-linux-gnu-gcc + - CXX=x86_64-linux-gnu-g++ + binary: xatu-{{.Version}} goos: - - linux - - windows - - darwin + - linux + goarch: + - amd64 + ldflags: + - -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} + mod_timestamp: "{{ .CommitTimestamp }}" + + - id: linux-arm64 + env: + - CGO_ENABLED=1 + - CC=aarch64-linux-gnu-gcc + - CXX=aarch64-linux-gnu-g++ + binary: xatu-{{.Version}} + goos: + - linux + goarch: + - arm64 + ldflags: + - -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} + mod_timestamp: "{{ .CommitTimestamp }}" + + - id: windows-amd64 + env: + - CGO_ENABLED=1 + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ + binary: xatu-{{.Version}} + goos: + - windows + goarch: + - amd64 + ldflags: + - -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} + mod_timestamp: "{{ .CommitTimestamp }}" + + - id: darwin-amd64 + env: + - CGO_ENABLED=1 + - CC=o64-clang + - CXX=o64-clang++ + binary: xatu-{{.Version}} + goos: + - darwin + goarch: + - amd64 + ldflags: + - -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} + mod_timestamp: "{{ .CommitTimestamp }}" + - id: darwin-arm64 + env: + - CGO_ENABLED=1 + - CC=o64-clang + - CXX=o64-clang++ + binary: xatu-{{.Version}} + goos: + - darwin goarch: - - amd64 - - arm64 - goarm: - - 6 - - 7 - ignore: - - goarch: 386 - # broken with go-ethereum github.com/prometheus/tsdb module - - goos: windows - goarch: arm64 + - arm64 ldflags: - -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} mod_timestamp: "{{ .CommitTimestamp }}"