-
-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from ccojocar/goreleaser
Use the goreleaser tool to perform releases
- Loading branch information
Showing
6 changed files
with
85 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
_obj | ||
_test | ||
vendor | ||
dist | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
builds: | ||
- main : ./cmd/gosec/ | ||
binary: gosec | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- amd64 | ||
ldflags: -X main.Version={{.Version}} -X main.GitTag={{.Tag}} -X main.BuildDate={{.Date}} | ||
env: | ||
- CGO_ENABLED=0 | ||
|
||
archive: | ||
files: | ||
- README.md | ||
- LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,44 @@ | ||
GIT_TAG?= $(shell git describe --always --tags) | ||
BUILD_DATE = $(shell date +%Y-%m-%d) | ||
BIN = gosec | ||
BUILD_CMD = go build -ldflags "-X main.Version=${VERSION} -X main.GitTag=${GIT_TAG} -X main.BuildDate=${BUILD_DATE}" -o build/$(BIN)-$(VERSION)-$${GOOS}-$${GOARCH} ./cmd/gosec/ & | ||
FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr) | ||
IMAGE_REPO = docker.io | ||
|
||
default: | ||
$(MAKE) bootstrap | ||
$(MAKE) build | ||
|
||
bootstrap: | ||
dep ensure | ||
|
||
test: bootstrap | ||
test -z '$(FMT_CMD)' | ||
go vet $(go list ./... | grep -v /vendor/) | ||
golint -set_exit_status $(shell go list ./... | grep -v vendor) | ||
gosec ./... | ||
ginkgo -r -v | ||
bootstrap: | ||
dep ensure | ||
|
||
build: | ||
go build -o $(BIN) ./cmd/gosec/ | ||
|
||
clean: | ||
rm -rf build vendor | ||
rm -rf build vendor dist | ||
rm -f release image bootstrap $(BIN) | ||
|
||
release: bootstrap | ||
ifndef VERSION | ||
$(error VERSION flag is not set. Run 'make release VERSION=<YOUR VERSION>'.) | ||
endif | ||
@echo "Running build command..." | ||
bash -c '\ | ||
export GOOS=linux; export GOARCH=amd64; export CGO_ENABLED=0; $(BUILD_CMD) \ | ||
wait \ | ||
' | ||
touch release | ||
@echo "Releasing the gosec binary..." | ||
goreleaser release | ||
|
||
image: release | ||
@echo "Building the Docker image..." | ||
docker build -t $(IMAGE_REPO)/$(BIN):$(VERSION) . | ||
docker tag $(IMAGE_REPO)/$(BIN):$(VERSION) $(IMAGE_REPO)/$(BIN):latest | ||
docker build -t $(IMAGE_REPO)/$(BIN):$(GIT_TAG) . | ||
docker tag $(IMAGE_REPO)/$(BIN):$(GIT_TAG) $(IMAGE_REPO)/$(BIN):latest | ||
touch image | ||
|
||
image-push: image | ||
@echo "Pushing the Docker image..." | ||
docker push $(IMAGE_REPO)/$(BIN):$(VERSION) | ||
|
||
docker push $(IMAGE_REPO)/$(BIN):$(GIT_TAG) | ||
docker push $(IMAGE_REPO)/$(BIN):latest | ||
|
||
.PHONY: test build clean image-push | ||
.PHONY: test build clean release image image-push | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters