Skip to content

Commit 88aa54c

Browse files
committed
Add frontend/backend make targets, fix source release (#10325)
* Add frontend/backend make targets, fix source release - Add 'make backend' and 'make frontend' make targets which are used to build go and js/css/svg files respectively. - The 'backend' target can be invoked without requiring Node.js to be present on the system if pre-built frontend assets are present like in the release source tarballs. - Fix source releases missing 'dist' folders inside 'node_modules' which were erronously excluded from tar. - Store VERSION in file VERSION for the release tarballs and prefer that file over git-derived version. * fix release task * fix typo * fix another typo Fixes: #10253
1 parent 7284327 commit 88aa54c

File tree

4 files changed

+53
-14
lines changed

4 files changed

+53
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ coverage.all
6969
/yarn.lock
7070
/public/js
7171
/public/css
72+
/VERSION
7273

7374
# Snapcraft
7475
snap/.snapcraft/

Makefile

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ EXTRA_GOFLAGS ?=
2929

3030
MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
3131

32+
STORED_VERSION_FILE := VERSION
33+
3234
ifneq ($(DRONE_TAG),)
3335
VERSION ?= $(subst v,,$(DRONE_TAG))
3436
GITEA_VERSION ?= $(VERSION)
@@ -38,7 +40,13 @@ else
3840
else
3941
VERSION ?= master
4042
endif
41-
GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
43+
44+
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
45+
ifneq ($(STORED_VERSION),)
46+
GITEA_VERSION ?= $(STORED_VERSION)
47+
else
48+
GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
49+
endif
4250
endif
4351

4452
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
@@ -96,13 +104,15 @@ include docker/Makefile
96104
help:
97105
@echo "Make Routines:"
98106
@echo " - \"\" equivalent to \"build\""
99-
@echo " - build creates the entire project"
100-
@echo " - clean delete integration files and build files but not css and js files"
101-
@echo " - clean-all delete all generated files (integration test, build, css and js files)"
107+
@echo " - build build everything"
108+
@echo " - frontend build frontend files"
109+
@echo " - backend build backend files"
110+
@echo " - clean delete backend and integration files"
111+
@echo " - clean-all delete backend, frontend and integration files"
102112
@echo " - css rebuild only css files"
103113
@echo " - js rebuild only js files"
104-
@echo " - generate run \"make css js\" and \"go generate\""
105-
@echo " - fmt format the code"
114+
@echo " - generate run \"go generate\""
115+
@echo " - fmt format the Go code"
106116
@echo " - generate-swagger generate the swagger spec from code comments"
107117
@echo " - swagger-validate check if the swagger spec is valide"
108118
@echo " - revive run code linter revive"
@@ -156,10 +166,6 @@ fmt:
156166
vet:
157167
$(GO) vet $(PACKAGES)
158168

159-
.PHONY: generate
160-
generate: js css
161-
GO111MODULE=on $(GO) generate -mod=vendor $(PACKAGES)
162-
163169
.PHONY: generate-swagger
164170
generate-swagger:
165171
$(SWAGGER) generate spec -o './$(SWAGGER_SPEC)'
@@ -414,13 +420,23 @@ install: $(wildcard *.go)
414420
$(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
415421

416422
.PHONY: build
417-
build: go-check generate $(EXECUTABLE)
423+
build: frontend backend
424+
425+
.PHONY: frontend
426+
frontend: node-check js css
427+
428+
.PHONY: backend
429+
backend: go-check generate $(EXECUTABLE)
430+
431+
.PHONY: generate
432+
generate:
433+
GO111MODULE=on $(GO) generate -mod=vendor $(PACKAGES)
418434

419435
$(EXECUTABLE): $(GO_SOURCES)
420436
GO111MODULE=on $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
421437

422438
.PHONY: release
423-
release: generate release-dirs release-windows release-linux release-darwin release-copy release-compress release-sources release-check
439+
release: frontend generate release-dirs release-windows release-linux release-darwin release-copy release-compress release-sources release-check
424440

425441
.PHONY: release-dirs
426442
release-dirs:
@@ -472,8 +488,10 @@ release-compress:
472488
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
473489

474490
.PHONY: release-sources
475-
release-sources:
476-
tar cvzf $(DIST)/release/gitea-src-$(VERSION).tar.gz --exclude $(DIST) --exclude .git .
491+
release-sources: | node_modules
492+
echo $(VERSION) > $(STORED_VERSION_FILE)
493+
tar --exclude=./$(DIST) --exclude=./.git --exclude=./node_modules/.cache -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
494+
rm -f $(STORED_VERSION_FILE)
477495

478496
node_modules: package-lock.json
479497
npm install --no-save

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ From the root of the source tree, run:
3333

3434
TAGS="bindata" make build
3535

36+
The `build` target is split into two sub-targets:
37+
38+
- `make backend` which requires [Go 1.11](https://golang.org/dl/) or greater.
39+
- `make frontend` which requires [Node.js 10.0.0](https://nodejs.org/en/download/) or greater.
40+
41+
If pre-built frontend files are present it is possible to only build the backend:
42+
43+
TAGS="bindata" make backend
44+
3645
More info: https://docs.gitea.io/en-us/install-from-source/
3746

3847
## Using

docs/content/doc/installation/from-source.en-us.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ recommended way to build from source is therefore:
114114
TAGS="bindata sqlite sqlite_unlock_notify" make build
115115
```
116116

117+
The `build` target is split into two sub-targets:
118+
119+
- `make backend` which requires [Go 1.11](https://golang.org/dl/) or greater.
120+
- `make frontend` which requires [Node.js 10.0.0](https://nodejs.org/en/download/) or greater.
121+
122+
If pre-built frontend files are present it is possible to only build the backend:
123+
124+
```bash
125+
TAGS="bindata" make backend
126+
``
127+
117128
## Test
118129

119130
After following the steps above, a `gitea` binary will be available in the working directory.

0 commit comments

Comments
 (0)