diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 000000000..7bcbd47a3 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,86 @@ +clone: + path: github.com/gogits/gogs + +build: + general: + image: golang:$$GO_VERSION + environment: + - TAGS=pam sqlite cert + commands: + - apt-get update -qq && apt-get install -y libpam-dev zip + - make deps + - make test + - make build + + release: + image: golang:1.5 + environment: + - TAGS=pam sqlite cert + commands: + - apt-get update -qq && apt-get install -y libpam-dev zip + - make deps + - make release + when: + repo: gogits/gogs + branch: master + matrix: + GO_VERSION: 1.5 + +publish: + github_release: + api_key: $$GITHUB_TOKEN + files: + - dist/*.tgz + - dist/*.zip + when: + repo: gogits/gogs + event: tag + matrix: + GO_VERSION: 1.5 + + docker: + username: $$DOCKER_USERNAME + password: $$DOCKER_PASSWORD + email: $$DOCKER_EMAIL + repo: gogs/gogs + tag: $${TAG##v} + when: + repo: gogits/gogs + event: tag + matrix: + GO_VERSION: 1.5 + + docker: + username: $$DOCKER_USERNAME + password: $$DOCKER_PASSWORD + email: $$DOCKER_EMAIL + repo: gogs/gogs + tag: $${BRANCH/master/latest} + when: + repo: gogits/gogs + branch: [develop, master] + matrix: + GO_VERSION: 1.5 + +notify: + gitter: + webhook: https://webhooks.gitter.im/e/c52d2013f36e28b35f71 + when: + repo: gogits/gogs + + email: + host: $$EMAIL_HOST + port: $$EMAIL_PORT + username: $$EMAIL_USERNAME + password: $$EMAIL_PASSWORD + from: drone@gogs.io + recipients: + - u@gogs.io + when: + repo: gogits/gogs + +matrix: + GO_VERSION: + - 1.3 + - 1.4 + - 1.5 diff --git a/.gitignore b/.gitignore index 774a100be..75161ce33 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,5 @@ docker/docker/init_gogs.sh gogs.sublime-project gogs.sublime-workspace .tags* -release +dist/ +bin/ diff --git a/Makefile b/Makefile index 2fa26170a..a776cf242 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,56 @@ LDFLAGS += -X "github.com/gogits/gogs/modules/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')" LDFLAGS += -X "github.com/gogits/gogs/modules/setting.BuildGitHash=$(shell git rev-parse HEAD)" -DATA_FILES := $(shell find conf | sed 's/ /\\ /g') -LESS_FILES := $(wildcard public/less/gogs.less public/less/_*.less) -GENERATED := modules/bindata/bindata.go public/css/gogs.css +DATA_FILES ?= $(shell find conf | sed 's/ /\\ /g') +LESS_FILES ?= $(wildcard public/less/gogs.less public/less/_*.less) -TAGS = "" +GENERATED ?= modules/bindata/bindata.go public/css/gogs.css -RELEASE_ROOT = "release" -RELEASE_GOGS = "release/gogs" -NOW = $(shell date -u '+%Y%m%d%I%M%S') +TAGS ?= -.PHONY: build pack release bindata clean +DIST := dist +BIN := bin +FILES := templates public scripts LICENSE README.md README_ZH.md +RELEASES ?= $(DIST)/gogs-linux-amd64.tgz \ + $(DIST)/gogs-linux-386.tgz \ + $(DIST)/gogs-linux-arm.tgz \ + $(DIST)/gogs-darwin-amd64.tgz \ + $(DIST)/gogs-darwin-386.tgz \ + $(DIST)/gogs-darwin-arm.tgz \ + $(DIST)/gogs-freebsd-amd64.tgz \ + $(DIST)/gogs-freebsd-386.tgz \ + $(DIST)/gogs-freebsd-arm.tgz \ + $(DIST)/gogs-openbsd-amd64.tgz \ + $(DIST)/gogs-openbsd-386.tgz \ + $(DIST)/gogs-openbsd-arm.tgz \ + $(DIST)/gogs-windows-amd64.zip \ + $(DIST)/gogs-windows-386.zip + +.PHONY: clean test deps gofmt govet build install .IGNORE: public/css/gogs.css -build: $(GENERATED) - go install -v -ldflags '$(LDFLAGS)' -tags '$(TAGS)' - cp '$(GOPATH)/bin/gogs' . +clean: + go clean -i ./... + rm -rf $(BIN) $(DIST) + +test: + @echo "Tests are not integrated!" # go test -tags '$(TAGS)' -cover ./... + +deps: + go get -tags '$(TAGS)' -d -t ./... + +gofmt: + go fmt ./... govet: go tool vet -composites=false -methods=false -structtags=false . -pack: - rm -rf $(RELEASE_GOGS) - mkdir -p $(RELEASE_GOGS) - cp -r gogs LICENSE README.md README_ZH.md templates public scripts $(RELEASE_GOGS) - rm -rf $(RELEASE_GOGS)/public/config.codekit $(RELEASE_GOGS)/public/less - cd $(RELEASE_ROOT) && zip -r gogs.$(NOW).zip "gogs" +build: install + cp $(GOPATH)/bin/gogs . -release: build pack +install: + go install -ldflags '$(LDFLAGS)' -tags '$(TAGS)' bindata: modules/bindata/bindata.go @@ -41,8 +62,22 @@ less: public/css/gogs.css public/css/gogs.css: $(LESS_FILES) lessc $< $@ -clean: - go clean -i ./... +release: $(RELEASES) + +$(BIN)/%/gogs/gogs: GOOS=$(firstword $(subst -, ,$*)) +$(BIN)/%/gogs/gogs: GOARCH=$(subst .exe,,$(word 2,$(subst -, ,$*))) +$(BIN)/%/gogs/gogs: + GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -o $@ + cp -r $(FILES) $(BIN)/$*/gogs + +$(DIST)/gogs-%.tgz: GOOS=$(firstword $(subst -, ,$*)) +$(DIST)/gogs-%.tgz: GOARCH=$(subst .exe,,$(word 2,$(subst -, ,$*))) +$(DIST)/gogs-%.tgz: $(BIN)/%/gogs/gogs + mkdir -p $(DIST) + tar -czf $@ --directory=$(BIN)/$* gogs -clean-mac: clean - find . -name ".DS_Store" -print0 | xargs -0 rm +$(DIST)/gogs-%.zip: GOOS=$(firstword $(subst -, ,$*)) +$(DIST)/gogs-%.zip: GOARCH=$(subst .exe,,$(word 2,$(subst -, ,$*))) +$(DIST)/gogs-%.zip: $(BIN)/%/gogs/gogs + @mkdir -p $(DIST) + (cd $(BIN)/$* && zip -r - gogs) > $@