Skip to content

Commit a69dccc

Browse files
committed
ci: Convert Helm chart packaging/publishing to buildkite
1 parent 4880c41 commit a69dccc

File tree

4 files changed

+96
-152
lines changed

4 files changed

+96
-152
lines changed

.github/workflows/helm_release.yaml

Lines changed: 0 additions & 152 deletions
This file was deleted.

ci/builder/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ RUN curl -fsSL https://releases.hashicorp.com/terraform/1.9.8/terraform_1.9.8_li
382382
&& chmod +x /usr/local/bin/terraform \
383383
&& rm terraform.zip
384384

385+
RUN curl -fsSL https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_$ARCH_GO > yq \
386+
&& if [ $ARCH_GO = amd64 ]; then echo '654d2943ca1d3be2024089eb4f270f4070f491a0610481d128509b2834870049 yq' | sha256sum --check; fi \
387+
&& if [ $ARCH_GO = arm64 ]; then echo 'ceea73d4c86f2e5c91926ee0639157121f5360da42beeb8357783d79c2cc6a1d yq' | sha256sum --check; fi \
388+
&& chmod +x yq \
389+
&& mv yq /usr/local/bin
390+
385391
# Hardcode some known SSH hosts, or else SSH will ask whether the host is
386392
# trustworthy on the first connection.
387393

ci/test/pipeline.template.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@ steps:
158158
- exit_status: 1
159159
limit: 2
160160

161+
- id: helm-charts-publish
162+
label: Publish Helm Charts
163+
command: bin/ci-builder run stable misc/helm-charts/publish.sh
164+
timeout_in_minutes: 10
165+
inputs:
166+
- "*"
167+
depends_on: []
168+
agents:
169+
queue: linux-aarch64-small
170+
branches: main
171+
coverage: skip
172+
sanitizer: skip
173+
161174
- group: Lints
162175
key: lints
163176
steps:

misc/helm-charts/publish.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
# Copyright Materialize, Inc. and contributors. All rights reserved.
4+
#
5+
# Use of this software is governed by the Business Source License
6+
# included in the LICENSE file at the root of this repository.
7+
#
8+
# As of the Change Date specified in that file, in accordance with
9+
# the Business Source License, use of this software will be governed
10+
# by the Apache License, Version 2.0.
11+
12+
set -euo pipefail
13+
14+
. misc/shlib/shlib.bash
15+
16+
CHARTS_DIR=misc/helm-charts
17+
GITHUB_PAGES_BRANCH=gh-pages
18+
RELEASE_DIR=.cr-release-packages
19+
20+
# Find directories containing Chart.yaml
21+
CHARTS=""
22+
for dir in "$CHARTS_DIR"/*/; do
23+
if [ -f "${dir}Chart.yaml" ]; then
24+
chart_name=$(basename "$dir")
25+
CHARTS="${CHARTS:+${CHARTS} }$chart_name"
26+
fi
27+
done
28+
if [ -z "$CHARTS" ]; then
29+
echo "No valid Helm charts found"
30+
exit 0
31+
fi
32+
echo "Found valid charts: $CHARTS"
33+
34+
rm -rf gh-pages
35+
git clone --branch $GITHUB_PAGES_BRANCH --depth 1 https://$GITHUB_TOKEN@github.com/MaterializeInc/materialize.git gh-pages
36+
37+
mkdir -p $RELEASE_DIR
38+
CHANGES_MADE=0
39+
for CHART in $CHARTS; do
40+
CHART_PATH="$CHARTS_DIR/$CHART"
41+
VERSION=$(yq eval '.version' "$CHART_PATH"/Chart.yaml)
42+
echo "Processing chart: $CHART version: $VERSION"
43+
# Check if version already exists
44+
if [ -f "gh-pages/$CHART-$VERSION.tgz" ]; then
45+
echo "Chart $CHART version $VERSION already exists, skipping"
46+
continue
47+
fi
48+
# Lint chart
49+
if ! helm lint "$CHART_PATH"; then
50+
echo "Linting failed for $CHART"
51+
exit 1
52+
fi
53+
# Package chart
54+
helm package "$CHART_PATH" --destination $RELEASE_DIR
55+
CHANGES_MADE=1
56+
done
57+
# Only proceed if we have new packages
58+
if [ $CHANGES_MADE -eq 1 ]; then
59+
# Copy new charts to gh-pages
60+
cp $RELEASE_DIR/*.tgz gh-pages/
61+
# Update the repository index
62+
cd gh-pages
63+
REPO_URL="https://materialize.github.io/materialize"
64+
if [ -f index.yaml ]; then
65+
helm repo index . --url "$REPO_URL" --merge index.yaml
66+
else
67+
helm repo index . --url "$REPO_URL"
68+
fi
69+
# Commit and push changes
70+
git add .
71+
git config user.email "[email protected]"
72+
git config user.name "Buildkite"
73+
git commit -m "helm-charts: publish updated charts"
74+
git push origin $GITHUB_PAGES_BRANCH
75+
else
76+
echo "No new chart versions to publish"
77+
fi

0 commit comments

Comments
 (0)