mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 09:27:56 +01:00
* 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: https://github.com/go-gitea/gitea/issues/10253
This commit is contained in:
parent
7284327a00
commit
e938f1d945
1
.gitignore
vendored
1
.gitignore
vendored
@ -69,6 +69,7 @@ coverage.all
|
|||||||
/yarn.lock
|
/yarn.lock
|
||||||
/public/js
|
/public/js
|
||||||
/public/css
|
/public/css
|
||||||
|
/VERSION
|
||||||
|
|
||||||
# Snapcraft
|
# Snapcraft
|
||||||
snap/.snapcraft/
|
snap/.snapcraft/
|
||||||
|
46
Makefile
46
Makefile
@ -29,6 +29,8 @@ EXTRA_GOFLAGS ?=
|
|||||||
|
|
||||||
MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
|
MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
|
||||||
|
|
||||||
|
STORED_VERSION_FILE := VERSION
|
||||||
|
|
||||||
ifneq ($(DRONE_TAG),)
|
ifneq ($(DRONE_TAG),)
|
||||||
VERSION ?= $(subst v,,$(DRONE_TAG))
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
||||||
GITEA_VERSION ?= $(VERSION)
|
GITEA_VERSION ?= $(VERSION)
|
||||||
@ -38,7 +40,13 @@ else
|
|||||||
else
|
else
|
||||||
VERSION ?= master
|
VERSION ?= master
|
||||||
endif
|
endif
|
||||||
GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
|
||||||
|
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
|
||||||
|
ifneq ($(STORED_VERSION),)
|
||||||
|
GITEA_VERSION ?= $(STORED_VERSION)
|
||||||
|
else
|
||||||
|
GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
|
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
|
||||||
@ -96,13 +104,15 @@ include docker/Makefile
|
|||||||
help:
|
help:
|
||||||
@echo "Make Routines:"
|
@echo "Make Routines:"
|
||||||
@echo " - \"\" equivalent to \"build\""
|
@echo " - \"\" equivalent to \"build\""
|
||||||
@echo " - build creates the entire project"
|
@echo " - build build everything"
|
||||||
@echo " - clean delete integration files and build files but not css and js files"
|
@echo " - frontend build frontend files"
|
||||||
@echo " - clean-all delete all generated files (integration test, build, css and js files)"
|
@echo " - backend build backend files"
|
||||||
|
@echo " - clean delete backend and integration files"
|
||||||
|
@echo " - clean-all delete backend, frontend and integration files"
|
||||||
@echo " - css rebuild only css files"
|
@echo " - css rebuild only css files"
|
||||||
@echo " - js rebuild only js files"
|
@echo " - js rebuild only js files"
|
||||||
@echo " - generate run \"make css js\" and \"go generate\""
|
@echo " - generate run \"go generate\""
|
||||||
@echo " - fmt format the code"
|
@echo " - fmt format the Go code"
|
||||||
@echo " - generate-swagger generate the swagger spec from code comments"
|
@echo " - generate-swagger generate the swagger spec from code comments"
|
||||||
@echo " - swagger-validate check if the swagger spec is valide"
|
@echo " - swagger-validate check if the swagger spec is valide"
|
||||||
@echo " - revive run code linter revive"
|
@echo " - revive run code linter revive"
|
||||||
@ -156,10 +166,6 @@ fmt:
|
|||||||
vet:
|
vet:
|
||||||
$(GO) vet $(PACKAGES)
|
$(GO) vet $(PACKAGES)
|
||||||
|
|
||||||
.PHONY: generate
|
|
||||||
generate: js css
|
|
||||||
GO111MODULE=on $(GO) generate -mod=vendor $(PACKAGES)
|
|
||||||
|
|
||||||
.PHONY: generate-swagger
|
.PHONY: generate-swagger
|
||||||
generate-swagger:
|
generate-swagger:
|
||||||
$(SWAGGER) generate spec -o './$(SWAGGER_SPEC)'
|
$(SWAGGER) generate spec -o './$(SWAGGER_SPEC)'
|
||||||
@ -414,13 +420,23 @@ install: $(wildcard *.go)
|
|||||||
$(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
|
$(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: go-check generate $(EXECUTABLE)
|
build: frontend backend
|
||||||
|
|
||||||
|
.PHONY: frontend
|
||||||
|
frontend: node-check js css
|
||||||
|
|
||||||
|
.PHONY: backend
|
||||||
|
backend: go-check generate $(EXECUTABLE)
|
||||||
|
|
||||||
|
.PHONY: generate
|
||||||
|
generate:
|
||||||
|
GO111MODULE=on $(GO) generate -mod=vendor $(PACKAGES)
|
||||||
|
|
||||||
$(EXECUTABLE): $(GO_SOURCES)
|
$(EXECUTABLE): $(GO_SOURCES)
|
||||||
GO111MODULE=on $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
|
GO111MODULE=on $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
|
||||||
|
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
release: generate release-dirs release-windows release-linux release-darwin release-copy release-compress release-sources release-check
|
release: frontend generate release-dirs release-windows release-linux release-darwin release-copy release-compress release-sources release-check
|
||||||
|
|
||||||
.PHONY: release-dirs
|
.PHONY: release-dirs
|
||||||
release-dirs:
|
release-dirs:
|
||||||
@ -472,8 +488,10 @@ release-compress:
|
|||||||
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
|
||||||
|
|
||||||
.PHONY: release-sources
|
.PHONY: release-sources
|
||||||
release-sources:
|
release-sources: | node_modules
|
||||||
tar cvzf $(DIST)/release/gitea-src-$(VERSION).tar.gz --exclude $(DIST) --exclude .git .
|
echo $(VERSION) > $(STORED_VERSION_FILE)
|
||||||
|
tar --exclude=./$(DIST) --exclude=./.git --exclude=./node_modules/.cache -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
|
||||||
|
rm -f $(STORED_VERSION_FILE)
|
||||||
|
|
||||||
node_modules: package-lock.json
|
node_modules: package-lock.json
|
||||||
npm install --no-save
|
npm install --no-save
|
||||||
|
@ -33,6 +33,15 @@ From the root of the source tree, run:
|
|||||||
|
|
||||||
TAGS="bindata" make build
|
TAGS="bindata" make build
|
||||||
|
|
||||||
|
The `build` target is split into two sub-targets:
|
||||||
|
|
||||||
|
- `make backend` which requires [Go 1.11](https://golang.org/dl/) or greater.
|
||||||
|
- `make frontend` which requires [Node.js 10.0.0](https://nodejs.org/en/download/) or greater.
|
||||||
|
|
||||||
|
If pre-built frontend files are present it is possible to only build the backend:
|
||||||
|
|
||||||
|
TAGS="bindata" make backend
|
||||||
|
|
||||||
More info: https://docs.gitea.io/en-us/install-from-source/
|
More info: https://docs.gitea.io/en-us/install-from-source/
|
||||||
|
|
||||||
## Using
|
## Using
|
||||||
|
@ -114,6 +114,17 @@ recommended way to build from source is therefore:
|
|||||||
TAGS="bindata sqlite sqlite_unlock_notify" make build
|
TAGS="bindata sqlite sqlite_unlock_notify" make build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `build` target is split into two sub-targets:
|
||||||
|
|
||||||
|
- `make backend` which requires [Go 1.11](https://golang.org/dl/) or greater.
|
||||||
|
- `make frontend` which requires [Node.js 10.0.0](https://nodejs.org/en/download/) or greater.
|
||||||
|
|
||||||
|
If pre-built frontend files are present it is possible to only build the backend:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
TAGS="bindata" make backend
|
||||||
|
``
|
||||||
|
|
||||||
## Test
|
## Test
|
||||||
|
|
||||||
After following the steps above, a `gitea` binary will be available in the working directory.
|
After following the steps above, a `gitea` binary will be available in the working directory.
|
||||||
|
Loading…
Reference in New Issue
Block a user