From fbcb5a0ac084f6875805d3464aaccbbd79713f49 Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 14 Jun 2018 15:19:34 -0400 Subject: [PATCH 1/2] use makefile --- .drone.yml | 8 ++------ Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 Makefile diff --git a/.drone.yml b/.drone.yml index 4311106..12fc0dc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,18 +23,14 @@ pipeline: environment: GOPATH: /go commands: - - go get -u golang.org/x/lint/golint - - golint -set_exit_status $(go list ./...) - - go vet ./... - - go test -cover ./... + - make test static: image: golang:1.10 pull: true environment: GOPATH: /go commands: - - go get -u github.com/mitchellh/gox - - gox -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -output "releases/gitea-github-migrator_{{.OS}}_{{.Arch}}" + - make release when: event: [ tag ] gitea: diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f0328a3 --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +IMPORT := git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator +GO ?= go + +BUILD=$(or ${DRONE_BUILD_NUMBER},${DRONE_BUILD_NUMBER},0) + +ifneq ($(DRONE_TAG),) + VERSION ?= $(subst v,,$(DRONE_TAG)) +else + ifneq ($(DRONE_BRANCH),) + VERSION ?= $(subst release/v,,$(DRONE_BRANCH)) + else + VERSION ?= master + endif +endif + +LDFLAGS := -X "main.Version=$(VERSION)" -X "main.build=$(BUILD)" + +.PHONY: all +all: + +.PHONY: release +release: + @hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GO) get -u github.com/mitchellh/gox; \ + fi + gox -ldflags $(LDFLAGS) -output "releases/gitea-github-migrator_{{.OS}}_{{.Arch}}" + +.PHONY: lint +lint: + @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GO) get -u golang.org/x/lint/golint; \ + fi + golint -set_exit_status $(go list ./...) + +.PHONY: vet +vet: + go vet ./... + +.PHONY: test +test: lint vet + go test -cover ./... + \ No newline at end of file -- 2.36.2 From 48c05a8a40e3f5b392670d94c008ca86b2df0031 Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 14 Jun 2018 15:35:25 -0400 Subject: [PATCH 2/2] fix ldflags --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f0328a3..0c1ff02 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ else endif endif -LDFLAGS := -X "main.Version=$(VERSION)" -X "main.build=$(BUILD)" +LDFLAGS := -X main.Version=$(VERSION) -X main.build=$(BUILD) .PHONY: all all: @@ -23,7 +23,7 @@ release: @hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ $(GO) get -u github.com/mitchellh/gox; \ fi - gox -ldflags $(LDFLAGS) -output "releases/gitea-github-migrator_{{.OS}}_{{.Arch}}" + gox -ldflags "$(LDFLAGS)" -output "releases/gitea-github-migrator_{{.OS}}_{{.Arch}}" .PHONY: lint lint: -- 2.36.2