Skip to content
Snippets Groups Projects
Unverified Commit e792ed18 authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

feat: pass gitlab version file variables to Goreleaser

This allows goreleaser to reference variables in build stage.
parent 0407d648
No related branches found
No related tags found
No related merge requests found
Pipeline #23198034 passed
spec:
inputs:
docker_hub_host:
default: docker.io
---
# Note: this is not a full template, just the basis
 
include:
Loading
Loading
@@ -9,7 +15,7 @@ include:
entrypoint: [""]
retry: 2
services:
- docker:dind
- $[[ inputs.docker_hub_host ]]/docker:dind
variables:
DOCKER_DRIVER: overlayfs
DOCKER_HOST: tcp://docker:2376
Loading
Loading
Loading
Loading
@@ -246,3 +246,13 @@ set the `GORELEASER_FULL_MOCK_RELEASE` variable to 1:
variables:
GORELEASER_FULL_MOCK_RELEASE: 1
```
## Toolversion Variable Passthrough
Similar to the [Docker](./docker.md) task, the Goreleaser task will automatically pass any tool-version variables
through to the Goreleaser Docker container.
The set of arguments is parsed from the `.gitlab-ci-asdf-versions.yml` and `.gitlab-ci-other-versions.yml` files,
if they exist.
This can be customized through the `GL_VERSION_YML_FILES` variable.
Loading
Loading
@@ -71,23 +71,37 @@ goreleaser_validate:
.goreleaser_base:
extends:
- .goreleaser_common
image: $[[ inputs.docker_hub_host ]]/docker:stable
image:
name: registry.gitlab.com/gitlab-com/gl-infra/common-ci-tasks-images/docker:latest
entrypoint: [""]
services:
- name: $[[ inputs.docker_hub_host ]]/docker:${DOCKER_VERSION}-dind
alias: docker
- $[[ inputs.docker_hub_host ]]/docker:dind
tags:
# Need to use DinD runners
- gitlab-org-docker
variables:
DOCKER_VERSION: "24.0.6" # Pinning due to https://github.com/docker-library/docker/issues/467
DOCKER_REGISTRY: $CI_REGISTRY
DOCKER_USERNAME: $CI_REGISTRY_USER
DOCKER_PASSWORD: $CI_REGISTRY_PASSWORD
# DOCKER_DRIVER: overlayfs
# DOCKER_HOST: tcp://docker:2376
# DOCKER_TLS_VERIFY: 1
DOCKER_TLS_CERTDIR: "/certs"
# DOCKER_CERT_PATH: "/certs/client"
# TEST_INTEGRATION_USE_SNAPSHOTTER: "true"
GIT_DEPTH: 0
GL_VERSION_YML_FILES: .gitlab-ci-asdf-versions.yml .gitlab-ci-other-versions.yml
 
# See https://goreleaser.com/ci/gitlab/ for documentation
script: |
docker info
mkdir -p "${GOMODCACHE}"
echo "Cache size at start:"
du -h -d0 "${GOMODCACHE}"
 
echo ".gomodcache" >> .dockerignore
mkdir -p /builds/shared
cat > /builds/shared/docker-creds.json <<-EOF
{
Loading
Loading
@@ -101,6 +115,15 @@ goreleaser_validate:
}
EOF
 
generate_build_args() {
for i in "$@"; do
if [[ -f $i ]]; then
yq --unwrapScalar '.variables|to_entries[]|"-e " + .key + "=" + .value + ""' "$i"
fi;
done
}
docker_version_build_args=$(generate_build_args $GL_VERSION_YML_FILES)
cat <<-EOD
----------------------------------------------------------
$GL_COMMON_CI_TASKS_GORELEASER_MESSAGE
Loading
Loading
@@ -125,6 +148,7 @@ goreleaser_validate:
-e GOTOOLCHAIN=go${GL_ASDF_GOLANG_VERSION} \
-e COSIGN_YES \
-e SIGSTORE_ID_TOKEN \
$docker_version_build_args \
${GORELEASER_DOCKER_EXTRA_ARGS:-} \
${GL_COMMON_CI_TASKS_GORELEASER_IMAGE} \
$GL_COMMON_CI_TASKS_GORELEASER_ARGUMENTS \
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment