Skip to content

Commit 18b434c

Browse files
committed
goreleaser scripts for building/creating a release on a workstation
Signed-off-by: Steve Kriss <steve@heptio.com>
1 parent 21a2a2e commit 18b434c

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

.goreleaser.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2018 the Heptio Ark contributors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
dist: _output
16+
builds:
17+
- main: ./cmd/ark/main.go
18+
env:
19+
- CGO_ENABLED=0
20+
goos:
21+
- linux
22+
- darwin
23+
- windows
24+
goarch:
25+
- amd64
26+
- arm
27+
- arm64
28+
ignore:
29+
# don't build arm/arm64 for darwin or windows
30+
- goos: darwin
31+
goarch: arm
32+
- goos: darwin
33+
goarch: arm64
34+
- goos: windows
35+
goarch: arm
36+
- goos: windows
37+
goarch: arm64
38+
ldflags:
39+
- -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 }}"
40+
archive:
41+
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
42+
files:
43+
- LICENSE
44+
- examples/**/*
45+
checksum:
46+
name_template: 'CHECKSUM'
47+
snapshot:
48+
name_template: "{{ .Env.GIT_SHA }}"
49+
release:
50+
github:
51+
owner: heptio
52+
name: ark
53+
draft: true

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,6 @@ clean:
233233
docker rmi $(BUILDER_IMAGE)
234234

235235
ci: all verify test
236+
237+
goreleaser:
238+
hack/goreleaser.sh

hack/goreleaser.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018 the Heptio Ark contributors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
# $PUBLISH must explicitly be set to 'true' for goreleaser
22+
# to publish the release to GitHub.
23+
if [ "${PUBLISH:-}" != "true" ]; then
24+
SKIP_PUBLISH="--skip-publish"
25+
else
26+
SKIP_PUBLISH=""
27+
fi
28+
29+
if [ -z "${GITHUB_TOKEN}" ]; then
30+
echo "GITHUB_TOKEN must be set"
31+
exit 1
32+
fi
33+
34+
# TODO derive this from the major+minor version
35+
if [ -z "${RELEASE_NOTES_FILE}" ]; then
36+
echo "RELEASE_NOTES_FILE must be set"
37+
exit 1
38+
fi
39+
40+
export GIT_SHA=$(git describe --tags --always)
41+
42+
GIT_DIRTY=$(git status --porcelain 2> /dev/null)
43+
if [[ -z "${GIT_DIRTY}" ]]; then
44+
export GIT_TREE_STATE=clean
45+
else
46+
export GIT_TREE_STATE=dirty
47+
fi
48+
49+
goreleaser release \
50+
--rm-dist \
51+
--release-notes="${RELEASE_NOTES_FILE}" \
52+
"${SKIP_PUBLISH}"

0 commit comments

Comments
 (0)