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 20KB

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