From a6458415d8333dbc1930080b90dd07a471987a80 Mon Sep 17 00:00:00 2001 From: Nick Turner Date: Tue, 13 Dec 2022 21:05:26 -0800 Subject: [PATCH] Add automatic release creation * Run goreleaser on tag creation to automatically create release * Reduce build duplication * Remove Dockerfile.goreleaser * Remove parameter to cloudbuild specifying base image * Rely on cloudbuild for publicly consumable images * Only 1 Dockerfile --- .github/workflows/create-release.yml | 29 ++++++++++++++++++++++++++++ .goreleaser.yaml | 24 ----------------------- Dockerfile.goreleaser | 21 -------------------- cloudbuild.yaml | 1 - 4 files changed, 29 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/create-release.yml delete mode 100644 Dockerfile.goreleaser diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 000000000..1cee3b0cb --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,29 @@ +# Github Action to create a release with goreleaser +name: Create Release +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v3 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0983dbec1..b64fb27a7 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -20,30 +20,6 @@ builds: ldflags: - "-s -w -X sigs.k8s.io/aws-iam-authenticator/pkg.Version={{.Version}} -X sigs.k8s.io/aws-iam-authenticator/pkg.CommitID={{.Commit}} -buildid=''" -dockers: - - use: buildx - goarch: amd64 - goos: linux - build_flag_templates: - - "--platform=linux/amd64" - dockerfile: Dockerfile.goreleaser - image_templates: - - "602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:{{ .Tag }}-amd64" - - use: buildx - goarch: arm64 - goos: linux - build_flag_templates: - - "--platform=linux/arm64" - dockerfile: Dockerfile.goreleaser - image_templates: - - "602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:{{ .Tag }}-arm64" - -docker_manifests: - - name_template: "602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:{{ .Tag }}" - image_templates: - - "602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:{{ .Tag }}-amd64" - - "602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:{{ .Tag }}-arm64" - snapshot: name_template: "git-{{.ShortCommit}}" diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser deleted file mode 100644 index 675f18bc5..000000000 --- a/Dockerfile.goreleaser +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2022 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -ARG image=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2021-12-01-1638322424 - -FROM public.ecr.aws/eks-distro/kubernetes/go-runner:v0.9.0-eks-1-21-4 as go-runner - -FROM $image -COPY --from=go-runner /usr/local/bin/go-runner /usr/local/bin/go-runner -COPY aws-iam-authenticator /aws-iam-authenticator -ENTRYPOINT ["/aws-iam-authenticator"] diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 1dc7d7f98..fe64e7de6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -7,7 +7,6 @@ steps: - build - --tag=gcr.io/$PROJECT_ID/aws-iam-authenticator:$_GIT_TAG - --tag=gcr.io/$PROJECT_ID/aws-iam-authenticator:latest - - --build-arg=IMAGE=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2021-08-26-1630012071 - --platform=linux/amd64,linux/arm64 - --output=type=registry - .