Skip to content

Make Goreleaser play nicely with truncated versions

Background

In Create a semantic-release plugin for managing t... (gitlab-com/gl-infra/platform/runway/team#480 - closed) we're making it easier to create truncated versions. For example, when releasing v1.4.3 we'll also create the v1.4 tag. This allows us to reduce Renovate MRs by only creating an MR when the minor version changes and not for every patch release.

This causes problems with goreleaser. When running on the v1.4 tag, goreleaser will use the Git commit to discover the version it's running on and will find the v1.4.3 tag. Since goreleaser is also running on the v1.4.3 tag, this creates a race between the two jobs with errors like Url has already been taken, Name has already been taken, Filepath has already been taken.

Solution

  • Change the rules in common-ci-tasks/goreleaser.yml so goreleaser only runs on semantic version tags, e.g. v1.4.3. This solves the race.
  • Change the .goreleaser.yml template in common-template-copier to also publish the truncated tag to the container registry.

Alternatives Considered

  • Running goreleaser on truncated tags but with --skip-publish flag: Rejected because it still builds assets unnecessarily
  • Creating a separate job to copy/tag container images after deployment: Adds complexity and potential race conditions
  • Override goreleaser's tag selection (documentation): Causes each commit to be built multiple times, causing the truncated and full tags to have different checksums
Edited by Florian Forster