2021-06-22 12:34:35 +02:00
GO_PACKAGES ?= $( shell go list ./... | grep -v /vendor/)
2019-09-14 14:11:40 +02:00
2023-08-24 00:24:16 +02:00
TARGETOS ?= $( shell go env GOOS)
TARGETARCH ?= $( shell go env GOARCH)
2021-12-21 03:35:48 +02:00
2023-07-18 18:46:27 +02:00
BIN_SUFFIX :=
i f e q ( $( TARGETOS ) , w i n d o w s )
BIN_SUFFIX := .exe
e n d i f
2024-06-24 08:29:47 +02:00
DIST_DIR ?= dist
2021-10-04 19:50:21 +02:00
VERSION ?= next
2022-02-24 16:35:11 +02:00
VERSION_NUMBER ?= 0.0.0
2023-08-16 23:58:51 +02:00
CI_COMMIT_SHA ?= $( shell git rev-parse HEAD)
# it's a tagged release
2021-11-25 21:43:31 +02:00
i f n e q ( $( CI_COMMIT_TAG ) , )
2023-08-23 06:53:40 +02:00
VERSION := $( CI_COMMIT_TAG:v%= %)
2023-08-17 14:20:06 +02:00
VERSION_NUMBER := ${ CI_COMMIT_TAG : v %=% }
2023-08-16 23:58:51 +02:00
e l s e
# append commit-sha to next version
ifeq ( $( VERSION) ,next)
2023-08-23 06:53:40 +02:00
VERSION := $( shell echo " next- $( shell echo ${ CI_COMMIT_SHA } | cut -c -10) " )
2023-08-16 23:58:51 +02:00
endif
# append commit-sha to release branch version
ifeq ( $( shell echo ${ CI_COMMIT_BRANCH } | cut -c -9) ,release/v)
2023-08-23 06:53:40 +02:00
VERSION := $( shell echo " $( shell echo ${ CI_COMMIT_BRANCH } | cut -c 10-) - $( shell echo ${ CI_COMMIT_SHA } | cut -c -10) " )
2023-08-16 23:58:51 +02:00
endif
2021-06-22 13:12:26 +02:00
e n d i f
2024-06-25 12:23:07 +02:00
TAGS ?=
2024-12-22 11:44:34 +02:00
LDFLAGS := -X go.woodpecker-ci.org/woodpecker/v3/version.Version= ${ VERSION }
2023-12-27 14:01:56 +02:00
STATIC_BUILD ?= true
i f e q ( $( STATIC_BUILD ) , t r u e )
LDFLAGS := -s -w -extldflags "-static" $( LDFLAGS)
e n d i f
2022-11-23 00:39:49 +02:00
CGO_ENABLED ?= 1 # only used to compile server
2022-03-01 17:40:24 +02:00
HAS_GO = $( shell hash go > /dev/null 2>& 1 && echo "GO" || echo "NOGO" )
2022-11-23 00:39:49 +02:00
i f e q ( $( HAS_GO ) , G O )
2024-10-30 15:21:50 +02:00
# renovate: datasource=docker depName=docker.io/techknowlogick/xgo
2024-11-17 08:25:32 +02:00
XGO_VERSION ?= go-1.23.x
2022-11-23 00:39:49 +02:00
CGO_CFLAGS ?= $( shell go env CGO_CFLAGS)
2022-03-01 17:40:24 +02:00
e n d i f
2022-11-23 00:39:49 +02:00
CGO_CFLAGS ?=
2021-06-22 13:12:26 +02:00
2022-02-10 16:12:47 +02:00
# If the first argument is "in_docker"...
i f e q ( i n _ d o c k e r , $( firstword $ ( MAKECMDGOALS ) ) )
# use the rest as arguments for "in_docker"
MAKE_ARGS := $( wordlist 2,$( words $( MAKECMDGOALS) ) ,$( MAKECMDGOALS) )
# Ignore the next args
$( eval $( MAKE_ARGS) :; @:)
in_docker:
2023-06-06 18:29:40 +02:00
@[ "1" -eq " $( shell docker image ls woodpecker/make:local -a | wc -l) " ] && docker buildx build -f ./docker/Dockerfile.make -t woodpecker/make:local --load . || echo reuse existing docker image
2022-02-10 16:12:47 +02:00
@echo run in docker:
@docker run -it \
--user $( shell id -u) :$( shell id -g) \
-e VERSION = " $( VERSION) " \
-e CI_COMMIT_SHA = " $( CI_COMMIT_SHA) " \
-e TARGETOS = " $( TARGETOS) " \
-e TARGETARCH = " $( TARGETARCH) " \
2023-06-06 18:29:40 +02:00
-e CGO_ENABLED = " $( CGO_ENABLED) " \
2022-02-10 16:12:47 +02:00
-v $( PWD) :/build --rm woodpecker/make:local make $( MAKE_ARGS)
e l s e
# Proceed with normal make
2022-09-28 17:28:23 +02:00
##@ General
2023-10-31 10:14:09 +02:00
.PHONY : all
2022-09-28 17:28:23 +02:00
all : help
.PHONY : version
version : ## Print the current version
2023-08-23 06:53:40 +02:00
@echo ${ VERSION }
2022-09-28 17:28:23 +02:00
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY : help
help : ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $( MAKEFILE_LIST)
2019-09-14 14:11:40 +02:00
2022-08-30 00:36:37 +02:00
.PHONY : vendor
2022-09-28 17:28:23 +02:00
vendor : ## Update the vendor directory
2021-08-30 19:14:04 +02:00
go mod tidy
go mod vendor
2019-09-14 14:11:40 +02:00
2022-09-28 17:28:23 +02:00
format : install -tools ## Format source code
2023-03-19 23:56:16 +02:00
@gofumpt -extra -w .
2019-09-14 14:11:40 +02:00
2021-06-22 12:34:35 +02:00
.PHONY : clean
2022-09-28 17:28:23 +02:00
clean : ## Clean build artifacts
2021-06-22 12:34:35 +02:00
go clean -i ./...
rm -rf build
2022-02-10 16:12:47 +02:00
@[ "1" != " $( shell docker image ls woodpecker/make:local -a | wc -l) " ] && docker image rm woodpecker/make:local || echo no docker image to clean
2021-06-22 12:34:35 +02:00
2024-01-09 18:53:56 +02:00
.PHONY : clean -all
clean-all : clean ## Clean all artifacts
2024-06-24 08:29:47 +02:00
rm -rf ${ DIST_DIR } web/dist docs/build docs/node_modules web/node_modules
2024-01-09 18:53:56 +02:00
# delete generated
2024-11-23 10:17:19 +02:00
rm -rf docs/docs/40-cli.md docs/openapi.json
2024-01-09 18:53:56 +02:00
2023-03-19 19:32:19 +02:00
.PHONY : generate
2024-11-23 10:17:19 +02:00
generate : install -tools generate -openapi ## Run all code generations
2024-06-12 18:02:55 +02:00
CGO_ENABLED = 0 go generate ./...
2023-03-19 19:32:19 +02:00
2024-11-23 10:17:19 +02:00
generate-openapi : install -tools ## Run openapi code generation and format it
go run github.com/swaggo/swag/cmd/swag fmt
CGO_ENABLED = 0 go generate cmd/server/openapi.go
2023-06-03 21:38:36 +02:00
2023-08-10 11:06:00 +02:00
generate-license-header : install -tools
addlicense -c "Woodpecker Authors" -ignore "vendor/**" **/*.go
2022-09-28 17:28:23 +02:00
check-xgo : ## Check if xgo is installed
@hash xgo > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
$( GO) install src.techknowlogick.com/xgo@latest; \
fi
install-tools : ## Install development tools
@hash golangci-lint > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
2024-03-21 12:22:36 +02:00
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest ; \
2022-09-28 17:28:23 +02:00
fi ; \
hash gofumpt > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
go install mvdan.cc/gofumpt@latest; \
2023-06-03 21:38:36 +02:00
fi ; \
2023-08-10 11:06:00 +02:00
hash addlicense > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
go install github.com/google/addlicense@latest; \
2024-04-15 17:46:44 +02:00
fi ; \
hash mockery > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
go install github.com/vektra/mockery/v2@latest; \
fi ; \
hash protoc-gen-go > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest; \
fi ; \
hash protoc-gen-go-grpc > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest; \
2022-09-28 17:28:23 +02:00
fi
ui-dependencies : ## Install UI dependencies
2022-10-08 16:15:07 +02:00
( cd web/; pnpm install --frozen-lockfile)
2022-09-28 17:28:23 +02:00
##@ Test
2021-10-13 18:48:43 +02:00
.PHONY : lint
2022-09-28 17:28:23 +02:00
lint : install -tools ## Lint code
2021-11-14 22:01:54 +02:00
@echo "Running golangci-lint"
2023-12-29 22:19:42 +02:00
golangci-lint run
2021-10-13 18:48:43 +02:00
2024-01-22 09:10:28 +02:00
lint-ui : ui -dependencies ## Lint UI code
2022-10-08 16:15:07 +02:00
( cd web/; pnpm lint --quiet)
2021-11-30 18:46:19 +02:00
2022-09-28 17:28:23 +02:00
test-agent : ## Test agent code
2024-12-22 11:44:34 +02:00
go test -race -cover -coverprofile agent-coverage.out -timeout 60s -tags 'test $(TAGS)' go.woodpecker-ci.org/woodpecker/v3/cmd/agent go.woodpecker-ci.org/woodpecker/v3/agent/...
2019-09-14 14:11:40 +02:00
2022-09-28 17:28:23 +02:00
test-server : ## Test server code
2024-12-22 11:44:34 +02:00
go test -race -cover -coverprofile server-coverage.out -timeout 60s -tags 'test $(TAGS)' go.woodpecker-ci.org/woodpecker/v3/cmd/server $( shell go list go.woodpecker-ci.org/woodpecker/v3/server/... | grep -v '/store' )
2021-11-30 18:46:19 +02:00
2022-09-28 17:28:23 +02:00
test-cli : ## Test cli code
2024-12-22 11:44:34 +02:00
go test -race -cover -coverprofile cli-coverage.out -timeout 60s -tags 'test $(TAGS)' go.woodpecker-ci.org/woodpecker/v3/cmd/cli go.woodpecker-ci.org/woodpecker/v3/cli/...
2019-09-14 14:11:40 +02:00
2022-09-28 17:28:23 +02:00
test-server-datastore : ## Test server datastore
2024-12-22 11:44:34 +02:00
go test -timeout 300s -tags 'test $(TAGS)' -run TestMigrate go.woodpecker-ci.org/woodpecker/v3/server/store/...
go test -race -timeout 100s -tags 'test $(TAGS)' -skip TestMigrate go.woodpecker-ci.org/woodpecker/v3/server/store/...
2022-02-01 20:34:56 +02:00
2022-09-28 17:28:23 +02:00
test-server-datastore-coverage : ## Test server datastore with coverage report
2024-12-22 11:44:34 +02:00
go test -race -cover -coverprofile datastore-coverage.out -timeout 300s -tags 'test $(TAGS)' go.woodpecker-ci.org/woodpecker/v3/server/store/...
2021-12-07 02:13:31 +02:00
2022-09-28 17:28:23 +02:00
test-ui : ui -dependencies ## Test UI code
2022-10-08 16:15:07 +02:00
( cd web/; pnpm run lint)
2023-08-17 15:52:43 +02:00
( cd web/; pnpm run format:check)
2022-10-08 16:15:07 +02:00
( cd web/; pnpm run typecheck)
( cd web/; pnpm run test )
2019-11-12 15:27:39 +02:00
2022-09-28 17:28:23 +02:00
test-lib : ## Test lib code
2024-07-13 16:55:01 +02:00
go test -race -cover -coverprofile coverage.out -timeout 60s -tags 'test $(TAGS)' $( shell go list ./... | grep -v '/cmd\|/agent\|/cli\|/server' )
2019-09-14 14:11:40 +02:00
2023-10-31 10:14:09 +02:00
.PHONY : test
2024-01-22 09:10:28 +02:00
test : test -agent test -server test -server -datastore test -cli test -lib ## Run all tests
2022-09-28 17:28:23 +02:00
##@ Build
2019-09-14 14:11:40 +02:00
2022-09-28 17:28:23 +02:00
build-ui : ## Build UI
2022-10-08 16:15:07 +02:00
( cd web/; pnpm install --frozen-lockfile; pnpm build)
2019-09-14 14:11:40 +02:00
2024-11-23 10:17:19 +02:00
build-server : build -ui generate -openapi ## Build server
2024-12-22 11:44:34 +02:00
CGO_ENABLED = ${ CGO_ENABLED } GOOS = ${ TARGETOS } GOARCH = ${ TARGETARCH } go build -tags '$(TAGS)' -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /woodpecker-server${ BIN_SUFFIX } go.woodpecker-ci.org/woodpecker/v3/cmd/server
2019-09-14 14:11:40 +02:00
2022-09-28 17:28:23 +02:00
build-agent : ## Build agent
2024-12-22 11:44:34 +02:00
CGO_ENABLED = 0 GOOS = ${ TARGETOS } GOARCH = ${ TARGETARCH } go build -tags '$(TAGS)' -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /woodpecker-agent${ BIN_SUFFIX } go.woodpecker-ci.org/woodpecker/v3/cmd/agent
2019-11-12 15:27:39 +02:00
2022-09-28 17:28:23 +02:00
build-cli : ## Build cli
2024-12-22 11:44:34 +02:00
CGO_ENABLED = 0 GOOS = ${ TARGETOS } GOARCH = ${ TARGETARCH } go build -tags '$(TAGS)' -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /woodpecker-cli${ BIN_SUFFIX } go.woodpecker-ci.org/woodpecker/v3/cmd/cli
2019-09-14 14:11:40 +02:00
2024-01-21 23:18:20 +02:00
build-tarball : ## Build tar archive
2024-06-24 08:29:47 +02:00
mkdir -p ${ DIST_DIR } && tar chzvf ${ DIST_DIR } /woodpecker-src.tar.gz \
2024-01-21 23:18:20 +02:00
--exclude= "*.exe" \
--exclude= "./.pnpm-store" \
--exclude= "node_modules" \
--exclude= "./dist" \
--exclude= "./data" \
--exclude= "./build" \
--exclude= "./.git" \
.
2023-10-31 10:14:09 +02:00
.PHONY : build
2022-09-28 17:28:23 +02:00
build : build -agent build -server build -cli ## Build all binaries
2021-06-22 13:12:26 +02:00
2022-09-28 17:28:23 +02:00
release-frontend : build -frontend ## Build frontend
2022-03-01 17:40:24 +02:00
2022-09-28 17:28:23 +02:00
cross-compile-server : ## Cross compile the server
2022-03-01 17:40:24 +02:00
$( foreach platform,$( subst ; , ,$( PLATFORMS) ) ,\
TARGETOS = $( firstword $( subst | , ,$( platform) ) ) \
TARGETARCH_XGO = $( subst arm64/v8,arm64,$( subst arm/v7,arm-7,$( word 2,$( subst | , ,$( platform) ) ) ) ) \
TARGETARCH_BUILDX = $( subst arm64/v8,arm64,$( subst arm/v7,arm,$( word 2,$( subst | , ,$( platform) ) ) ) ) \
make release-server-xgo || exit 1; \
)
2024-06-24 08:29:47 +02:00
tree ${ DIST_DIR }
2022-03-01 17:40:24 +02:00
2022-09-28 17:28:23 +02:00
release-server-xgo : check -xgo ## Create server binaries for release using xgo
2022-03-01 17:40:24 +02:00
@echo "Building for:"
@echo " os: $( TARGETOS) "
@echo " arch orgi: $( TARGETARCH) "
@echo " arch (xgo): $( TARGETARCH_XGO) "
@echo " arch (buildx): $( TARGETARCH_BUILDX) "
2024-07-14 22:59:45 +02:00
# build via xgo
2024-06-24 08:29:47 +02:00
CGO_CFLAGS = " $( CGO_CFLAGS) " xgo -go $( XGO_VERSION) -dest ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_BUILDX) -tags 'netgo osusergo grpcnotrace $(TAGS)' -ldflags '-linkmode external $(LDFLAGS)' -targets '$(TARGETOS)/$(TARGETARCH_XGO)' -out woodpecker-server -pkg cmd/server .
2024-07-14 22:59:45 +02:00
# move binary into subfolder depending on target os and arch
@if [ " $$ {XGO_IN_XGO:-0} " -eq "1" ] ; then \
echo "inside xgo image" ; \
2024-06-24 08:29:47 +02:00
mkdir -p ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_BUILDX) ; \
mv -vf /build/woodpecker-server* ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_BUILDX) /woodpecker-server$( BIN_SUFFIX) ; \
2024-07-14 22:59:45 +02:00
else \
echo "outside xgo image" ; \
2024-06-24 08:29:47 +02:00
[ -f " ${ DIST_DIR } /server/ $( TARGETOS) _ $( TARGETARCH_BUILDX) /woodpecker-server $( BIN_SUFFIX) " ] && rm -v ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_BUILDX) /woodpecker-server$( BIN_SUFFIX) ; \
mv -v ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_XGO) /woodpecker-server* ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_BUILDX) /woodpecker-server$( BIN_SUFFIX) ; \
2023-12-29 23:31:34 +02:00
fi
2024-07-14 22:59:45 +02:00
# if enabled package it in an archive
@if [ " $$ {ARCHIVE_IT:-0} " -eq "1" ] ; then \
if [ " $( BIN_SUFFIX) " = ".exe" ] ; then \
rm -f ${ DIST_DIR } /woodpecker-server_$( TARGETOS) _$( TARGETARCH_BUILDX) .zip; \
zip -j ${ DIST_DIR } /woodpecker-server_$( TARGETOS) _$( TARGETARCH_BUILDX) .zip ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_BUILDX) /woodpecker-server.exe; \
else \
tar -cvzf ${ DIST_DIR } /woodpecker-server_$( TARGETOS) _$( TARGETARCH_BUILDX) .tar.gz -C ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH_BUILDX) woodpecker-server$( BIN_SUFFIX) ; \
fi ; \
else \
echo " skip creating ' ${ DIST_DIR } /woodpecker-server_ $( TARGETOS) _ $( TARGETARCH_BUILDX) .tar.gz' " ; \
fi
2022-03-01 17:40:24 +02:00
2022-09-28 17:28:23 +02:00
release-server : ## Create server binaries for release
2021-10-04 19:50:21 +02:00
# compile
2024-12-22 11:44:34 +02:00
GOOS = $( TARGETOS) GOARCH = $( TARGETARCH) CGO_ENABLED = ${ CGO_ENABLED } go build -ldflags '${LDFLAGS}' -tags 'grpcnotrace $(TAGS)' -o ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH) /woodpecker-server$( BIN_SUFFIX) go.woodpecker-ci.org/woodpecker/v3/cmd/server
2021-10-04 19:50:21 +02:00
# tar binary files
2024-07-14 22:59:45 +02:00
if [ " $( BIN_SUFFIX) " = = ".exe" ] ; then \
zip -j ${ DIST_DIR } /woodpecker-server_$( TARGETOS) _$( TARGETARCH) .zip ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH) /woodpecker-server.exe; \
else \
tar -cvzf ${ DIST_DIR } /woodpecker-server_$( TARGETOS) _$( TARGETARCH) .tar.gz -C ${ DIST_DIR } /server/$( TARGETOS) _$( TARGETARCH) woodpecker-server$( BIN_SUFFIX) ; \
fi
2021-10-04 19:50:21 +02:00
2022-09-28 17:28:23 +02:00
release-agent : ## Create agent binaries for release
2021-10-04 19:50:21 +02:00
# compile
2024-12-22 11:44:34 +02:00
GOOS = linux GOARCH = amd64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -tags 'grpcnotrace $(TAGS)' -o ${ DIST_DIR } /agent/linux_amd64/woodpecker-agent go.woodpecker-ci.org/woodpecker/v3/cmd/agent
GOOS = linux GOARCH = arm64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -tags 'grpcnotrace $(TAGS)' -o ${ DIST_DIR } /agent/linux_arm64/woodpecker-agent go.woodpecker-ci.org/woodpecker/v3/cmd/agent
GOOS = linux GOARCH = arm CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -tags 'grpcnotrace $(TAGS)' -o ${ DIST_DIR } /agent/linux_arm/woodpecker-agent go.woodpecker-ci.org/woodpecker/v3/cmd/agent
GOOS = windows GOARCH = amd64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -tags 'grpcnotrace $(TAGS)' -o ${ DIST_DIR } /agent/windows_amd64/woodpecker-agent.exe go.woodpecker-ci.org/woodpecker/v3/cmd/agent
GOOS = darwin GOARCH = amd64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -tags 'grpcnotrace $(TAGS)' -o ${ DIST_DIR } /agent/darwin_amd64/woodpecker-agent go.woodpecker-ci.org/woodpecker/v3/cmd/agent
GOOS = darwin GOARCH = arm64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -tags 'grpcnotrace $(TAGS)' -o ${ DIST_DIR } /agent/darwin_arm64/woodpecker-agent go.woodpecker-ci.org/woodpecker/v3/cmd/agent
2021-10-04 19:50:21 +02:00
# tar binary files
2024-06-24 08:29:47 +02:00
tar -cvzf ${ DIST_DIR } /woodpecker-agent_linux_amd64.tar.gz -C ${ DIST_DIR } /agent/linux_amd64 woodpecker-agent
tar -cvzf ${ DIST_DIR } /woodpecker-agent_linux_arm64.tar.gz -C ${ DIST_DIR } /agent/linux_arm64 woodpecker-agent
tar -cvzf ${ DIST_DIR } /woodpecker-agent_linux_arm.tar.gz -C ${ DIST_DIR } /agent/linux_arm woodpecker-agent
tar -cvzf ${ DIST_DIR } /woodpecker-agent_darwin_amd64.tar.gz -C ${ DIST_DIR } /agent/darwin_amd64 woodpecker-agent
tar -cvzf ${ DIST_DIR } /woodpecker-agent_darwin_arm64.tar.gz -C ${ DIST_DIR } /agent/darwin_arm64 woodpecker-agent
2024-07-14 22:59:45 +02:00
# zip binary files
rm -f ${ DIST_DIR } /woodpecker-agent_windows_amd64.zip
zip -j ${ DIST_DIR } /woodpecker-agent_windows_amd64.zip ${ DIST_DIR } /agent/windows_amd64/woodpecker-agent.exe
2021-06-22 13:12:26 +02:00
2022-09-28 17:28:23 +02:00
release-cli : ## Create cli binaries for release
2021-10-04 19:50:21 +02:00
# compile
2024-12-22 11:44:34 +02:00
GOOS = linux GOARCH = amd64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /cli/linux_amd64/woodpecker-cli go.woodpecker-ci.org/woodpecker/v3/cmd/cli
GOOS = linux GOARCH = arm64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /cli/linux_arm64/woodpecker-cli go.woodpecker-ci.org/woodpecker/v3/cmd/cli
GOOS = linux GOARCH = arm CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /cli/linux_arm/woodpecker-cli go.woodpecker-ci.org/woodpecker/v3/cmd/cli
GOOS = windows GOARCH = amd64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /cli/windows_amd64/woodpecker-cli.exe go.woodpecker-ci.org/woodpecker/v3/cmd/cli
GOOS = darwin GOARCH = amd64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /cli/darwin_amd64/woodpecker-cli go.woodpecker-ci.org/woodpecker/v3/cmd/cli
GOOS = darwin GOARCH = arm64 CGO_ENABLED = 0 go build -ldflags '${LDFLAGS}' -o ${ DIST_DIR } /cli/darwin_arm64/woodpecker-cli go.woodpecker-ci.org/woodpecker/v3/cmd/cli
2021-10-04 19:50:21 +02:00
# tar binary files
2024-06-24 08:29:47 +02:00
tar -cvzf ${ DIST_DIR } /woodpecker-cli_linux_amd64.tar.gz -C ${ DIST_DIR } /cli/linux_amd64 woodpecker-cli
tar -cvzf ${ DIST_DIR } /woodpecker-cli_linux_arm64.tar.gz -C ${ DIST_DIR } /cli/linux_arm64 woodpecker-cli
tar -cvzf ${ DIST_DIR } /woodpecker-cli_linux_arm.tar.gz -C ${ DIST_DIR } /cli/linux_arm woodpecker-cli
tar -cvzf ${ DIST_DIR } /woodpecker-cli_darwin_amd64.tar.gz -C ${ DIST_DIR } /cli/darwin_amd64 woodpecker-cli
tar -cvzf ${ DIST_DIR } /woodpecker-cli_darwin_arm64.tar.gz -C ${ DIST_DIR } /cli/darwin_arm64 woodpecker-cli
2024-07-14 22:59:45 +02:00
# zip binary files
rm -f ${ DIST_DIR } /woodpecker-cli_windows_amd64.zip
zip -j ${ DIST_DIR } /woodpecker-cli_windows_amd64.zip ${ DIST_DIR } /cli/windows_amd64/woodpecker-cli.exe
2021-10-04 19:50:21 +02:00
2022-09-28 17:28:23 +02:00
release-checksums : ## Create checksums for all release files
2021-06-22 13:26:37 +02:00
# generate shas for tar files
2024-06-24 08:29:47 +02:00
( cd ${ DIST_DIR } /; sha256sum *.* > checksums.txt)
2021-10-04 19:50:21 +02:00
2023-10-31 10:14:09 +02:00
.PHONY : release
2022-09-28 17:28:23 +02:00
release : release -frontend release -server release -agent release -cli ## Release all binaries
2021-06-22 13:26:37 +02:00
2022-09-28 17:28:23 +02:00
bundle-prepare : ## Prepare the bundles
2021-10-21 18:34:49 +02:00
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.6.0
2021-10-20 21:55:09 +02:00
2022-09-28 17:28:23 +02:00
bundle-agent : bundle -prepare ## Create bundles for agent
2024-06-24 08:29:47 +02:00
VERSION_NUMBER = $( VERSION_NUMBER) nfpm package --config ./nfpm/agent.yaml --target ${ DIST_DIR } --packager deb
VERSION_NUMBER = $( VERSION_NUMBER) nfpm package --config ./nfpm/agent.yaml --target ${ DIST_DIR } --packager rpm
2021-10-20 21:55:09 +02:00
2022-09-28 17:28:23 +02:00
bundle-server : bundle -prepare ## Create bundles for server
2024-06-24 08:29:47 +02:00
VERSION_NUMBER = $( VERSION_NUMBER) nfpm package --config ./nfpm/server.yaml --target ${ DIST_DIR } --packager deb
VERSION_NUMBER = $( VERSION_NUMBER) nfpm package --config ./nfpm/server.yaml --target ${ DIST_DIR } --packager rpm
2021-10-20 21:55:09 +02:00
2022-09-28 17:28:23 +02:00
bundle-cli : bundle -prepare ## Create bundles for cli
2024-06-24 08:29:47 +02:00
VERSION_NUMBER = $( VERSION_NUMBER) nfpm package --config ./nfpm/cli.yaml --target ${ DIST_DIR } --packager deb
VERSION_NUMBER = $( VERSION_NUMBER) nfpm package --config ./nfpm/cli.yaml --target ${ DIST_DIR } --packager rpm
2021-10-20 21:55:09 +02:00
2023-10-31 10:14:09 +02:00
.PHONY : bundle
2022-09-28 17:28:23 +02:00
bundle : bundle -agent bundle -server bundle -cli ## Create all bundles
2021-10-20 21:55:09 +02:00
2024-04-26 07:51:10 +02:00
.PHONY : spellcheck
spellcheck :
pnpx cspell lint --no-progress --gitignore '{**,.*}/{*,.*}'
2024-05-14 02:45:03 +02:00
tree --gitignore \
-I 012_columns_rename_procs_to_steps.go \
-I versioned_docs -I '*opensource.svg' | \
pnpx cspell lint --no-progress stdin
2024-04-26 07:51:10 +02:00
2022-09-28 17:28:23 +02:00
##@ Docs
.PHONY : docs
docs : ## Generate docs (currently only for the cli)
2024-06-12 18:02:55 +02:00
CGO_ENABLED = 0 go generate cmd/cli/app.go
2024-11-23 10:17:19 +02:00
CGO_ENABLED = 0 go generate cmd/server/openapi.go
2022-02-10 16:12:47 +02:00
e n d i f