Use docker buildx for building and pushing images

This has the benefit that every tag only shows up as one image. With goreleaser, multiple images were shipped
This commit is contained in:
Joris Coenen
2021-04-23 18:40:15 +02:00
parent e8e01d6578
commit 9e8f621020
2 changed files with 24 additions and 15 deletions

View File

@@ -1,9 +1,9 @@
name: goreleaser name: release
on: on:
push: push:
tags: tags:
- '*' - 'v*'
jobs: jobs:
goreleaser: goreleaser:
@@ -16,6 +16,18 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
-
name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: |
1password/onepassword-operator
# Publish image for x.y.z and x.y
# The latest tag is automatically added for semver tags
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
@@ -29,15 +41,14 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Set up Go name: Build and push
uses: actions/setup-go@v2 uses: docker/build-push-action@v2
with: with:
go-version: 1.15 context: .
- file: Dockerfile
name: Run GoReleaser platforms: linux/amd64,linux/arm64
uses: goreleaser/goreleaser-action@v2 push: true
with: tags: ${{ steps.meta.outputs.tags }}
version: latest labels: ${{ steps.meta.outputs.labels }}
args: release --rm-dist build-args: |
env: operator_version=${{ github.event.ref }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -14,8 +14,6 @@ COPY vendor/ vendor/
# Build # Build
ARG operator_version=dev ARG operator_version=dev
RUN CGO_ENABLED=0 \ RUN CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
GO111MODULE=on \ GO111MODULE=on \
go build \ go build \
-ldflags "-X version.Version=$operator_version" \ -ldflags "-X version.Version=$operator_version" \