From 18b434cb241613a994303a7a2d0a1a6f55f7f4a0 Mon Sep 17 00:00:00 2001 From: Steve Kriss Date: Thu, 25 Oct 2018 13:47:26 -0600 Subject: [PATCH] goreleaser scripts for building/creating a release on a workstation Signed-off-by: Steve Kriss --- .goreleaser.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 3 +++ hack/goreleaser.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .goreleaser.yml create mode 100755 hack/goreleaser.sh diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000000..c6616c62ac --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,53 @@ +# 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. + +dist: _output +builds: + - main: ./cmd/ark/main.go + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm + - arm64 + ignore: + # don't build arm/arm64 for darwin or windows + - goos: darwin + goarch: arm + - goos: darwin + goarch: arm64 + - goos: windows + goarch: arm + - goos: windows + goarch: arm64 + ldflags: + - -X "github.com/heptio/ark/pkg/buildinfo.Version={{ .Version }}" -X "github.com/heptio/ark/pkg/buildinfo.GitSHA={{ .Env.GIT_SHA }}" -X "github.com/heptio/ark/pkg/buildinfo.GitTreeState={{ .Env.GIT_TREE_STATE }}" +archive: + name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + files: + - LICENSE + - examples/**/* +checksum: + name_template: 'CHECKSUM' +snapshot: + name_template: "{{ .Env.GIT_SHA }}" +release: + github: + owner: heptio + name: ark + draft: true diff --git a/Makefile b/Makefile index a7353feac8..1b0c60dcd5 100644 --- a/Makefile +++ b/Makefile @@ -233,3 +233,6 @@ clean: docker rmi $(BUILDER_IMAGE) ci: all verify test + +goreleaser: + hack/goreleaser.sh diff --git a/hack/goreleaser.sh b/hack/goreleaser.sh new file mode 100755 index 0000000000..aaec9e940e --- /dev/null +++ b/hack/goreleaser.sh @@ -0,0 +1,52 @@ +#!/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 errexit +set -o nounset +set -o pipefail + +# $PUBLISH must explicitly be set to 'true' for goreleaser +# to publish the release to GitHub. +if [ "${PUBLISH:-}" != "true" ]; then + SKIP_PUBLISH="--skip-publish" +else + SKIP_PUBLISH="" +fi + +if [ -z "${GITHUB_TOKEN}" ]; then + echo "GITHUB_TOKEN must be set" + exit 1 +fi + +# TODO derive this from the major+minor version +if [ -z "${RELEASE_NOTES_FILE}" ]; then + echo "RELEASE_NOTES_FILE must be set" + exit 1 +fi + +export GIT_SHA=$(git describe --tags --always) + +GIT_DIRTY=$(git status --porcelain 2> /dev/null) +if [[ -z "${GIT_DIRTY}" ]]; then + export GIT_TREE_STATE=clean +else + export GIT_TREE_STATE=dirty +fi + +goreleaser release \ + --rm-dist \ + --release-notes="${RELEASE_NOTES_FILE}" \ + "${SKIP_PUBLISH}"