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.

520 lines
19 KiB

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