Skip to content

Commit

Permalink
ci: Convert Helm chart packaging/publishing to buildkite
Browse files Browse the repository at this point in the history
  • Loading branch information
def- committed Jan 18, 2025
1 parent fda2d21 commit 9265135
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 152 deletions.
152 changes: 0 additions & 152 deletions .github/workflows/helm_release.yaml

This file was deleted.

1 change: 1 addition & 0 deletions ci/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ RUN apt-get update --fix-missing && TZ=UTC DEBIAN_FRONTEND=noninteractive apt-ge
unzip \
xz-utils \
yamllint \
yq \
zstd \
&& rm -rf /var/lib/apt/lists/*

Expand Down
14 changes: 14 additions & 0 deletions ci/test/pipeline.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ steps:
- exit_status: 1
limit: 2

- id: helm-charts-publish
label: Publish Helm Charts
command: bin/ci-builder run stable misc/helm-charts/publish.sh
timeout_in_minutes: 10
inputs:
- "*"
depends_on: []
agents:
queue: linux-aarch64-small
# TODO: Uncomment before merging
#branches: main
coverage: skip
sanitizer: skip

- group: Lints
key: lints
steps:
Expand Down
77 changes: 77 additions & 0 deletions misc/helm-charts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

set -euo pipefail

. misc/shlib/shlib.bash

CHARTS_DIR=misc/helm-charts
# TODO: Switch back to gh-pages before merging
# GITHUB_PAGES_BRANCH=gh-pages
GITHUB_PAGES_BRANCH=gh-pages-test
RELEASE_DIR=.cr-release-packages

# Find directories containing Chart.yaml
CHARTS=""
for dir in "$CHARTS_DIR"/*/; do
if [ -f "${dir}Chart.yaml" ]; then
chart_name=$(basename "$dir")
CHARTS="${CHARTS:+${CHARTS} }$chart_name"
fi
done
if [ -z "$CHARTS" ]; then
echo "No valid Helm charts found"
exit 0
fi
echo "Found valid charts: $CHARTS"

git fetch origin
git checkout $GITHUB_PAGES_BRANCH

mkdir -p $RELEASE_DIR
CHANGES_MADE=0
for CHART in $CHARTS; do
CHART_PATH="$CHARTS_DIR/$CHART"
VERSION=$(yq eval '.version' "$CHART_PATH"/Chart.yaml)
echo "Processing chart: $CHART version: $VERSION"
# Check if version already exists
if [ -f "gh-pages/$CHART-$VERSION.tgz" ]; then
echo "Chart $CHART version $VERSION already exists, skipping"
continue
fi
# Lint chart
if ! helm lint "$CHART_PATH"; then
echo "Linting failed for $CHART"
exit 1
fi
# Package chart
helm package "$CHART_PATH" --destination $RELEASE_DIR
CHANGES_MADE=1
done
# Only proceed if we have new packages
if [ $CHANGES_MADE -eq 1 ]; then
# Copy new charts to gh-pages
cp $RELEASE_DIR/*.tgz gh-pages/
# Update the repository index
cd gh-pages
REPO_URL="https://materialize.github.io/materialize"
if [ -f index.yaml ]; then
helm repo index . --url "$REPO_URL" --merge index.yaml
else
helm repo index . --url "$REPO_URL"
fi
# Commit and push changes
git add .
git commit -m "helm-charts: publish updated charts"
git push origin $GITHUB_PAGES_BRANCH
else
echo "No new chart versions to publish"
fi

0 comments on commit 9265135

Please sign in to comment.