From b6da5ff789d88ade98a7cdc29b5ca98a8316c972 Mon Sep 17 00:00:00 2001 From: Jameel Al-Aziz Date: Sun, 4 Sep 2022 22:13:57 +0000 Subject: [PATCH] Support arm64 builds Update the goreleaesr config with: * arm64 binary builds * mutli-arch docker image builds Also, add the newly required dependencies for multi-arch builds to the Github Actions workflows. --- .github/workflows/release.yml | 8 +++++ .github/workflows/snapshot.yml | 8 +++++ .goreleaser.yml | 63 +++++++++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 30dd575048..29de729e92 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,14 @@ jobs: - uses: arduino/setup-task@v1 + - uses: docker/setup-qemu-action@v2 + + - uses: docker/setup-buildx-action@v2 + + - name: Install GCC for arm64 + run: | + sudo apt-get install gcc-aarch64-linux-gnu + - name: Install Syft run: | curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index bc8cc0e55f..d6ff21e211 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -18,6 +18,14 @@ jobs: - uses: arduino/setup-task@v1 + - uses: docker/setup-qemu-action@v2 + + - uses: docker/setup-buildx-action@v2 + + - name: Install GCC for arm64 + run: | + sudo apt-get install gcc-aarch64-linux-gnu + - name: Install Syft run: | curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin diff --git a/.goreleaser.yml b/.goreleaser.yml index 1465093c6c..a6454e2c45 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -3,8 +3,6 @@ snapshot: builds: - main: ./cmd/flipt/. - env: - - CGO_ENABLED=1 ldflags: - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .Date }} -X main.analyticsKey={{ .Env.ANALYTICS_KEY }} - -linkmode external -extldflags -static @@ -12,9 +10,22 @@ builds: - linux goarch: - amd64 + - arm64 flags: - -tags=assets,netgo - -trimpath + overrides: + - goos: linux + goarch: amd64 + goamd64: v1 + env: + - CGO_ENABLED=1 + - CC=x86_64-linux-gnu-gcc + - goos: linux + goarch: arm64 + env: + - CGO_ENABLED=1 + - CC=aarch64-linux-gnu-gcc sboms: - artifacts: archive @@ -39,20 +50,56 @@ changelog: dockers: - dockerfile: ./build/Dockerfile use: buildx + goarch: amd64 image_templates: - - "flipt/flipt:latest" - - "flipt/flipt:{{ .Tag }}" - - "markphelps/flipt:latest" # TODO: deprecate - - "markphelps/flipt:{{ .Tag }}" # TODO: deprecate - - "ghcr.io/flipt-io/flipt:latest" - - "ghcr.io/flipt-io/flipt:{{ .Tag }}" + - "flipt/flipt:{{ .Tag }}-amd64" build_flag_templates: + - "--platform=linux/amd64" - "--label=org.opencontainers.image.created={{.Date}}" - "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.version={{.Version}}" extra_files: - config/migrations/ - config/default.yml + - dockerfile: ./build/Dockerfile + use: buildx + goarch: arm64 + image_templates: + - "flipt/flipt:{{ .Tag }}-arm64" + build_flag_templates: + - "--platform=linux/arm64" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + extra_files: + - config/migrations/ + - config/default.yml + +docker_manifests: + - name_template: "flipt/flipt:latest" + image_templates: + - "flipt/flipt:{{ .Tag }}-amd64" + - "flipt/flipt:{{ .Tag }}-arm64" + - name_template: "flipt/flipt:{{ .Tag }}" + image_templates: + - "flipt/flipt:{{ .Tag }}-amd64" + - "flipt/flipt:{{ .Tag }}-arm64" + - name_template: "markphelps/flipt:latest" # TODO: deprecate + image_templates: + - "flipt/flipt:{{ .Tag }}-amd64" + - "flipt/flipt:{{ .Tag }}-arm64" + - name_template: "markphelps/flipt:{{ .Tag }}" # TODO: deprecate + image_templates: + - "flipt/flipt:{{ .Tag }}-amd64" + - "flipt/flipt:{{ .Tag }}-arm64" + - name_template: "ghcr.io/flipt-io/flipt:latest" + image_templates: + - "flipt/flipt:{{ .Tag }}-amd64" + - "flipt/flipt:{{ .Tag }}-arm64" + - name_template: "ghcr.io/flipt-io/flipt:{{ .Tag }}" + image_templates: + - "flipt/flipt:{{ .Tag }}-amd64" + - "flipt/flipt:{{ .Tag }}-arm64" announce: discord: