Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit 3800ef8

Browse files
author
Michael Weber
committed
Added goreleaser configuration
1 parent 65a21c1 commit 3800ef8

File tree

4 files changed

+74
-20
lines changed

4 files changed

+74
-20
lines changed

.circleci/config.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ jobs:
4444
- run:
4545
name: Code Quality
4646
command: make lint
47+
- run:
48+
name: Release
49+
command: |
50+
export GOVERSION=$(go version | awk '{sub("^go","",$3);print $3;}')
51+
scripts/goreleaser --rm-dist --skip-publish ${CIRCLE_TAG:-"--snapshot"}
52+
rm -rf $(find ./dist/* -type d) || true
4753
- store_test_results:
4854
path: test-results/
4955
- store_artifacts:
5056
path: test-results/
5157
- store_artifacts:
52-
path: /go/bin/vault-plugin-splunk
58+
path: dist/
5359

5460
- save_cache:
5561
name: Saving Cache for vendor
@@ -63,10 +69,8 @@ jobs:
6369
- /tmp/go/cache
6470

6571
- persist_to_workspace:
66-
root: /go/bin
67-
# Must be relative path from root
68-
paths:
69-
- vault-plugin-splunk
72+
root: dist/
73+
paths: .
7074

7175
publish-github-release:
7276
docker:
@@ -78,9 +82,8 @@ jobs:
7882
name: "Publish Release on GitHub"
7983
command: |
8084
go get github.com/tcnksm/ghr
81-
VERSION=$(artifacts/vault-plugin-splunk -version | awk '{print $1}')
82-
zip -jr vault-plugin-splunk artifacts/
83-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -recreate ${VERSION} ./vault-plugin-splunk.zip
85+
VERSION=$(echo artifacts/vault-plugin-splunk_*_*.zip | awk -F_ '{print $2;exit;}')
86+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -recreate ${VERSION} ./artifacts/
8487
8588
workflows:
8689
version: 2

.goreleaser.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
before:
2+
# hooks:
3+
# # you may remove this if you don't use vgo
4+
# - go mod download
5+
builds:
6+
- main: cmd/vault-plugin-splunk/main.go
7+
ldflags:
8+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.goVersion={{.Env.GOVERSION}}
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- darwin
14+
goarch:
15+
- amd64
16+
archives:
17+
- replacements:
18+
386: i386
19+
format: zip
20+
format_overrides:
21+
- goos: linux
22+
format: tar.bz2
23+
name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}_{{.Arch}}"
24+
checksum:
25+
name_template: 'checksums.txt'
26+
snapshot:
27+
name_template: "{{.Version}}-next"
28+
changelog:
29+
sort: asc
30+
filters:
31+
exclude:
32+
- '^docs:'
33+
- '^test:'

Makefile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
VERSION := $(shell git describe --tags --always 2>/dev/null)
2-
SHORT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo dev)
3-
GO_VERSION := $(shell go version | awk '{ print $$3}' | sed 's/^go//')
4-
51
TESTREPORT := test-results.xml
62

73
# XXX BUG(mweber) "go env GOBIN" is empty?
84
GOBIN := $(shell go env GOPATH)/bin
95

10-
LD_FLAGS_PKG ?= main
11-
LD_FLAGS :=
12-
LD_FLAGS += -X "$(LD_FLAGS_PKG).version=$(VERSION)"
13-
LD_FLAGS += -X "$(LD_FLAGS_PKG).commit=$(SHORT_COMMIT)"
14-
LD_FLAGS += -X "$(LD_FLAGS_PKG).goVersion=$(GO_VERSION)"
15-
166
.PHONY: all
177
all: build lint test
188

@@ -22,7 +12,7 @@ dep: prereq
2212

2313
.PHONY: build
2414
build: dep vault.hcl
25-
go install -ldflags '$(LD_FLAGS)' ./...
15+
go install ./...
2616

2717
vault.hcl: vault.hcl.in
2818
sed -e 's;@@GOBIN@@;$(GOBIN);g' < $< > $@
@@ -60,4 +50,4 @@ prereq:
6050
.PHONY: clean
6151
clean:
6252
# XXX clean
63-
rm -rf vault.hcl $(TESTREPORT) vendor/
53+
rm -rf vault.hcl $(TESTREPORT) vendor/ dist/

scripts/goreleaser

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
set -e
3+
4+
TAR_FILE="/tmp/goreleaser.tar.gz"
5+
RELEASES_URL="https://github.com/goreleaser/goreleaser/releases"
6+
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
7+
8+
last_version() {
9+
curl -sL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" |
10+
rev |
11+
cut -f1 -d'/'|
12+
rev
13+
}
14+
15+
download() {
16+
test -z "$VERSION" && VERSION="$(last_version)"
17+
test -z "$VERSION" && {
18+
echo "Unable to get goreleaser version." >&2
19+
exit 1
20+
}
21+
rm -f "$TAR_FILE"
22+
curl -s -L -o "$TAR_FILE" \
23+
"$RELEASES_URL/download/$VERSION/goreleaser_$(uname -s)_$(uname -m).tar.gz"
24+
}
25+
26+
download
27+
tar -xf "$TAR_FILE" -C "$TMPDIR"
28+
"${TMPDIR}/goreleaser" "$@"

0 commit comments

Comments
 (0)