@@ -33,21 +33,26 @@ jobs:
3333 run : helm lint charts/kvm-node-agent
3434 - name : Package Helm Chart
3535 run : |
36+ APP_VERSION=""
37+ # use version from the helm chart itself as a base
38+ VERSION="$(helm show chart charts/kvm-node-agent | grep -E "^version:" | awk '{print $2}')"
3639 # try to detect a version from the git tags, set APP_VERSION only if this commit has been tagged
37- APP_VERSION=$(git describe --tags --exact-match ${{ github.sha }} 2>/dev/null || echo "")
38- if [ -n "$APP_VERSION" ]; then
39- VERSION=$(echo -n "$APP_VERSION" | sed -E 's/^v//')
40- else
41- VERSION=$((git describe --tags --abbrev=0 2>/dev/null | sed -E 's/^v//') || echo "")
40+ CURRENT_TAG=$(git describe --tags --exact-match ${{ github.sha }} 2>/dev/null || echo "")
41+ LAST_TAG=$((git describe --tags --abbrev=0 2>/dev/null | sed -E 's/^v//') || echo "")
42+ if [ -n "$CURRENT_TAG" ]; then
43+ APP_VERSION="$CURRENT_TAG"
44+ VERSION=$(echo -n "$CURRENT_TAG" | sed -E 's/^v//')
45+ elif [ -n "$LAST_TAG" ]; then
46+ VERSION="$LAST_TAG"
4247 fi
4348
44- # use the git sha as app-version, if no version could be detected from the tags
49+ # use the git sha as app-version if no version could be detected from the tags
4550 if [ -z "$APP_VERSION" ]; then
46- APP_VERSION=$(echo -n "sha-${{ github.sha }}")
51+ APP_VERSION="sha-${{ github.sha }}"
4752 fi
48- # use the git sha as helm version suffix, version is semver
49- if [ -z "$VERSION" ] && [ -n "$APP_VERSION" ]; then
50- VERSION="$(helm show chart charts/kvm-node-agent | grep -E "^version:" | awk '{print $2}' ) +${APP_VERSION:0:11}"
53+ # append truncated sha to version for uniqueness on untagged commits
54+ if [[ "$APP_VERSION" == sha-* ] ]; then
55+ VERSION="$VERSION +${APP_VERSION:0:11}"
5156 fi
5257
5358 HELM_ARGS=--dependency-update
0 commit comments