#!/bin/sh set -eu description=$(git describe --tags --long --match 'v[0-9]*' --dirty) case "$description" in *-dirty) echo "refusing to package a dirty tree" >&2; exit 1 ;; esac version=${description#v} case "$version" in *-0-g*) version=${version%%-0-g*} ;; esac # Upstream uses four numeric components (for example v1.0.39.0), whereas # Helm chart versions must be SemVer. Keep the upstream Git tag verbatim and # encode its fourth component as a SemVer prerelease identifier. version=$(printf '%s\n' "$version" | sed -E 's/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(-.*)?$/\1.\2.\3-\4\5/') printf '%s\n' "$version"