Checking existing GoReleaser files using CUE
The easiest way to start with CUE’s validation is to check existing configuration files. By adding this check to your development or deployment process you can catch and fix errors before they affect downstream systems.
This guide shows you how to use the cue command to validate a GoReleaser
configuration file using
a curated module from the
CUE Central Registry. You don’t need to write any schemas or policies in CUE.
Choose a GoReleaser configuration file
This example is adapted from the
goreleaser/example
repository, but you should use any GoReleaser configuration file that’s
relevant to your situation.
project_name: example
builds:
- goos: [ linux, windows, darwin ]
goarch: [ amd64, arm64 ]
env:
- CGO_ENABLED=0
dockers:
- dockerfile: Dockerfile
image_templates:
- ghcr.io/goreleaser/example:{{ .Version }}
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/goreleaser/example
nfpms:
- formats: [ deb, rpm, apk ]
homepage: https://github.com/caarlos0/tasktimer
maintainer: Carlos A Becker <root@carlosbecker.dev>
description: Sample project.
license: MITValidate the configuration file
$ cue vet -c -d '#Project' cue.dev/x/goreleaser@latest goreleaser.ymlThis command uses the #Project definition from the goreleaser package to
check the goreleaser.yml file. Because cue vet doesn’t display any errors,
you know that the curated module has validated your configuration file.
If you see an error message mentioning “too many requests” then login to the Central Registry and re-run this command. The Central Registry allows more requests from authenticated users.
Next steps
Validating existing configuration files with CUE makes development and deployments safer, but defining them in CUE lets you build on its templating, referencing, and policy features. Take the first step with Getting started with GoReleaser + CUE …