nebula-plugins / nebula-plugins/nebula-release-plugin

sanitizeVersion breaks helm lint because it's not semver compliant

Open
#258 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Groovy
Stars
236
Forks
60
Avg merge
10m
Merged PRs (30d)
4

Description

use case:
build and release docker images and helm charts

the issue:
Because docker tags won't accept the + symbol, I added the sanitizeVersion property

-Prelease.sanitizeVersion=true 

This replaces the + symbol with the . symbol creating a new pre-release identifier.
example from the readme:

This will generate a version string similar to: 0.1.0-dev.2.e1c43c7

The last pre-release component ( e1c43c7 ) is the shortened hash of the revision being built.

According to https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions, each of the dot-separated pre-release components should be an alphanumeric string or a number starting with a positive-digit.

So, in the event of a revision hash that has digits only and it is starting with a 0, the version created by this plugin is not SemVer compliant. ( the probability of this happening is circa 0.4%)

And apparently Helm lint is very strict about this.

[ERROR] Chart.yaml: version '1.351.0-dev.21.pr.489.0303690' is not a valid SemVer

the solution:
prepending or appending a character to the shortened revision hash could be very confusing (as it could easily be mistaken for a character of the hash).
Maybe prepending something like rev- to have 1.351.0-dev.21.pr.489.rev-0303690 could work?
(note that the symbol - is a valid non-digit in the grammar)

However I'm not sure if this could break some other use cases, so maybe we need a breaking-change or a new property to adopt this behaviour?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the sanitizeVersion property through the version-generation path; no source file or test is named in the issue. Reproduce the digits-only revision-hash case and run Helm lint against the generated Chart.yaml. Done means the generated version is valid SemVer while the compatibility impact of changing the hash format is understood.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, groovy, helm
Domain
build-system, release
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.