Skip to content

Commit

Permalink
goreleaser scripts for building/creating a release on a workstation
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kriss <[email protected]>
  • Loading branch information
skriss committed Oct 25, 2018
1 parent 21a2a2e commit 18b434c
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,6 @@ clean:
docker rmi $(BUILDER_IMAGE)

ci: all verify test

goreleaser:
hack/goreleaser.sh
52 changes: 52 additions & 0 deletions hack/goreleaser.sh
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit 18b434c

Please sign in to comment.