1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

Improve release (#400)

* improve make release

* improve release

* fix release workflow
This commit is contained in:
Anbraten 2021-10-04 19:50:21 +02:00 committed by GitHub
parent e3354e440f
commit 2084ff3a62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 45 deletions

3
.gitignore vendored
View File

@ -33,9 +33,8 @@ docker-compose.yml
*.out
/.env
extras/
release/
/build/
cli/release/
/dist/
server/swagger/files/*.json
server/swagger/swagger_gen.go

View File

@ -41,20 +41,28 @@ pipeline:
build-frontend:
image: node:10.17.0-stretch
commands:
- make build-frontend
- make release-frontend
build:
build-server:
group: build
image: golang:1.16
commands:
- go get github.com/woodpecker-ci/togo
- (cd web/; go generate ./...)
- make release
- make release-server
build-agent:
group: build
image: golang:1.16
commands:
- make release-agent
build-cli:
group: build
image: golang:1.16
commands: make release-cli
commands:
- make release-cli
publish-server:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server
@ -66,6 +74,7 @@ pipeline:
event: push
publish-server-alpine:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server.alpine
@ -77,6 +86,7 @@ pipeline:
event: push
publish-agent:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent
@ -88,6 +98,7 @@ pipeline:
event: push
publish-agent-alpine:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent.alpine
@ -99,6 +110,7 @@ pipeline:
event: push
release-server:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server
@ -108,6 +120,7 @@ pipeline:
event: tag
release-server-alpine:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-server
dockerfile: docker/Dockerfile.server.alpine
@ -117,6 +130,7 @@ pipeline:
event: tag
release-agent:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent
@ -126,6 +140,7 @@ pipeline:
event: tag
release-agent-alpine:
group: docker
image: plugins/docker
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent.alpine
@ -134,11 +149,21 @@ pipeline:
when:
event: tag
release-cli:
checksums:
image: golang:1.16
commands:
- make release-checksums
when:
event: tag
# TODO: upload build artifacts for pushes to master
release:
image: plugins/github-release
files:
- cli/release/woodpecker_*.tar.gz
- cli/release/woodpecker_checksums.txt
- dist/*.tar.gz
- dist/checksums.txt
title: ${DRONE_TAG##v}
secrets:
- source: github_token
target: github_release_api_key

View File

@ -2,16 +2,18 @@ DOCKER_RUN_GO_VERSION=1.16
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
VERSION ?= ${DRONE_TAG}
ifeq ($(VERSION),)
VERSION := $(shell echo ${DRONE_COMMIT_SHA} | head -c 8)
VERSION ?= next
ifneq ($(DRONE_TAG),)
VERSION := $(DRONE_TAG:v%=%)
endif
LDFLAGS ?= -extldflags "-static"
ifneq ($(VERSION),)
LDFLAGS := ${LDFLAGS} -X github.com/woodpecker-ci/woodpecker/version.Version=${VERSION}
# 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)")
endif
LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION}
DOCKER_RUN?=
_with-docker:
@ -53,39 +55,56 @@ test-lib:
test: test-lib test-agent test-server
build-agent:
$(DOCKER_RUN) go build -o build/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
build-server:
$(DOCKER_RUN) go build -o build/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
build-frontend:
(cd web/; yarn; yarn run build)
(cd web/; yarn; yarn build)
build: build-agent build-server
build-server: build-frontend
$(DOCKER_RUN) go build -o dist/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
release-agent:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
build-agent:
$(DOCKER_RUN) go build -o dist/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
build-cli:
$(DOCKER_RUN) go build -o dist/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
build: build-agent build-server build-cli
release-frontend: build-frontend
release-server:
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -ldflags '${LDFLAGS}' -o release/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
# 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
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
# tar binary files
tar -cvzf dist/woodpecker-agent_linux_amd64.tar.gz -C dist/agent/linux_amd64 woodpecker-agent
release-cli:
# disable CGO for cross-compiling
export CGO_ENABLED=0
# compile for all architectures
GOOS=linux GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o cli/release/linux/amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=linux GOARCH=arm64 go build -ldflags '${LDFLAGS}' -o cli/release/linux/arm64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=linux GOARCH=arm go build -ldflags '${LDFLAGS}' -o cli/release/linux/arm/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=windows GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o cli/release/windows/amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=darwin GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o cli/release/darwin/amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
# tar binary files prior to upload
tar -cvzf cli/release/woodpecker_linux_amd64.tar.gz -C cli/release/linux/amd64 woodpecker-cli
tar -cvzf cli/release/woodpecker_linux_arm64.tar.gz -C cli/release/linux/arm64 woodpecker-cli
tar -cvzf cli/release/woodpecker_linux_arm.tar.gz -C cli/release/linux/arm woodpecker-cli
tar -cvzf cli/release/woodpecker_windows_amd64.tar.gz -C cli/release/windows/amd64 woodpecker-cli
tar -cvzf cli/release/woodpecker_darwin_amd64.tar.gz -C cli/release/darwin/amd64 woodpecker-cli
# generate shas for tar files
sha256sum cli/release/*.tar.gz > cli/release/woodpecker_checksums.txt
# compile
GOOS=linux GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o dist/cli/linux_amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=linux GOARCH=arm64 go build -ldflags '${LDFLAGS}' -o dist/cli/linux_arm64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=linux GOARCH=arm go build -ldflags '${LDFLAGS}' -o dist/cli/linux_arm/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=windows GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o dist/cli/windows_amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=darwin GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o dist/cli/darwin_amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
GOOS=darwin GOARCH=arm64 go build -ldflags '${LDFLAGS}' -o dist/cli/darwin_arm64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
# 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: release-agent release-server
release-checksums:
# generate shas for tar files
(cd dist/; sha256sum *.{tar.gz,apk,deb,rpm} > checksums.txt)
release: release-frontend release-server release-agent release-cli
.PHONY: version
version:
@echo ${VERSION}