You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. DIST := dist
  2. IMPORT := code.gitea.io/gitea
  3. export GO111MODULE=off
  4. GO ?= go
  5. SED_INPLACE := sed -i
  6. SHASUM ?= shasum -a 256
  7. export PATH := $($(GO) env GOPATH)/bin:$(PATH)
  8. ifeq ($(OS), Windows_NT)
  9. EXECUTABLE ?= gitea.exe
  10. else
  11. EXECUTABLE ?= gitea
  12. UNAME_S := $(shell uname -s)
  13. ifeq ($(UNAME_S),Darwin)
  14. SED_INPLACE := sed -i ''
  15. endif
  16. ifeq ($(UNAME_S),FreeBSD)
  17. SED_INPLACE := sed -i ''
  18. endif
  19. endif
  20. GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
  21. GOFMT ?= gofmt -s
  22. GOFLAGS := -v
  23. EXTRA_GOFLAGS ?=
  24. MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
  25. ifneq ($(DRONE_TAG),)
  26. VERSION ?= $(subst v,,$(DRONE_TAG))
  27. GITEA_VERSION ?= $(VERSION)
  28. else
  29. ifneq ($(DRONE_BRANCH),)
  30. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  31. else
  32. VERSION ?= master
  33. endif
  34. GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
  35. endif
  36. LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
  37. PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell GO111MODULE=on $(GO) list -mod=vendor ./... | grep -v /vendor/)))
  38. GO_SOURCES ?= $(shell find . -name "*.go" -type f)
  39. JS_SOURCES ?= $(shell find web_src/js web_src/css -type f)
  40. CSS_SOURCES ?= $(shell find web_src/less -type f)
  41. JS_DEST := public/js/index.js
  42. CSS_DEST := public/css/index.css
  43. BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
  44. JS_DEST_DIR := public/js
  45. CSS_DEST_DIR := public/css
  46. FOMANTIC_DEST_DIR := public/fomantic
  47. TAGS ?=
  48. TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp')
  49. #To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger@v0.20.1
  50. SWAGGER := GO111MODULE=on $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
  51. SWAGGER_SPEC := templates/swagger/v1_json.tmpl
  52. SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
  53. SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
  54. SWAGGER_NEWLINE_COMMAND := -e '$$a\'
  55. TEST_MYSQL_HOST ?= mysql:3306
  56. TEST_MYSQL_DBNAME ?= testgitea
  57. TEST_MYSQL_USERNAME ?= root
  58. TEST_MYSQL_PASSWORD ?=
  59. TEST_MYSQL8_HOST ?= mysql8:3306
  60. TEST_MYSQL8_DBNAME ?= testgitea
  61. TEST_MYSQL8_USERNAME ?= root
  62. TEST_MYSQL8_PASSWORD ?=
  63. TEST_PGSQL_HOST ?= pgsql:5432
  64. TEST_PGSQL_DBNAME ?= testgitea
  65. TEST_PGSQL_USERNAME ?= postgres
  66. TEST_PGSQL_PASSWORD ?= postgres
  67. TEST_PGSQL_SCHEMA ?= gtestschema
  68. TEST_MSSQL_HOST ?= mssql:1433
  69. TEST_MSSQL_DBNAME ?= gitea
  70. TEST_MSSQL_USERNAME ?= sa
  71. TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
  72. # $(call strip-suffix,filename)
  73. strip-suffix = $(firstword $(subst ., ,$(1)))
  74. .PHONY: all
  75. all: build
  76. include docker/Makefile
  77. .PHONY: help
  78. help:
  79. @echo "Make Routines:"
  80. @echo " - \"\" equivalent to \"build\""
  81. @echo " - build creates the entire project"
  82. @echo " - clean delete integration files and build files but not css and js files"
  83. @echo " - clean-all delete all generated files (integration test, build, css and js files)"
  84. @echo " - css rebuild only css files"
  85. @echo " - js rebuild only js files"
  86. @echo " - fomantic rebuild fomantic-ui files"
  87. @echo " - generate run \"make fomantic css js\" and \"go generate\""
  88. @echo " - fmt format the code"
  89. @echo " - generate-swagger generate the swagger spec from code comments"
  90. @echo " - swagger-validate check if the swagger spec is valid"
  91. @echo " - revive run code linter revive"
  92. @echo " - misspell check if a word is written wrong"
  93. @echo " - vet examines Go source code and reports suspicious constructs"
  94. @echo " - test run unit test"
  95. @echo " - test-sqlite run integration test for sqlite"
  96. .PHONY: go-check
  97. go-check:
  98. $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell go version | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ');))
  99. @if [ "$(GO_VERSION)" -lt "001011000" ]; then \
  100. echo "Gitea requires Go 1.11.0 or greater to build. You can get it at https://golang.org/dl/"; \
  101. exit 1; \
  102. fi
  103. .PHONY: git-check
  104. git-check:
  105. @if git lfs >/dev/null 2>&1 ; then : ; else \
  106. echo "Gitea requires git with lfs support to run tests." ; \
  107. exit 1; \
  108. fi
  109. .PHONY: node-check
  110. node-check:
  111. $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?' | tr '.' ' ');))
  112. $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1))
  113. @if [ "$(NODE_VERSION)" -lt "010000000" -o "$(NPM_MISSING)" = "1" ]; then \
  114. echo "Gitea requires Node.js 10.0.0 or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
  115. exit 1; \
  116. fi
  117. .PHONY: clean-all
  118. clean-all: clean
  119. rm -rf $(JS_DEST_DIR) $(CSS_DEST_DIR) $(FOMANTIC_DEST_DIR)
  120. .PHONY: clean
  121. clean:
  122. $(GO) clean -i ./...
  123. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) \
  124. integrations*.test \
  125. integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-mysql8/ integrations/gitea-integration-sqlite/ \
  126. integrations/gitea-integration-mssql/ integrations/indexers-mysql/ integrations/indexers-mysql8/ integrations/indexers-pgsql integrations/indexers-sqlite \
  127. integrations/indexers-mssql integrations/mysql.ini integrations/mysql8.ini integrations/pgsql.ini integrations/mssql.ini
  128. .PHONY: fmt
  129. fmt:
  130. $(GOFMT) -w $(GOFILES)
  131. .PHONY: vet
  132. vet:
  133. $(GO) vet $(PACKAGES)
  134. .PHONY: generate
  135. generate: fomantic js css
  136. GO111MODULE=on $(GO) generate -mod=vendor $(PACKAGES)
  137. .PHONY: generate-swagger
  138. generate-swagger:
  139. $(SWAGGER) generate spec -o './$(SWAGGER_SPEC)'
  140. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  141. $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
  142. .PHONY: swagger-check
  143. swagger-check: generate-swagger
  144. @diff=$$(git diff '$(SWAGGER_SPEC)'); \
  145. if [ -n "$$diff" ]; then \
  146. echo "Please run 'make generate-swagger' and commit the result:"; \
  147. echo "$${diff}"; \
  148. exit 1; \
  149. fi;
  150. .PHONY: swagger-validate
  151. swagger-validate:
  152. $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
  153. $(SWAGGER) validate './$(SWAGGER_SPEC)'
  154. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  155. .PHONY: errcheck
  156. errcheck:
  157. @hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  158. $(GO) get -u github.com/kisielk/errcheck; \
  159. fi
  160. errcheck $(PACKAGES)
  161. .PHONY: revive
  162. revive:
  163. @hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  164. $(GO) get -u github.com/mgechev/revive; \
  165. fi
  166. revive -config .revive.toml -exclude=./vendor/... ./... || exit 1
  167. .PHONY: misspell-check
  168. misspell-check:
  169. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  170. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  171. fi
  172. misspell -error -i unknwon,destory $(GOFILES)
  173. .PHONY: misspell
  174. misspell:
  175. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  176. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  177. fi
  178. misspell -w -i unknwon $(GOFILES)
  179. .PHONY: fmt-check
  180. fmt-check:
  181. # get all go files and run go fmt on them
  182. @diff=$$($(GOFMT) -d $(GOFILES)); \
  183. if [ -n "$$diff" ]; then \
  184. echo "Please run 'make fmt' and commit the result:"; \
  185. echo "$${diff}"; \
  186. exit 1; \
  187. fi;
  188. .PHONY: test
  189. test:
  190. GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
  191. .PHONY: test\#%
  192. test\#%:
  193. GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(PACKAGES)
  194. .PHONY: coverage
  195. coverage:
  196. @hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  197. $(GO) get -u github.com/wadey/gocovmerge; \
  198. fi
  199. gocovmerge integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all;\
  200. .PHONY: unit-test-coverage
  201. unit-test-coverage:
  202. GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
  203. .PHONY: vendor
  204. vendor:
  205. GO111MODULE=on $(GO) mod tidy && GO111MODULE=on $(GO) mod vendor
  206. .PHONY: test-vendor
  207. test-vendor: vendor
  208. @diff=$$(git diff vendor/); \
  209. if [ -n "$$diff" ]; then \
  210. echo "Please run 'make vendor' and commit the result:"; \
  211. echo "$${diff}"; \
  212. exit 1; \
  213. fi;
  214. .PHONY: test-sqlite
  215. test-sqlite: integrations.sqlite.test
  216. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
  217. .PHONY: test-sqlite\#%
  218. test-sqlite\#%: integrations.sqlite.test
  219. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.run $*
  220. .PHONY: test-sqlite-migration
  221. test-sqlite-migration: migrations.sqlite.test
  222. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./migrations.sqlite.test
  223. generate-ini-mysql:
  224. sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
  225. -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
  226. -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
  227. -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
  228. integrations/mysql.ini.tmpl > integrations/mysql.ini
  229. .PHONY: test-mysql
  230. test-mysql: integrations.mysql.test generate-ini-mysql
  231. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test
  232. .PHONY: test-mysql\#%
  233. test-mysql\#%: integrations.mysql.test generate-ini-mysql
  234. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.run $*
  235. .PHONY: test-mysql-migration
  236. test-mysql-migration: migrations.mysql.test generate-ini-mysql
  237. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./migrations.mysql.test
  238. generate-ini-mysql8:
  239. sed -e 's|{{TEST_MYSQL8_HOST}}|${TEST_MYSQL8_HOST}|g' \
  240. -e 's|{{TEST_MYSQL8_DBNAME}}|${TEST_MYSQL8_DBNAME}|g' \
  241. -e 's|{{TEST_MYSQL8_USERNAME}}|${TEST_MYSQL8_USERNAME}|g' \
  242. -e 's|{{TEST_MYSQL8_PASSWORD}}|${TEST_MYSQL8_PASSWORD}|g' \
  243. integrations/mysql8.ini.tmpl > integrations/mysql8.ini
  244. .PHONY: test-mysql8
  245. test-mysql8: integrations.mysql8.test generate-ini-mysql8
  246. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test
  247. .PHONY: test-mysql8\#%
  248. test-mysql8\#%: integrations.mysql8.test generate-ini-mysql8
  249. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test -test.run $*
  250. .PHONY: test-mysql8-migration
  251. test-mysql8-migration: migrations.mysql8.test generate-ini-mysql8
  252. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./migrations.mysql8.test
  253. generate-ini-pgsql:
  254. sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
  255. -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
  256. -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
  257. -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
  258. -e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
  259. integrations/pgsql.ini.tmpl > integrations/pgsql.ini
  260. .PHONY: test-pgsql
  261. test-pgsql: integrations.pgsql.test generate-ini-pgsql
  262. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test
  263. .PHONY: test-pgsql\#%
  264. test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
  265. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.run $*
  266. .PHONY: test-pgsql-migration
  267. test-pgsql-migration: migrations.pgsql.test generate-ini-pgsql
  268. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./migrations.pgsql.test
  269. generate-ini-mssql:
  270. sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
  271. -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
  272. -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
  273. -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
  274. integrations/mssql.ini.tmpl > integrations/mssql.ini
  275. .PHONY: test-mssql
  276. test-mssql: integrations.mssql.test generate-ini-mssql
  277. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test
  278. .PHONY: test-mssql\#%
  279. test-mssql\#%: integrations.mssql.test generate-ini-mssql
  280. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.run $*
  281. .PHONY: test-mssql-migration
  282. test-mssql-migration: migrations.mssql.test generate-ini-mssql
  283. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./migrations.mssql.test
  284. .PHONY: bench-sqlite
  285. bench-sqlite: integrations.sqlite.test
  286. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  287. .PHONY: bench-mysql
  288. bench-mysql: integrations.mysql.test generate-ini-mysql
  289. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  290. .PHONY: bench-mssql
  291. bench-mssql: integrations.mssql.test generate-ini-mssql
  292. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  293. .PHONY: bench-pgsql
  294. bench-pgsql: integrations.pgsql.test generate-ini-pgsql
  295. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  296. .PHONY: integration-test-coverage
  297. integration-test-coverage: integrations.cover.test generate-ini-mysql
  298. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
  299. integrations.mysql.test: git-check $(GO_SOURCES)
  300. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
  301. integrations.mysql8.test: git-check $(GO_SOURCES)
  302. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
  303. integrations.pgsql.test: git-check $(GO_SOURCES)
  304. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
  305. integrations.mssql.test: git-check $(GO_SOURCES)
  306. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
  307. integrations.sqlite.test: git-check $(GO_SOURCES)
  308. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
  309. integrations.cover.test: git-check $(GO_SOURCES)
  310. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test
  311. .PHONY: migrations.mysql.test
  312. migrations.mysql.test: $(GO_SOURCES)
  313. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test
  314. .PHONY: migrations.mysql8.test
  315. migrations.mysql8.test: $(GO_SOURCES)
  316. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test
  317. .PHONY: migrations.pgsql.test
  318. migrations.pgsql.test: $(GO_SOURCES)
  319. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test
  320. .PHONY: migrations.mssql.test
  321. migrations.mssql.test: $(GO_SOURCES)
  322. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test
  323. .PHONY: migrations.sqlite.test
  324. migrations.sqlite.test: $(GO_SOURCES)
  325. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
  326. .PHONY: check
  327. check: test
  328. .PHONY: install
  329. install: $(wildcard *.go)
  330. $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  331. .PHONY: build
  332. build: go-check generate $(EXECUTABLE)
  333. $(EXECUTABLE): $(GO_SOURCES)
  334. GO111MODULE=on $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  335. .PHONY: release
  336. release: generate release-dirs release-windows release-linux release-darwin release-copy release-compress release-check
  337. .PHONY: release-dirs
  338. release-dirs:
  339. mkdir -p $(DIST)/binaries $(DIST)/release
  340. .PHONY: release-windows
  341. release-windows:
  342. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  343. $(GO) get -u src.techknowlogick.com/xgo; \
  344. fi
  345. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  346. ifeq ($(CI),drone)
  347. cp /build/* $(DIST)/binaries
  348. endif
  349. .PHONY: release-linux
  350. release-linux:
  351. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  352. $(GO) get -u src.techknowlogick.com/xgo; \
  353. fi
  354. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -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 gitea-$(VERSION) .
  355. ifeq ($(CI),drone)
  356. cp /build/* $(DIST)/binaries
  357. endif
  358. .PHONY: release-darwin
  359. release-darwin:
  360. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  361. $(GO) get -u src.techknowlogick.com/xgo; \
  362. fi
  363. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
  364. ifeq ($(CI),drone)
  365. cp /build/* $(DIST)/binaries
  366. endif
  367. .PHONY: release-copy
  368. release-copy:
  369. cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done;
  370. .PHONY: release-check
  371. release-check:
  372. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
  373. .PHONY: release-compress
  374. release-compress:
  375. @hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  376. $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
  377. fi
  378. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
  379. node_modules: package-lock.json
  380. npm install --no-save
  381. .PHONY: npm-update
  382. npm-update: node-check | node_modules
  383. npx updates -cu
  384. rm -rf node_modules package-lock.json
  385. npm install --package-lock
  386. .PHONY: js
  387. js: node-check $(JS_DEST)
  388. $(JS_DEST): $(JS_SOURCES) | node_modules
  389. npx eslint web_src/js webpack.config.js
  390. npx webpack --hide-modules --display-entrypoints=false
  391. .PHONY: fomantic
  392. fomantic: node-check $(FOMANTIC_DEST_DIR)
  393. $(FOMANTIC_DEST_DIR): semantic.json web_src/fomantic/theme.config.less | node_modules
  394. cp web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config
  395. cp web_src/fomantic/_site/globals/* node_modules/fomantic-ui/src/_site/globals/
  396. npx gulp -f node_modules/fomantic-ui/gulpfile.js build
  397. .PHONY: css
  398. css: node-check $(CSS_DEST)
  399. $(CSS_DEST): $(CSS_SOURCES) | node_modules
  400. npx stylelint web_src/less
  401. npx lessc web_src/less/index.less public/css/index.css
  402. $(foreach file, $(filter-out web_src/less/themes/_base.less, $(wildcard web_src/less/themes/*)),npx lessc web_src/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
  403. npx postcss --use autoprefixer --use cssnano --no-map --replace public/css/*
  404. .PHONY: update-translations
  405. update-translations:
  406. mkdir -p ./translations
  407. cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
  408. rm ./translations/gitea.zip
  409. $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
  410. $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
  411. mv ./translations/*.ini ./options/locale/
  412. rmdir ./translations
  413. .PHONY: generate-images
  414. generate-images:
  415. mkdir -p $(TMPDIR)/images
  416. inkscape -f $(PWD)/assets/logo.svg -w 880 -h 880 -e $(PWD)/public/img/gitea-lg.png
  417. inkscape -f $(PWD)/assets/logo.svg -w 512 -h 512 -e $(PWD)/public/img/gitea-512.png
  418. inkscape -f $(PWD)/assets/logo.svg -w 192 -h 192 -e $(PWD)/public/img/gitea-192.png
  419. inkscape -f $(PWD)/assets/logo.svg -w 120 -h 120 -jC -i layer1 -e $(TMPDIR)/images/sm-1.png
  420. inkscape -f $(PWD)/assets/logo.svg -w 120 -h 120 -jC -i layer2 -e $(TMPDIR)/images/sm-2.png
  421. composite -compose atop $(TMPDIR)/images/sm-2.png $(TMPDIR)/images/sm-1.png $(PWD)/public/img/gitea-sm.png
  422. inkscape -f $(PWD)/assets/logo.svg -w 200 -h 200 -e $(PWD)/public/img/avatar_default.png
  423. inkscape -f $(PWD)/assets/logo.svg -w 180 -h 180 -e $(PWD)/public/img/favicon.png
  424. inkscape -f $(PWD)/assets/logo.svg -w 128 -h 128 -e $(TMPDIR)/images/128-raw.png
  425. inkscape -f $(PWD)/assets/logo.svg -w 64 -h 64 -e $(TMPDIR)/images/64-raw.png
  426. inkscape -f $(PWD)/assets/logo.svg -w 32 -h 32 -jC -i layer1 -e $(TMPDIR)/images/32-1.png
  427. inkscape -f $(PWD)/assets/logo.svg -w 32 -h 32 -jC -i layer2 -e $(TMPDIR)/images/32-2.png
  428. composite -compose atop $(TMPDIR)/images/32-2.png $(TMPDIR)/images/32-1.png $(TMPDIR)/images/32-raw.png
  429. inkscape -f $(PWD)/assets/logo.svg -w 16 -h 16 -jC -i layer1 -e $(TMPDIR)/images/16-raw.png
  430. zopflipng -m -y $(TMPDIR)/images/128-raw.png $(TMPDIR)/images/128.png
  431. zopflipng -m -y $(TMPDIR)/images/64-raw.png $(TMPDIR)/images/64.png
  432. zopflipng -m -y $(TMPDIR)/images/32-raw.png $(TMPDIR)/images/32.png
  433. zopflipng -m -y $(TMPDIR)/images/16-raw.png $(TMPDIR)/images/16.png
  434. rm -f $(TMPDIR)/images/*-*.png
  435. convert $(TMPDIR)/images/16.png $(TMPDIR)/images/32.png \
  436. $(TMPDIR)/images/64.png $(TMPDIR)/images/128.png \
  437. $(PWD)/public/img/favicon.ico
  438. rm -rf $(TMPDIR)/images
  439. $(foreach file, $(shell find public/img -type f -name '*.png'),zopflipng -m -y $(file) $(file);)
  440. .PHONY: pr
  441. pr:
  442. $(GO) run contrib/pr/checkout.go $(PR)
  443. .PHONY: golangci-lint
  444. golangci-lint:
  445. @hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  446. export BINARY="golangci-lint"; \
  447. curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.20.0; \
  448. fi
  449. golangci-lint run --timeout 5m