-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [x] go-code version cleanup * [x] extend tests (vet & format) * [x] build & publish docker
- Loading branch information
Showing
4 changed files
with
79 additions
and
24 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
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,52 @@ | ||
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*") | ||
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/) | ||
|
||
VERSION ?= next | ||
ifneq ($(DRONE_TAG),) | ||
VERSION := $(DRONE_TAG:v%=%) | ||
endif | ||
|
||
# append commit-sha to next version | ||
BUILD_VERSION := $(VERSION) | ||
ifeq ($(BUILD_VERSION),next) | ||
BUILD_VERSION := $(shell echo "next-$(shell echo ${DRONE_COMMIT_SHA} | head -c 8)") | ||
endif | ||
|
||
LDFLAGS := -s -w -extldflags "-static" -X main.version=${BUILD_VERSION} | ||
|
||
all: build | ||
|
||
vendor: | ||
go mod tidy | ||
go mod vendor | ||
|
||
formatcheck: | ||
@([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1) | ||
|
||
format: | ||
@gofmt -w ${GOFILES_NOVENDOR} | ||
|
||
.PHONY: clean | ||
clean: | ||
go clean -i ./... | ||
rm -rf release/ | ||
|
||
.PHONY: vet | ||
vet: | ||
@echo "Running go vet..." | ||
@go vet $(GO_PACKAGES) | ||
|
||
test: | ||
go test -race -cover ./... | ||
|
||
build: | ||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/linux/amd64/plugin-s3 | ||
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/linux/arm64/plugin-s3 | ||
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/linux/arm/plugin-s3 | ||
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/windows/amd64/plugin-s3 | ||
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/darwin/amd64/plugin-s3 | ||
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/darwin/arm64/plugin-s3 | ||
|
||
.PHONY: version | ||
version: | ||
@echo ${VERSION} |
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
This file was deleted.
Oops, something went wrong.