109 lines
2.7 KiB
YAML
109 lines
2.7 KiB
YAML
|
|
|
|
variables:
|
|
- &golang_image 'golang:1.21'
|
|
- &goproxy_override ''
|
|
- &goproxy_setup |-
|
|
if [ -n "$${GOPROXY_OVERRIDE:-}" ]; then
|
|
export GOPROXY="$${GOPROXY_OVERRIDE}";
|
|
echo "Using goproxy from goproxy_override \"$${GOPROXY}\"";
|
|
elif [ -n "$${GOPROXY_DEFAULT:-}" ]; then
|
|
export GOPROXY="$${GOPROXY_DEFAULT}";
|
|
echo "Using goproxy from goproxy_default (secret) not displaying";
|
|
else
|
|
export GOPROXY="https://proxy.golang.org,direct";
|
|
echo "No goproxy overrides or defaults given, using \"$${GOPROXY}\"";
|
|
fi
|
|
- &buildx_image 'woodpeckerci/plugin-docker-buildx:2.2.1'
|
|
- &platforms 'linux/amd64'
|
|
|
|
workspace:
|
|
base: /go
|
|
path: go-import-redirector
|
|
|
|
steps:
|
|
deps:
|
|
image: *golang_image
|
|
pull: true
|
|
environment:
|
|
GOPROXY_OVERRIDE: *goproxy_override
|
|
secrets:
|
|
- goproxy_default
|
|
commands:
|
|
- *goproxy_setup
|
|
- make vendor
|
|
- make checks
|
|
- make lint
|
|
|
|
build:
|
|
image: *golang_image
|
|
environment:
|
|
GOPROXY_OVERRIDE: *goproxy_override
|
|
secrets:
|
|
- goproxy_default
|
|
commands:
|
|
- *goproxy_setup
|
|
- make release
|
|
- make dockerize
|
|
|
|
build-docker-next:
|
|
image: *buildx_image
|
|
pull: true
|
|
settings:
|
|
platforms: *platforms
|
|
dockerfile: dist/docker/Dockerfile
|
|
context: dist/docker/
|
|
registry:
|
|
from_secret: registry_domain
|
|
repo:
|
|
from_secret: target_image_name
|
|
password:
|
|
from_secret: registry_token
|
|
username:
|
|
from_secret: registry_user
|
|
auto_tag: true
|
|
tag: [next, "next-${CI_COMMIT_SHA:0:8}"]
|
|
when:
|
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
|
event: push
|
|
|
|
build-docker-branch:
|
|
image: *buildx_image
|
|
pull: true
|
|
settings:
|
|
platforms: *platforms
|
|
dockerfile: dist/docker/Dockerfile
|
|
context: dist/docker/
|
|
registry:
|
|
from_secret: registry_domain
|
|
repo:
|
|
from_secret: target_image_name
|
|
password:
|
|
from_secret: registry_token
|
|
username:
|
|
from_secret: registry_user
|
|
auto_tag: true
|
|
tag: ["${CI_COMMIT_BRANCH}", "${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}"]
|
|
when:
|
|
event: [push, manual]
|
|
|
|
build-docker-tag:
|
|
image: *buildx_image
|
|
pull: true
|
|
settings:
|
|
platforms: *platforms
|
|
dockerfile: dist/docker/Dockerfile
|
|
context: dist/docker/
|
|
registry:
|
|
from_secret: registry_domain
|
|
repo:
|
|
from_secret: target_image_name
|
|
password:
|
|
from_secret: registry_token
|
|
username:
|
|
from_secret: registry_user
|
|
auto_tag: true
|
|
tag: [latest, "${CI_COMMIT_TAG}", "tag-${CI_COMMIT_SHA:0:8}"]
|
|
when:
|
|
event: [tag]
|