mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-28 04:08:25 +01:00
Totally refactored the makefile and adjusted travis config
This commit is contained in:
parent
7a870080d6
commit
ec054ba582
16
.travis.yml
16
.travis.yml
@ -4,17 +4,21 @@ go:
|
|||||||
- 1.6
|
- 1.6
|
||||||
- 1.7
|
- 1.7
|
||||||
|
|
||||||
|
env:
|
||||||
|
TAGS: cert sqlite pam miniwinsvc
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
- sudo apt-get install -y libpam-dev
|
- sudo apt-get install -y libpam-dev
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- go build -v -tags 'cert sqlite pam miniwinsvc'
|
- make clean
|
||||||
- |
|
- make vet
|
||||||
for pkg in $(go list ./... | grep -v /vendor/)
|
|
||||||
do
|
# - make lint
|
||||||
go test -v -race -cover -coverprofile $GOPATH/src/$pkg/coverage.out $pkg || exit 1
|
|
||||||
done
|
- make test
|
||||||
|
- make build
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
174
Makefile
174
Makefile
@ -1,74 +1,132 @@
|
|||||||
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
|
DIST := dist
|
||||||
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildGitHash=$(shell git rev-parse HEAD)"
|
BIN := bin
|
||||||
|
|
||||||
DATA_FILES := $(shell find conf | sed 's/ /\\ /g')
|
EXECUTABLE := gitea
|
||||||
LESS_FILES := $(wildcard public/less/gogs.less public/less/_*.less)
|
IMPORT := github.com/go-gitea/gitea
|
||||||
GENERATED := modules/bindata/bindata.go public/css/index.css
|
|
||||||
|
|
||||||
TAGS = ""
|
SHA := $(shell git rev-parse --short HEAD)
|
||||||
BUILD_FLAGS = "-v"
|
DATE := $(shell date -u '+%Y-%m-%d %I:%M:%S %Z')
|
||||||
|
|
||||||
RELEASE_ROOT = "release"
|
BINDATA := $(shell find conf | sed 's/ /\\ /g')
|
||||||
RELEASE_GOGS = "release/gogs"
|
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
|
||||||
NOW = $(shell date -u '+%Y%m%d%I%M%S')
|
JAVASCRIPTS :=
|
||||||
GOVET = go tool vet -composites=false -methods=false -structtags=false
|
|
||||||
|
|
||||||
.PHONY: build pack release bindata clean
|
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildTime=$(DATE)"
|
||||||
|
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildGitHash=$(SHA)"
|
||||||
|
|
||||||
.IGNORE: public/css/index.css
|
TARGETS ?= linux/*,darwin/*,windows/*
|
||||||
|
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
|
||||||
|
|
||||||
all: build
|
TAGS ?=
|
||||||
|
|
||||||
check: test
|
ifneq ($(TRAVIS_TAG),)
|
||||||
|
VERSION ?= $(TRAVIS_TAG)
|
||||||
|
else
|
||||||
|
ifneq ($(TRAVIS_BRANCH),)
|
||||||
|
VERSION ?= $(TRAVIS_BRANCH)
|
||||||
|
else
|
||||||
|
VERSION ?= master
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
dist: release
|
.PHONY: all
|
||||||
|
all: clean test build
|
||||||
govet:
|
|
||||||
$(GOVET) main.go
|
|
||||||
$(GOVET) models modules routers
|
|
||||||
|
|
||||||
build: $(GENERATED)
|
|
||||||
go install $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
|
|
||||||
cp '$(GOPATH)/bin/gogs' .
|
|
||||||
|
|
||||||
build-dev: $(GENERATED) govet
|
|
||||||
go install $(BUILD_FLAGS) -tags '$(TAGS)'
|
|
||||||
cp '$(GOPATH)/bin/gogs' .
|
|
||||||
|
|
||||||
build-dev-race: $(GENERATED) govet
|
|
||||||
go install $(BUILD_FLAGS) -race -tags '$(TAGS)'
|
|
||||||
cp '$(GOPATH)/bin/gogs' .
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
release: build pack
|
|
||||||
|
|
||||||
bindata: modules/bindata/bindata.go
|
|
||||||
|
|
||||||
modules/bindata/bindata.go: $(DATA_FILES)
|
|
||||||
go-bindata -o=$@ -ignore="\\.DS_Store|README.md|TRANSLATORS" -pkg=bindata conf/...
|
|
||||||
|
|
||||||
less: public/css/index.css
|
|
||||||
|
|
||||||
public/css/index.css: $(LESS_FILES)
|
|
||||||
lessc $< $@
|
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
go clean -i ./...
|
go clean -i ./...
|
||||||
|
rm -rf $(BIN) $(DIST)
|
||||||
|
|
||||||
clean-mac: clean
|
.PHONY: deps
|
||||||
find . -name ".DS_Store" -print0 | xargs -0 rm
|
deps:
|
||||||
|
@which go-bindata > /dev/null; if [ $$? -ne 0 ]; then \
|
||||||
|
go get -u github.com/jteeuwen/go-bindata/...; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
go fmt $(PACKAGES)
|
||||||
|
|
||||||
|
.PHONY: vet
|
||||||
|
vet:
|
||||||
|
go vet $(PACKAGES)
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint:
|
||||||
|
@which golint > /dev/null; if [ $$? -ne 0 ]; then \
|
||||||
|
go get -u github.com/golang/lint/golint; \
|
||||||
|
fi
|
||||||
|
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
go test -cover -race ./...
|
for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
|
||||||
|
|
||||||
fixme:
|
.PHONY: install
|
||||||
grep -rnw "FIXME" routers models modules
|
install: $(BIN)/$(EXECUTABLE)
|
||||||
|
cp $< $(GOPATH)/bin/
|
||||||
|
|
||||||
todo:
|
.PHONY: build
|
||||||
grep -rnw "TODO" routers models modules
|
build: $(BIN)/$(EXECUTABLE)
|
||||||
|
|
||||||
|
$(BIN)/$(EXECUTABLE): $(wildcard *.go)
|
||||||
|
go build -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: release-build release-copy release-check
|
||||||
|
|
||||||
|
.PHONY: release-build
|
||||||
|
release-build:
|
||||||
|
@which xgo > /dev/null; if [ $$? -ne 0 ]; then \
|
||||||
|
go get -u github.com/karalabe/xgo; \
|
||||||
|
fi
|
||||||
|
xgo -dest $(BIN) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets '$(TARGETS)' -out $(EXECUTABLE)-$(VERSION) $(IMPORT)
|
||||||
|
|
||||||
|
.PHONY: release-copy
|
||||||
|
release-copy:
|
||||||
|
mkdir -p $(DIST)/release
|
||||||
|
$(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
|
||||||
|
|
||||||
|
.PHONY: release-check
|
||||||
|
release-check:
|
||||||
|
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
|
||||||
|
|
||||||
|
.PHONY: latest
|
||||||
|
latest: release-build latest-copy latest-check
|
||||||
|
|
||||||
|
.PHONY: latest-copy
|
||||||
|
latest-copy:
|
||||||
|
mkdir -p $(DIST)/latest
|
||||||
|
$(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/latest/$(subst $(EXECUTABLE)-$(VERSION),$(EXECUTABLE)-latest,$(notdir $(file)));)
|
||||||
|
|
||||||
|
.PHONY: latest-check
|
||||||
|
latest-check:
|
||||||
|
cd $(DIST)/latest; $(foreach file,$(wildcard $(DIST)/latest/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
|
||||||
|
|
||||||
|
.PHONY: publish
|
||||||
|
publish: release latest
|
||||||
|
|
||||||
|
.PHONY: bindata
|
||||||
|
bindata: modules/bindata/bindata.go
|
||||||
|
|
||||||
|
.IGNORE: modules/bindata/bindata.go
|
||||||
|
modules/bindata/bindata.go: $(BINDATA)
|
||||||
|
go-bindata -o=$@ -ignore="\\.go|README.md|TRANSLATORS" -pkg=bindata conf/...
|
||||||
|
go fmt $@
|
||||||
|
|
||||||
|
.PHONY: javascripts
|
||||||
|
javascripts: public/js/index.js
|
||||||
|
|
||||||
|
.IGNORE: public/js/index.js
|
||||||
|
public/js/index.js: $(JAVASCRIPTS)
|
||||||
|
cat $< >| $@
|
||||||
|
|
||||||
|
.PHONY: stylesheets
|
||||||
|
stylesheets: public/css/index.css
|
||||||
|
|
||||||
|
.IGNORE: public/css/index.css
|
||||||
|
public/css/index.css: $(STYLESHEETS)
|
||||||
|
lessc $< $@
|
||||||
|
|
||||||
|
.PHONY: generate
|
||||||
|
generate: bindata javascripts stylesheets
|
||||||
|
Loading…
Reference in New Issue
Block a user