From ec6aab2c8daa88067e09b82952e997871be81a86 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 22 Dec 2020 14:53:01 +0200 Subject: [PATCH] Publish multi-arch image to GitHub Container Registry Signed-off-by: Stefan Prodan --- .github/workflows/release.yml | 2 ++ .goreleaser.yml | 4 ---- Dockerfile | 5 ++++- Makefile | 17 +++-------------- artifacts/flagger/deployment.yaml | 2 +- charts/flagger/LICENSE | 2 +- charts/flagger/README.md | 2 +- charts/flagger/values.yaml | 2 +- charts/loadtester/values.yaml | 2 +- kustomize/base/flagger/deployment.yaml | 2 +- kustomize/tester/deployment.yaml | 2 +- 11 files changed, 16 insertions(+), 26 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7c9b459b..54f13ec5f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,6 +41,8 @@ jobs: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64,linux/arm/v7 + build-args: | + REVISON=${{ github.sha }} tags: | ghcr.io/fluxcd/flagger:${{ steps.prep.outputs.VERSION }} labels: | diff --git a/.goreleaser.yml b/.goreleaser.yml index 5e2548722..fc2c59a0a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -12,7 +12,3 @@ archives: - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" files: - none* -changelog: - filters: - exclude: - - '^CircleCI' diff --git a/Dockerfile b/Dockerfile index a45c9df14..d2d30928b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM golang:1.15-alpine as builder ARG TARGETPLATFORM +ARG REVISON WORKDIR /workspace @@ -16,7 +17,9 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # build -RUN CGO_ENABLED=0 go build -a -o flagger ./cmd/flagger +RUN CGO_ENABLED=0 go build \ + -ldflags "-s -w -X github.com/fluxcd/flagger/pkg/version.REVISION=${REVISON}" \ + -a -o flagger ./cmd/flagger FROM alpine:3.12 diff --git a/Makefile b/Makefile index 40d503db8..6b7dbeda1 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,7 @@ VERSION?=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | t LT_VERSION?=$(shell grep 'VERSION' cmd/loadtester/main.go | awk '{ print $$4 }' | tr -d '"' | head -n1) build: - GIT_COMMIT=$$(git rev-list -1 HEAD) && CGO_ENABLED=0 GOOS=linux go build \ - -ldflags "-s -w -X github.com/fluxcd/flagger/pkg/version.REVISION=$${GIT_COMMIT}" \ - -a -installsuffix cgo -o ./bin/flagger ./cmd/flagger/* - docker build -t weaveworks/flagger:$(TAG) . -f Dockerfile - -push: - docker tag fluxcd/flagger:$(TAG) fluxcd/flagger:$(VERSION) - docker push fluxcd/flagger:$(VERSION) + CGO_ENABLED=0 go build -a -o ./bin/flagger ./cmd/flagger fmt: gofmt -l -s -w ./ @@ -48,13 +41,9 @@ release: git tag "v$(VERSION)" git push origin "v$(VERSION)" -release-notes: - cd /tmp && GH_REL_URL="https://github.com/buchanae/github-release-notes/releases/download/0.2.0/github-release-notes-linux-amd64-0.2.0.tar.gz" && \ - curl -sSL $${GH_REL_URL} | tar xz && sudo mv github-release-notes /usr/local/bin/ - loadtester-build: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./bin/loadtester ./cmd/loadtester/* - docker build -t fluxcd/flagger-loadtester:$(LT_VERSION) . -f Dockerfile.loadtester + docker build -t ghcr.io/fluxcd/flagger-loadtester:$(LT_VERSION) . -f Dockerfile.loadtester loadtester-push: - docker push fluxcd/flagger-loadtester:$(LT_VERSION) + docker push ghcr.io/fluxcd/flagger-loadtester:$(LT_VERSION) diff --git a/artifacts/flagger/deployment.yaml b/artifacts/flagger/deployment.yaml index 03e818d7a..cc654fcbb 100644 --- a/artifacts/flagger/deployment.yaml +++ b/artifacts/flagger/deployment.yaml @@ -22,7 +22,7 @@ spec: serviceAccountName: flagger containers: - name: flagger - image: weaveworks/flagger:1.4.2 + image: ghcr.io/fluxcd/flagger:1.4.2 imagePullPolicy: IfNotPresent ports: - name: http diff --git a/charts/flagger/LICENSE b/charts/flagger/LICENSE index 6e292ed28..261eeb9e9 100644 --- a/charts/flagger/LICENSE +++ b/charts/flagger/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2018 Weaveworks. All rights reserved. + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/charts/flagger/README.md b/charts/flagger/README.md index e62c7c070..9c297ff2e 100644 --- a/charts/flagger/README.md +++ b/charts/flagger/README.md @@ -110,7 +110,7 @@ The following tables lists the configurable parameters of the Flagger chart and Parameter | Description | Default --- | --- | --- -`image.repository` | Image repository | `weaveworks/flagger` +`image.repository` | Image repository | `ghcr.io/fluxcd/flagger` `image.tag` | Image tag | `` `image.pullPolicy` | Image pull policy | `IfNotPresent` `logLevel` | Log level | `info` diff --git a/charts/flagger/values.yaml b/charts/flagger/values.yaml index d25f85dfc..b752db6cb 100644 --- a/charts/flagger/values.yaml +++ b/charts/flagger/values.yaml @@ -1,7 +1,7 @@ # Default values for flagger. image: - repository: weaveworks/flagger + repository: ghcr.io/fluxcd/flagger tag: 1.4.2 pullPolicy: IfNotPresent pullSecret: diff --git a/charts/loadtester/values.yaml b/charts/loadtester/values.yaml index c089cc6d7..0f93aa876 100644 --- a/charts/loadtester/values.yaml +++ b/charts/loadtester/values.yaml @@ -1,7 +1,7 @@ replicaCount: 1 image: - repository: weaveworks/flagger-loadtester + repository: ghcr.io/fluxcd/flagger-loadtester tag: 0.18.0 pullPolicy: IfNotPresent diff --git a/kustomize/base/flagger/deployment.yaml b/kustomize/base/flagger/deployment.yaml index f88be5875..f0bd8b133 100644 --- a/kustomize/base/flagger/deployment.yaml +++ b/kustomize/base/flagger/deployment.yaml @@ -20,7 +20,7 @@ spec: serviceAccountName: flagger containers: - name: flagger - image: weaveworks/flagger:1.0.0 + image: ghcr.io/fluxcd/flagger:1.0.0 imagePullPolicy: IfNotPresent ports: - name: http diff --git a/kustomize/tester/deployment.yaml b/kustomize/tester/deployment.yaml index b25e8150b..18e276e0e 100644 --- a/kustomize/tester/deployment.yaml +++ b/kustomize/tester/deployment.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: loadtester - image: weaveworks/flagger-loadtester:0.18.0 + image: ghcr.io/fluxcd/flagger-loadtester:0.18.0 imagePullPolicy: IfNotPresent ports: - name: http