2021-06-22 12:34:35 +02:00
|
|
|
DOCKER_RUN_GO_VERSION=1.16
|
2019-09-14 14:11:40 +02:00
|
|
|
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
|
2021-06-22 12:34:35 +02:00
|
|
|
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
VERSION ?= next
|
|
|
|
ifneq ($(DRONE_TAG),)
|
|
|
|
VERSION := $(DRONE_TAG:v%=%)
|
2021-06-22 13:12:26 +02:00
|
|
|
endif
|
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
# append commit-sha to next version
|
|
|
|
BUILD_VERSION := $(VERSION)
|
|
|
|
ifeq ($(BUILD_VERSION),next)
|
|
|
|
BUILD_VERSION := $(shell echo "next-$(shell echo ${DRONE_COMMIT_SHA} | head -c 8)")
|
2021-06-22 13:12:26 +02:00
|
|
|
endif
|
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION}
|
2021-06-22 13:12:26 +02:00
|
|
|
|
2019-10-06 22:07:31 +02:00
|
|
|
DOCKER_RUN?=
|
|
|
|
_with-docker:
|
2021-06-22 12:34:35 +02:00
|
|
|
$(eval DOCKER_RUN=docker run --rm -v $(shell pwd):/go/src/ -v $(shell pwd)/build:/build -w /go/src golang:$(DOCKER_RUN_GO_VERSION))
|
2019-10-06 22:07:31 +02:00
|
|
|
|
2021-09-09 19:39:59 +02:00
|
|
|
all: build
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2021-08-30 19:14:04 +02:00
|
|
|
vendor:
|
|
|
|
go mod tidy
|
|
|
|
go mod vendor
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
formatcheck:
|
2021-06-22 12:34:35 +02:00
|
|
|
@([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1)
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
format:
|
|
|
|
@gofmt -w ${GOFILES_NOVENDOR}
|
|
|
|
|
2021-06-22 12:34:35 +02:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
go clean -i ./...
|
|
|
|
rm -rf build
|
|
|
|
|
|
|
|
.PHONY: vet
|
|
|
|
vet:
|
|
|
|
@echo "Running go vet..."
|
|
|
|
@go vet $(GO_PACKAGES)
|
|
|
|
|
2021-10-13 18:48:43 +02:00
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
@echo "Running zerolog linter"
|
|
|
|
go run vendor/github.com/rs/zerolog/cmd/lint/lint.go github.com/woodpecker-ci/woodpecker/cmd/agent
|
|
|
|
go run vendor/github.com/rs/zerolog/cmd/lint/lint.go github.com/woodpecker-ci/woodpecker/cmd/cli
|
|
|
|
go run vendor/github.com/rs/zerolog/cmd/lint/lint.go github.com/woodpecker-ci/woodpecker/cmd/server
|
|
|
|
|
2019-09-14 14:11:40 +02:00
|
|
|
test-agent:
|
2021-09-21 17:06:13 +02:00
|
|
|
$(DOCKER_RUN) go test -race -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/agent $(GO_PACKAGES)
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
test-server:
|
2021-09-21 17:06:13 +02:00
|
|
|
$(DOCKER_RUN) go test -race -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/server
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2019-11-12 15:27:39 +02:00
|
|
|
test-frontend:
|
2021-09-29 17:34:56 +02:00
|
|
|
(cd web/; yarn; yarn run test)
|
2019-11-12 15:27:39 +02:00
|
|
|
|
2019-09-14 14:11:40 +02:00
|
|
|
test-lib:
|
2019-10-08 12:09:31 +02:00
|
|
|
$(DOCKER_RUN) go test -race -timeout 30s $(shell go list ./... | grep -v '/cmd/')
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
test: test-lib test-agent test-server
|
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
build-frontend:
|
|
|
|
(cd web/; yarn; yarn build)
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
build-server: build-frontend
|
|
|
|
$(DOCKER_RUN) go build -o dist/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
build-agent:
|
|
|
|
$(DOCKER_RUN) go build -o dist/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
2019-11-12 15:27:39 +02:00
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
build-cli:
|
|
|
|
$(DOCKER_RUN) go build -o dist/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
build: build-agent build-server build-cli
|
|
|
|
|
|
|
|
release-frontend: build-frontend
|
2021-06-22 13:12:26 +02:00
|
|
|
|
|
|
|
release-server:
|
2021-10-04 19:50:21 +02:00
|
|
|
# compile
|
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -ldflags '${LDFLAGS}' -o dist/server/linux_amd64/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
|
|
|
|
# tar binary files
|
|
|
|
tar -cvzf dist/woodpecker-server_linux_amd64.tar.gz -C dist/server/linux_amd64 woodpecker-server
|
|
|
|
|
|
|
|
release-agent:
|
|
|
|
# compile
|
2021-10-12 09:50:56 +02:00
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/agent/linux_amd64/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
|
|
|
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/agent/linux_arm64/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
|
|
|
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/agent/linux_arm/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
|
|
|
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/agent/windows_amd64/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
|
|
|
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/agent/darwin_amd64/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
|
|
|
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/agent/darwin_arm64/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
2021-10-04 19:50:21 +02:00
|
|
|
# tar binary files
|
2021-10-12 09:50:56 +02:00
|
|
|
tar -cvzf dist/woodpecker-agent_linux_amd64.tar.gz -C dist/agent/linux_amd64 woodpecker-agent
|
|
|
|
tar -cvzf dist/woodpecker-agent_linux_arm64.tar.gz -C dist/agent/linux_arm64 woodpecker-agent
|
|
|
|
tar -cvzf dist/woodpecker-agent_linux_arm.tar.gz -C dist/agent/linux_arm woodpecker-agent
|
|
|
|
tar -cvzf dist/woodpecker-agent_windows_amd64.tar.gz -C dist/agent/windows_amd64 woodpecker-agent
|
|
|
|
tar -cvzf dist/woodpecker-agent_darwin_amd64.tar.gz -C dist/agent/darwin_amd64 woodpecker-agent
|
|
|
|
tar -cvzf dist/woodpecker-agent_darwin_arm64.tar.gz -C dist/agent/darwin_arm64 woodpecker-agent
|
2021-06-22 13:12:26 +02:00
|
|
|
|
2021-06-22 13:26:37 +02:00
|
|
|
release-cli:
|
2021-10-04 19:50:21 +02:00
|
|
|
# compile
|
2021-10-05 01:56:11 +02:00
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/cli/linux_amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
|
|
|
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/cli/linux_arm64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
|
|
|
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/cli/linux_arm/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
|
|
|
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/cli/windows_amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
|
|
|
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/cli/darwin_amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
|
|
|
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o dist/cli/darwin_arm64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
2021-10-04 19:50:21 +02:00
|
|
|
# tar binary files
|
|
|
|
tar -cvzf dist/woodpecker-cli_linux_amd64.tar.gz -C dist/cli/linux_amd64 woodpecker-cli
|
|
|
|
tar -cvzf dist/woodpecker-cli_linux_arm64.tar.gz -C dist/cli/linux_arm64 woodpecker-cli
|
|
|
|
tar -cvzf dist/woodpecker-cli_linux_arm.tar.gz -C dist/cli/linux_arm woodpecker-cli
|
|
|
|
tar -cvzf dist/woodpecker-cli_windows_amd64.tar.gz -C dist/cli/windows_amd64 woodpecker-cli
|
|
|
|
tar -cvzf dist/woodpecker-cli_darwin_amd64.tar.gz -C dist/cli/darwin_amd64 woodpecker-cli
|
|
|
|
tar -cvzf dist/woodpecker-cli_darwin_arm64.tar.gz -C dist/cli/darwin_arm64 woodpecker-cli
|
|
|
|
|
|
|
|
release-checksums:
|
2021-06-22 13:26:37 +02:00
|
|
|
# generate shas for tar files
|
2021-10-04 19:50:21 +02:00
|
|
|
(cd dist/; sha256sum *.{tar.gz,apk,deb,rpm} > checksums.txt)
|
|
|
|
|
|
|
|
release: release-frontend release-server release-agent release-cli
|
2021-06-22 13:26:37 +02:00
|
|
|
|
2021-10-04 19:50:21 +02:00
|
|
|
.PHONY: version
|
|
|
|
version:
|
|
|
|
@echo ${VERSION}
|