Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: match file names in helm registry index and release assets #1373

Merged
merged 4 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Odigos CLI
name: Release Odigos

on:
workflow_dispatch:
Expand Down Expand Up @@ -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

Expand All @@ -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
8 changes: 4 additions & 4 deletions helm/odigos/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 22 additions & 8 deletions scripts/release-charts.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
Loading