Run pipeline for binary files on pull if go code changed (#722)

* run pipeline for binary files on pull if go code changed

* add release-dryrun

* run "test" only if go code changes

* fix-build-checksum
This commit is contained in:
6543 2022-01-29 13:58:55 +01:00 committed by GitHub
parent 48089f53d8
commit 062579d66f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 189 additions and 77 deletions

126
.woodpecker/binaries.yml Normal file
View file

@ -0,0 +1,126 @@
depends_on:
- test
- web
pipeline:
build-web:
image: node:16-alpine
commands:
- cd web/
- yarn install --frozen-lockfile
- yarn build
when:
path:
include:
# related config files
- ".woodpecker/binaries.yml"
- "nfpm/*.yml"
# go source code
- "**/*.go"
- "go.*"
# web source code
- "web/**"
build-server:
group: build
image: golang:1.16
commands:
- make release-server
when:
path:
include:
# related config files
- ".woodpecker/binaries.yml"
- "nfpm/*.yml"
# go source code
- "**/*.go"
- "go.*"
# web source code
- "web/**"
build-agent:
group: build
image: golang:1.16
commands:
- make release-agent
when:
path:
include:
# related config files
- ".woodpecker/binaries.yml"
- "nfpm/*.yml"
# go source code
- "**/*.go"
- "go.*"
build-cli:
group: build
image: golang:1.16
commands:
- make release-cli
when:
path:
include:
# related config files
- ".woodpecker/binaries.yml"
- "nfpm/*.yml"
# go source code
- "**/*.go"
- "go.*"
build-deb-rpm:
group: bundle
image: golang:1.16
commands:
- make bundle
when:
path:
include:
# related config files
- ".woodpecker/binaries.yml"
- "nfpm/*.yml"
# go source code
- "**/*.go"
- "go.*"
# web source code
- "web/**"
checksums:
image: golang:1.16
commands:
- make release-checksums
when:
path:
include:
# related config files
- ".woodpecker/binaries.yml"
- "nfpm/*.yml"
# go source code
- "**/*.go"
- "go.*"
# web source code
- "web/**"
# TODO: upload build artifacts for pushes to ${CI_REPO_DEFAULT_BRANCH}
release-dryrun:
image: golang:1.16
commands:
- ls -la dist/*.*
- cat dist/checksums.txt
release:
image: plugins/github-release
secrets:
- source: github_token
target: github_release_api_key
settings:
files:
- dist/*.tar.gz
- dist/*.deb
- dist/*.rpm
- dist/checksums.txt
title: ${CI_COMMIT_TAG##v}
when:
event: tag
# path conditions are ignored for tag events

View file

@ -1,3 +1,7 @@
depends_on:
- test
- web
pipeline:
build-web:
image: node:16-alpine
@ -217,7 +221,3 @@ pipeline:
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
when:
event: tag
depends_on:
- test
- web

View file

@ -1,65 +0,0 @@
pipeline:
build-web:
image: node:16-alpine
commands:
- cd web/
- yarn install --frozen-lockfile
- yarn build
build-server:
group: build
image: golang:1.16
commands:
- make release-server
build-agent:
group: build
image: golang:1.16
commands:
- make release-agent
when:
event: tag
build-cli:
group: build
image: golang:1.16
commands:
- make release-cli
when:
event: tag
build-deb-rpm:
group: bundle
image: golang:1.16
commands:
- make bundle
when:
event: tag
checksums:
image: golang:1.16
commands:
- make release-checksums
when:
event: tag
# TODO: upload build artifacts for pushes to ${CI_REPO_DEFAULT_BRANCH}
release:
image: plugins/github-release
secrets:
- source: github_token
target: github_release_api_key
settings:
files:
- dist/*.tar.gz
- dist/*.deb
- dist/*.rpm
- dist/checksums.txt
title: ${CI_COMMIT_TAG##v}
when:
event: tag
depends_on:
- test
- web

View file

@ -4,6 +4,14 @@ pipeline:
commands:
- mkdir -p web/dist/
- echo "test" > web/dist/index.html
when:
path:
include:
# related config files
- ".woodpecker/test.yml"
# go source code
- "**/*.go"
- "go.*"
lint:
image: golang:1.16
@ -13,11 +21,12 @@ pipeline:
when:
path:
include:
- "vendor/**"
- "go.mod"
- "go.sum"
- "**/*.go"
# related config files
- ".woodpecker/test.yml"
- ".golangci.yml"
# go source code
- "**/*.go"
- "go.*"
test:
image: golang:1.16
@ -30,10 +39,11 @@ pipeline:
when:
path:
include:
- "vendor/**"
- "go.mod"
- "go.sum"
# related config files
- ".woodpecker/test.yml"
# go source code
- "**/*.go"
- "go.*"
sqlite:
image: golang:1.16
@ -42,6 +52,14 @@ pipeline:
- WOODPECKER_DATABASE_DRIVER=sqlite3
commands:
- make test-server-datastore
when:
path:
include:
# related config files
- ".woodpecker/test.yml"
# go source code
- "**/*.go"
- "go.*"
postgres:
image: golang:1.16
@ -51,6 +69,14 @@ pipeline:
- WOODPECKER_DATABASE_DATASOURCE=host=service-postgres user=postgres dbname=postgres sslmode=disable
commands:
- make test-server-datastore
when:
path:
include:
# related config files
- ".woodpecker/test.yml"
# go source code
- "**/*.go"
- "go.*"
mysql:
image: golang:1.16
@ -60,6 +86,14 @@ pipeline:
- WOODPECKER_DATABASE_DATASOURCE=root@tcp(service-mysql:3306)/test?parseTime=true
commands:
- make test-server-datastore
when:
path:
include:
# related config files
- ".woodpecker/test.yml"
# go source code
- "**/*.go"
- "go.*"
services:
service-postgres:
@ -68,9 +102,26 @@ services:
environment:
- POSTGRES_USER=postgres
- POSTGRES_HOST_AUTH_METHOD=trust
when:
path:
include:
# related config files
- ".woodpecker/test.yml"
# go source code
- "**/*.go"
- "go.*"
service-mysql:
image: mysql:5.6.27
ports: ["3306"]
environment:
- MYSQL_DATABASE=test
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
when:
path:
include:
# related config files
- ".woodpecker/test.yml"
# go source code
- "**/*.go"
- "go.*"

View file

@ -128,7 +128,7 @@ release-cli:
release-checksums:
# generate shas for tar files
(cd dist/; sha256sum *.{tar.gz,apk,deb,rpm} > checksums.txt)
(cd dist/; sha256sum *.* > checksums.txt)
release: release-frontend release-server release-agent release-cli