diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52a05aef1..80ccc3279 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release Odigos CLI +name: Release Odigos on: workflow_dispatch: @@ -137,6 +137,7 @@ jobs: echo "TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV else echo "Unknown event type" + echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV exit 1 fi @@ -156,4 +157,6 @@ jobs: version: v3.15.2 - name: Release Helm charts - run: sh ./scripts/release-charts.sh + env: + GH_TOKEN: ${{ github.token }} + run: bash ./scripts/release-charts.sh diff --git a/helm/odigos/Chart.yaml b/helm/odigos/Chart.yaml index 574dc984e..d3f93b350 100644 --- a/helm/odigos/Chart.yaml +++ b/helm/odigos/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: odigos -description: Odigos Helm Chart for Kubernetes +description: Odigos distribution for Kubernetes type: application -# v0.0.0 will be replaced by the git tag version on release -version: "v0.0.0" -appVersion: "v0.0.0" +# 0.0.0 will be replaced by the git tag version on release +version: "0.0.0" +appVersion: "0.0.0" icon: https://d2q89wckrml3k4.cloudfront.net/logo.png diff --git a/scripts/release-charts.sh b/scripts/release-charts.sh old mode 100644 new mode 100755 index 443a4824b..04ece9bd8 --- a/scripts/release-charts.sh +++ b/scripts/release-charts.sh @@ -1,8 +1,17 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # Setup TMPDIR="$(mktemp -d)" -CHARTDIR="helm/odigos" +CHARTDIRS=("helm/odigos") + +prefix () { + echo "${@:1}" + echo "${@:2}" + for i in "${@:2}"; do + echo "Renaming $i to $1$i" + mv "$i" "$1$i" + done +} if [ -z "$TAG" ]; then echo "TAG required" @@ -14,7 +23,7 @@ if [ -z "$GITHUB_REPOSITORY" ]; then exit 1 fi -if [[ $(git diff -- $CHARTDIR | wc -c) -ne 0 ]]; then +if [[ $(git diff -- ${CHARTDIRS[*]} | wc -c) -ne 0 ]]; then echo "Helm chart dirty. Aborting." exit 1 fi @@ -24,16 +33,21 @@ helm repo add odigos https://odigos-io.github.io/odigos-charts 2> /dev/null || t git worktree add $TMPDIR gh-pages -f # Update index with new packages -sed -i -E 's/v0.0.0/'"${TAG}"'/' $CHARTDIR/Chart.yaml -helm package helm/* -d $TMPDIR +for chart in "${CHARTDIRS[@]}" +do + echo "Updating $chart/Chart.yaml with version ${TAG#v}" + sed -i -E 's/0.0.0/'"${TAG#v}"'/' $chart/Chart.yaml +done +helm package ${CHARTDIRS[*]} -d $TMPDIR pushd $TMPDIR +prefix 'test-helm-assets-' *.tgz helm repo index . --merge index.yaml --url https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG/ +git diff -G apiVersion # The check avoids pushing the same tag twice and only pushes if there's a new entry in the index if [[ $(git diff -G apiVersion | wc -c) -ne 0 ]]; then # Upload new packages - rename 'odigos' 'test-helm-assets-odigos' *.tgz - gh release upload -R $GITHUB_REPOSITORY $TAG $TMPDIR/*.tgz + gh release upload -R $GITHUB_REPOSITORY $TAG $TMPDIR/*.tgz || exit 1 git add index.yaml git commit -m "update index with $TAG" && git push @@ -45,5 +59,5 @@ else fi # Roll back chart version changes -git checkout $CHARTDIR +git checkout ${CHARTDIRS[*]} git worktree remove $TMPDIR -f || echo " -> Failed to clean up temp worktree"