From d6f6875771b5dfce83fbe2bb5e417307c14dccf5 Mon Sep 17 00:00:00 2001 From: avery Date: Sun, 3 May 2026 06:51:23 +0100 Subject: [PATCH] chore: upgrade to goreleaser v2 (#1208) Co-authored-by: Gareth --- .github/workflows/reusable-release.yml | 2 +- .goreleaser.yaml | 301 ++++--------------------- Dockerfile.alpine | 7 +- Dockerfile.scratch | 11 +- README.md | 2 +- 5 files changed, 54 insertions(+), 269 deletions(-) diff --git a/.github/workflows/reusable-release.yml b/.github/workflows/reusable-release.yml index 134a033e..702ce24d 100644 --- a/.github/workflows/reusable-release.yml +++ b/.github/workflows/reusable-release.yml @@ -59,7 +59,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v7 with: distribution: goreleaser version: latest diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 5f42b0e6..be632fe1 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,4 +1,4 @@ -version: 1 +version: 2 env: - BACKREST_BUILD_VERSION={{.Version}} @@ -77,11 +77,12 @@ builds: archives: - id: default - builds: + ids: - other - linux - windows - format: tar.gz + formats: + - tar.gz name_template: >- {{ .ProjectName }}_ {{- title .Os }}_ @@ -91,7 +92,7 @@ archives: {{- if .Arm }}v{{ .Arm }}{{ end }} format_overrides: - goos: windows - format: zip + formats: zip files: - install.sh - uninstall.sh @@ -100,274 +101,56 @@ archives: - CHANGELOG.md allow_different_binary_count: true -dockers: - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-alpine-amd64 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-amd64 +dockers_v2: + - id: alpine + images: + - "garethgeorge/backrest" + - "ghcr.io/garethgeorge/backrest" + tags: + - latest + - latest-alpine + - v{{ .Major }} + - v{{ .Major }}.{{ .Minor }} + - "{{ .Tag }}" + - "{{ .Tag }}-alpine" dockerfile: Dockerfile.alpine - use: buildx - build_flag_templates: - - "--pull" - - "--platform=linux/amd64" - ids: - - linux - - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-alpine-arm64 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-arm64 - dockerfile: Dockerfile.alpine - goarch: arm64 - use: buildx - build_flag_templates: - - "--pull" - - "--platform=linux/arm64/v8" - ids: - - linux - - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-alpine-armv6 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv6 - dockerfile: Dockerfile.alpine - use: buildx - goarch: arm - goarm: 6 - build_flag_templates: + flags: - "--pull" + # provenance attestations break the multi-arch manifest for armv6/armv7/386 - "--provenance=false" - - "--platform=linux/arm/v6" ids: - linux - docker-entrypoint + platforms: + - linux/amd64 + - linux/arm64 + - linux/arm/v6 + - linux/arm/v7 + - linux/386 - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-alpine-armv7 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv7 - dockerfile: Dockerfile.alpine - use: buildx - goarch: arm - goarm: 7 - build_flag_templates: - - "--pull" - - "--provenance=false" - - "--platform=linux/arm/v7" - ids: - - linux - - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-alpine-386 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-386 - dockerfile: Dockerfile.alpine - use: buildx - goarch: "386" - goarm: 7 - build_flag_templates: - - "--pull" - - "--provenance=false" - - "--platform=linux/386" - ids: - - linux - - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-scratch-arm64 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-arm64 + - id: scratch + images: + - garethgeorge/backrest + - ghcr.io/garethgeorge/backrest + tags: + - scratch + - v{{ .Major }}-scratch + - v{{ .Major }}.{{ .Minor }}-scratch + - "{{ .Tag }}-scratch" dockerfile: Dockerfile.scratch - goarch: arm64 - use: buildx - build_flag_templates: - - "--pull" - - "--platform=linux/arm64/v8" - ids: - - linux - - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-scratch-amd64 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-amd64 - dockerfile: Dockerfile.scratch - use: buildx - build_flag_templates: - - "--pull" - - "--platform=linux/amd64" - ids: - - linux - - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-scratch-armv6 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv6 - dockerfile: Dockerfile.scratch - use: buildx - goarch: arm - goarm: 6 - build_flag_templates: + flags: - "--pull" + # provenance attestations break the multi-arch manifest for armv6/armv7/386 - "--provenance=false" - - "--platform=linux/arm/v6" ids: - linux - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-scratch-armv7 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv7 - dockerfile: Dockerfile.scratch - use: buildx - goarch: arm - goarm: 7 - build_flag_templates: - - "--pull" - - "--provenance=false" - - "--platform=linux/arm/v7" - ids: - - linux - - docker-entrypoint - - - image_templates: - - garethgeorge/backrest:{{ .Tag }}-scratch-386 - - ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-386 - dockerfile: Dockerfile.scratch - use: buildx - goarch: "386" - goarm: 7 - build_flag_templates: - - "--pull" - - "--provenance=false" - - "--platform=linux/386" - ids: - - linux - - docker-entrypoint - -docker_manifests: - - name_template: "garethgeorge/backrest:latest" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "ghcr.io/garethgeorge/backrest:latest" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "garethgeorge/backrest:v{{ .Major }}" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "ghcr.io/garethgeorge/backrest:v{{ .Major }}" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "garethgeorge/backrest:v{{ .Major }}.{{ .Minor }}" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "ghcr.io/garethgeorge/backrest:v{{ .Major }}.{{ .Minor }}" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "garethgeorge/backrest:{{ .Tag }}" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "ghcr.io/garethgeorge/backrest:{{ .Tag }}" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "garethgeorge/backrest:latest-alpine" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "ghcr.io/garethgeorge/backrest:latest-alpine" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-alpine-386" - - name_template: "garethgeorge/backrest:scratch" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "garethgeorge/backrest:{{ .Tag }}-scratch-386" - - name_template: "ghcr.io/garethgeorge/backrest:scratch" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-386" - - name_template: "garethgeorge/backrest:v{{ .Major }}-scratch" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "garethgeorge/backrest:{{ .Tag }}-scratch-386" - - name_template: "ghcr.io/garethgeorge/backrest:v{{ .Major }}-scratch" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-386" - - name_template: "garethgeorge/backrest:v{{ .Major }}.{{ .Minor }}-scratch" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "garethgeorge/backrest:{{ .Tag }}-scratch-386" - - name_template: "ghcr.io/garethgeorge/backrest:v{{ .Major }}.{{ .Minor }}-scratch" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-386" - - name_template: "garethgeorge/backrest:{{ .Tag }}-scratch" - image_templates: - - "garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "garethgeorge/backrest:{{ .Tag }}-scratch-386" - - name_template: "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch" - image_templates: - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-amd64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-arm64" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv6" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-armv7" - - "ghcr.io/garethgeorge/backrest:{{ .Tag }}-scratch-386" + platforms: + - linux/amd64 + - linux/arm64 + - linux/arm/v6 + - linux/arm/v7 + - linux/386 brews: - name: backrest diff --git a/Dockerfile.alpine b/Dockerfile.alpine index ddec214f..cb0d2398 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -4,9 +4,10 @@ RUN apk --no-cache add tini ca-certificates curl bash rclone openssh tzdata dock rclone selfupdate --stable RUN mkdir -p /tmp -# Copy the binary we built via goreleaser -COPY backrest /backrest -COPY docker-entrypoint /docker-entrypoint +ARG TARGETPLATFORM +# Binaries are staged per-platform by goreleaser dockers_v2 +COPY $TARGETPLATFORM/backrest /backrest +COPY $TARGETPLATFORM/docker-entrypoint /docker-entrypoint # Run the binary to install dependencies (may run via QEMU but necessary) RUN /backrest --install-deps-only diff --git a/Dockerfile.scratch b/Dockerfile.scratch index 64f96f1f..8b0e9af3 100644 --- a/Dockerfile.scratch +++ b/Dockerfile.scratch @@ -3,8 +3,9 @@ FROM alpine:latest AS alpine RUN apk add --no-cache ca-certificates tini-static RUN mkdir /tmp-orig -# Copy binary from goreleaser to run install-deps -COPY backrest /backrest +ARG TARGETPLATFORM +# Binaries are staged per-platform by goreleaser dockers_v2 +COPY $TARGETPLATFORM/backrest /backrest RUN /backrest --install-deps-only # Setup restic path @@ -20,9 +21,9 @@ COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=alpine /bin/restic /bin/restic COPY --from=alpine /sbin/tini-static /tini -# Copy binaries from goreleaser -COPY backrest /backrest -COPY docker-entrypoint /docker-entrypoint +ARG TARGETPLATFORM +COPY $TARGETPLATFORM/backrest /backrest +COPY $TARGETPLATFORM/docker-entrypoint /docker-entrypoint ENTRYPOINT ["/tini", "--", "/docker-entrypoint"] CMD ["/backrest"] diff --git a/README.md b/README.md index 3d5820b4..b51f6e4c 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,7 @@ If you prefer not to use Nix, install the following manually: - [Go](https://go.dev/) 1.24 or greater - [Node.js](https://nodejs.org/en) 20.x and [pnpm](https://pnpm.io/) 9 -- [goreleaser](https://github.com/goreleaser/goreleaser) `go install github.com/goreleaser/goreleaser@latest` +- [goreleaser](https://github.com/goreleaser/goreleaser) `go install github.com/goreleaser/goreleaser/v2@latest` **(Optional) To edit protobuf definitions:**