From ca0f5fe929b75da14487e0c811f967bc27c71e32 Mon Sep 17 00:00:00 2001 From: Dusan Malusev Date: Mon, 30 Sep 2024 11:54:35 +0200 Subject: [PATCH] feature(releaser): better goreleaser with arm support and optimized AMD64 Signed-off-by: Dusan Malusev --- .github/workflows/release.yml | 3 ++ .gitignore | 1 + .goreleaser.yml | 64 +++++++++++++++++++++++++++++++---- Dockerfile | 13 +------ 4 files changed, 62 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b5e478..af3c715 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,9 @@ jobs: with: go-version: '1.23' + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.gitignore b/.gitignore index 6a64bbb..97f5c95 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ cmd/gemini/dist/ .vscode bin/ coverage.txt +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml index 00fcaaf..bf5f6c8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,34 +2,84 @@ version: 2 env: - GO111MODULE=on + - GOARM64=v8.0,lse,crypto + - CFLAGS="-O3" + - CXXFLAGS="-O3" + before: hooks: - go mod download + builds: - - - env: + - env: - CGO_ENABLED=0 goos: - linux + ldflags: -s -w goarch: - amd64 + - arm64 + main: ./cmd/gemini + goamd64: + - v3 + archives: - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + files: + - README.md + - CHANGELOG.md + - LICENSE + +source: + enabled: true + format: 'tar.gz' checksum: name_template: 'checksums.txt' snapshot: - name_template: "{{ .Tag }}-next" + name_template: '{{ .Tag }}-next' changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' + - '^docs:' + - '^test:' dockers: - image_templates: - - scylladb/gemini:{{ .Tag }} - - scylladb/gemini:latest + - scylladb/gemini:{{ .Version }}-amd64 + goarch: amd64 + goamd64: v3 + goos: linux + id: gemini-amd64 + build_flag_templates: + - '--platform=linux/amd64' + + - image_templates: + - scylladb/gemini:{{ .Version }}-arm64v8 + goarch: arm64 + id: gemini-arm + goos: linux + build_flag_templates: + - '--platform=linux/arm64/v8' + +docker_manifests: + - name_template: 'scylladb/gemini:{{ .Version }}' + skip_push: false + image_templates: + - 'scylladb/gemini:{{ .Version }}-amd64' + - 'scylladb/gemini:{{ .Version }}-arm64v8' + + - name_template: 'scylladb/gemini:latest' + skip_push: false + image_templates: + - 'scylladb/gemini:{{ .Version }}-amd64' + - 'scylladb/gemini:{{ .Version }}-arm64v8' + +release: + mode: keep-existing + make_latest: true + prerelease: auto + skip_upload: false diff --git a/Dockerfile b/Dockerfile index 9454a45..b4d0e76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,8 @@ -FROM golang:1.23 AS builder - -ENV GO111MODULE=on - -WORKDIR /gemini - -COPY . . - -RUN apt-get update && apt-get install -y libc-dev build-essential \ - && make build - FROM busybox AS production WORKDIR /gemini -COPY --from=builder /gemini/bin/gemini . +COPY gemini . ENV PATH="/gemini:${PATH}"