From 5929bebe01e7b8c7c57b3c8fdfd41d4038bb85a1 Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Tue, 18 Feb 2020 15:51:10 +0000 Subject: [PATCH] Add Drone and releases (#2) Move comment to appease linter Signed-off-by: jolheiser Add Drone and releases Signed-off-by: jolheiser Co-authored-by: jolheiser Reviewed-on: https://gitea.com/jolheiser/sip/pulls/2 --- .drone.yml | 73 ++++++++++++++++++++++++++++++++++++++++ Makefile | 53 ++++++++++++++++++++++++++++- README.md | 2 ++ modules/config/config.go | 1 + 4 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..2ee6ec2 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,73 @@ +--- +kind: pipeline +name: compliance + +platform: + os: linux + arch: arm64 + +trigger: + event: + - pull_request + +steps: + - name: build + pull: always + image: golang:1.13 + environment: + GOPROXY: https://goproxy.cn + commands: + - go test -race + - go build + + - name: check + pull: always + image: golang:1.13 + environment: + GOPROXY: https://goproxy.cn + commands: + - make lint + +--- +kind: pipeline +name: release + +platform: + os: linux + arch: amd64 + +trigger: + branch: + - master + event: + - push + - tag + +steps: + - name: fetch-tags + pull: always + image: docker:git + commands: + - git fetch --tags --force + + - name: release + pull: always + image: techknowlogick/xgo:latest + environment: + GOPROXY: https://goproxy.cn + commands: + - export PATH=$PATH:$GOPATH/bin + - make release + + - name: gitea + pull: always + image: plugins/gitea-release:1 + settings: + api_key: + from_secret: gitea_token + base_url: https://gitea.com + files: + - "dist/release/*" + when: + event: + - tag \ No newline at end of file diff --git a/Makefile b/Makefile index ca0b755..a555565 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ +DIST := dist GO ?= go +SHASUM ?= shasum -a 256 ifneq ($(DRONE_TAG),) VERSION ?= $(subst v,,$(DRONE_TAG)) @@ -32,4 +34,53 @@ fmt: .PHONY: test test: - $(GO) test -race ./... \ No newline at end of file + $(GO) test -race ./... + +.PHONY: release +release: release-dirs check-xgo release-windows release-linux release-darwin release-copy release-compress release-check + +.PHONY: check-xgo +check-xgo: + @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GO) get -u src.techknowlogick.com/xgo; \ + fi + +.PHONY: release-dirs +release-dirs: + mkdir -p $(DIST)/binaries $(DIST)/release + +.PHONY: release-windows +release-windows: + xgo -dest $(DIST)/binaries -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out sip-$(VERSION) . +ifeq ($(CI),drone) + cp /build/* $(DIST)/binaries +endif + +.PHONY: release-linux +release-linux: + xgo -dest $(DIST)/binaries -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out sip-$(VERSION) . +ifeq ($(CI),drone) + cp /build/* $(DIST)/binaries +endif + +.PHONY: release-darwin +release-darwin: + xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out sip-$(VERSION) . +ifeq ($(CI),drone) + cp /build/* $(DIST)/binaries +endif + +.PHONY: release-copy +release-copy: + cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done; + +.PHONY: release-check +release-check: + cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done; + +.PHONY: release-compress +release-compress: + @hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \ + fi + cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done; \ No newline at end of file diff --git a/README.md b/README.md index 0f33733..ba28840 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Sip (alternative) CLI for interacting with Gitea +[![Build Status](https://drone.gitea.com/api/badges/jolheiser/sip/status.svg)](https://drone.gitea.com/jolheiser/sip) + ### Features Understands the concepts of an origin vs remote repository. diff --git a/modules/config/config.go b/modules/config/config.go index 049e379..257e358 100644 --- a/modules/config/config.go +++ b/modules/config/config.go @@ -14,6 +14,7 @@ var ( cfg *config // Config items + Origin string Upstream string Tokens []Token