-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (47 loc) · 1.89 KB
/
Makefile
File metadata and controls
61 lines (47 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
GOPATH := $(shell go env GOPATH)
GOARCH ?= $(shell go env GOARCH)
GOOS ?= $(shell go env GOOS)
ifeq ($(GOOS),windows)
GO_DIST_NAME := gitea-pages.exe
else
GO_DIST_NAME := gitea-pages
endif
fmt:
@(test -f "$(GOPATH)/bin/gofumpt" || go install mvdan.cc/gofumpt@latest) && \
"$(GOPATH)/bin/gofumpt" -l -w .
.PHONY: release
release: dist/gitea-pages-$(GOOS)-$(GOARCH).tar.gz
dist/gitea-pages-$(GOOS)-$(GOARCH).tar.gz: $(shell find . -type f -name "*.go" ) go.mod go.sum
@echo Compile $@ via $(GO_DIST_NAME) && \
mkdir -p dist && \
rm -f dist/$(GO_DIST_NAME) && \
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o dist/$(GO_DIST_NAME) ./cmd/server && \
cd dist && \
tar zcf gitea-pages-$(GOOS)-$(GOARCH).tar.gz $(GO_DIST_NAME) ../LICENSE ../config.yaml ../cmd/server/errors.html.tmpl ../README.md ../README_*.md && \
rm -f $(GO_DIST_NAME)
gitea-pages: $(shell find . -type f -name "*.go" ) go.mod go.sum
@CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o $@ ./cmd/server
.PHONY: debug
debug: gitea-pages
@./gitea-pages -conf config-local.yaml -debug
.PHONY: test
test:
@go test -v -coverprofile=coverage.txt ./...
.PHONY: releases
releases:
@make release GOOS=linux GOARCH=amd64 && \
make release GOOS=linux GOARCH=arm64 && \
make release GOOS=linux GOARCH=loong64 && \
make release GOOS=windows GOARCH=amd64
.PHONY: lint
lint:
@(test -f "$(GOPATH)/bin/golangci-lint" || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0) && \
"$(GOPATH)/bin/golangci-lint" run -c .golangci.yml
.PHONY: lint-fix
lint-fix:
@(test -f "$(GOPATH)/bin/golangci-lint" || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0) && \
"$(GOPATH)/bin/golangci-lint" run -c .golangci.yml --fix
EXAMPLE_DIRS := $(shell find examples -maxdepth 1 -type d ! -path "examples" | sort)
.PHONY: $(EXAMPLE_DIRS)
$(EXAMPLE_DIRS):
@go run ./cmd/local/main.go -path $@