From eace0255de0cf6a814d64deb3f0d47f91b8ad7cd Mon Sep 17 00:00:00 2001 From: Steve Kriss Date: Thu, 8 Nov 2018 16:08:56 -0700 Subject: [PATCH] goreleaser: update example image tags to match version being released Signed-off-by: Steve Kriss --- .gitignore | 1 + .goreleaser.yml | 5 ++++- hack/set-example-tags.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 hack/set-example-tags.sh diff --git a/.gitignore b/.gitignore index e98574df7..fdd7a5821 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ _obj _test _output +config # Architecture specific extensions/prefixes *.[568vq] diff --git a/.goreleaser.yml b/.goreleaser.yml index 33a43a526..584342c5e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,6 +13,9 @@ # limitations under the License. dist: _output +before: + hooks: + - ./hack/set-example-tags.sh builds: - main: ./cmd/ark/main.go env: @@ -41,7 +44,7 @@ archive: name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" files: - LICENSE - - examples/**/* + - config/**/* checksum: name_template: 'CHECKSUM' snapshot: diff --git a/hack/set-example-tags.sh b/hack/set-example-tags.sh new file mode 100755 index 000000000..38b302138 --- /dev/null +++ b/hack/set-example-tags.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Copyright 2018 the Heptio Ark contributors. +# +# 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. + +set -o nounset +set -o errexit +set -o pipefail + +# this script copies all of the files under examples/ into a new directory, +# config/ (which is gitignored so it doesn't result in the git +# state being dirty, which would prevent goreleaser from running), and then +# updates all of the image tags in those files to use $GIT_SHA (which will +# be the release/tag name). + +rm -rf config/ && cp -r examples/ config/ + +# the "-i'.bak'" flag to sed is necessary, with no space between the flag +# and the value, for this to be compatible across BSD/OSX sed and GNU sed. +# remove the ".bak" files afterwards (they're copies of the originals). +find config/ -type f -name "*.yaml" | xargs sed -i'.bak' "s|gcr.io/heptio-images/ark:latest|gcr.io/heptio-images/ark:$GIT_SHA|g" +find config/ -type f -name "*.bak" | xargs rm + +find config/ -type f -name "*.yaml" | xargs sed -i'.bak' "s|gcr.io/heptio-images/fsfreeze-pause:latest|gcr.io/heptio-images/fsfreeze-pause:$GIT_SHA|g" +find config/ -type f -name "*.bak" | xargs rm