-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Convert Helm chart packaging/publishing to buildkite
- Loading branch information
Showing
4 changed files
with
92 additions
and
152 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |