mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 11:51:16 -06:00
With this commit I have prepared a full basic project structure, so far it doesn't embed phoenix itself and also no kit parts. It includes the whole Drone pipeline to continously publish binaries on push and on tag to our download mirrors (will be available at https://download.owncloud.com/reva/phoenix) and also publishes Docker images at owncloud/reva-phonix. For the Docker image auto_tag is enabled, which means latest is always based on the master branch and tags are automatically converted to minor, major and patch release tags.
124 lines
3.1 KiB
Makefile
124 lines
3.1 KiB
Makefile
SHELL := bash
|
|
NAME := reva-hyper
|
|
IMPORT := github.com/owncloud/$(NAME)
|
|
BIN := bin
|
|
DIST := dist
|
|
|
|
ifeq ($(OS), Windows_NT)
|
|
EXECUTABLE := $(NAME).exe
|
|
HAS_GORUNPKG := $(shell where gorunpkg)
|
|
else
|
|
EXECUTABLE := $(NAME)
|
|
HAS_GORUNPKG := $(shell command -v gorunpkg)
|
|
endif
|
|
|
|
PACKAGES ?= $(shell go list ./...)
|
|
SOURCES ?= $(shell find . -name "*.go" -type f)
|
|
GENERATE ?= $(PACKAGES)
|
|
|
|
TAGS ?=
|
|
|
|
ifndef OUTPUT
|
|
ifneq ($(DRONE_TAG),)
|
|
OUTPUT ?= $(subst v,,$(DRONE_TAG))
|
|
else
|
|
OUTPUT ?= testing
|
|
endif
|
|
endif
|
|
|
|
ifndef VERSION
|
|
ifneq ($(DRONE_TAG),)
|
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
|
else
|
|
VERSION ?= $(shell git rev-parse --short HEAD)
|
|
endif
|
|
endif
|
|
|
|
ifndef DATE
|
|
DATE := $(shell date -u '+%Y%m%d')
|
|
endif
|
|
|
|
LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)"
|
|
|
|
.PHONY: all
|
|
all: build
|
|
|
|
.PHONY: sync
|
|
sync:
|
|
go mod download
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
go clean -i ./...
|
|
rm -rf $(BIN) $(DIST)
|
|
|
|
.PHONY: fmt
|
|
fmt:
|
|
gofmt -s -w $(SOURCES)
|
|
|
|
.PHONY: vet
|
|
vet:
|
|
go vet $(PACKAGES)
|
|
|
|
.PHONY: staticcheck
|
|
staticcheck: gorunpkg
|
|
gorunpkg honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES)
|
|
|
|
.PHONY: lint
|
|
lint: gorunpkg
|
|
for PKG in $(PACKAGES); do gorunpkg golang.org/x/lint/golint -set_exit_status $$PKG || exit 1; done;
|
|
|
|
.PHONY: generate
|
|
generate: gorunpkg
|
|
go generate $(GENERATE)
|
|
|
|
.PHONY: test
|
|
test: gorunpkg
|
|
gorunpkg github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
|
|
|
|
.PHONY: install
|
|
install: $(SOURCES)
|
|
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)
|
|
|
|
.PHONY: build
|
|
build: $(BIN)/$(EXECUTABLE)
|
|
|
|
$(BIN)/$(EXECUTABLE): $(SOURCES)
|
|
go build -i -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
|
|
|
|
.PHONY: release
|
|
release: release-dirs release-linux release-windows release-darwin release-copy release-check
|
|
|
|
.PHONY: release-dirs
|
|
release-dirs:
|
|
mkdir -p $(DIST)/binaries $(DIST)/release
|
|
|
|
.PHONY: release-linux
|
|
release-linux: gorunpkg release-dirs
|
|
gorunpkg github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME)
|
|
|
|
.PHONY: release-windows
|
|
release-windows: gorunpkg release-dirs
|
|
gorunpkg github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME)
|
|
|
|
.PHONY: release-darwin
|
|
release-darwin: gorunpkg release-dirs
|
|
gorunpkg github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME)
|
|
|
|
.PHONY: release-copy
|
|
release-copy:
|
|
$(foreach file,$(wildcard $(DIST)/binaries/$(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: release-finish
|
|
release-finish: release-copy release-check
|
|
|
|
.PHONY: gorunpkg
|
|
gorunpkg:
|
|
ifndef HAS_GORUNPKG
|
|
go get -u github.com/vektah/gorunpkg
|
|
endif
|