191 lines
7.2 KiB
YAML
191 lines
7.2 KiB
YAML
# This workflow publishes the Helm chart to R2 when we tag a release.
|
|
name: Publish Helm chart
|
|
|
|
permissions: {}
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
release:
|
|
types: [released]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
publish-helm-chart:
|
|
name: Publish Helm chart to R2
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
if: github.repository == 'tensorzero/tensorzero'
|
|
permissions:
|
|
contents: read # Required for checkout or repository metadata reads.
|
|
# Required secrets:
|
|
# - HELM_PUBLISH_ACCESS_KEY_ID: Cloudflare R2 access key ID
|
|
# - HELM_PUBLISH_SECRET_ACCESS_KEY: Cloudflare R2 secret access key
|
|
# Required variables:
|
|
# - R2_ENDPOINT_URL: Cloudflare R2 endpoint URL (e.g., https://ACCOUNT_ID.r2.cloudflarestorage.com)
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up Helm
|
|
uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
|
|
with:
|
|
version: "latest"
|
|
|
|
- name: Extract version from Cargo.toml
|
|
id: version
|
|
run: |
|
|
echo "=== Extracting version from Cargo.toml ==="
|
|
echo "Current directory: $(pwd)"
|
|
echo "Cargo.toml contents (first 30 lines):"
|
|
head -30 crates/Cargo.toml
|
|
echo ""
|
|
echo "Looking for version line..."
|
|
# Extract version from Cargo.toml workspace.package section
|
|
VERSION=$(grep -E '^version = ' crates/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
|
|
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
|
|
echo "Extracted version: ${VERSION}"
|
|
echo "========================="
|
|
|
|
- name: Update Chart.yaml version
|
|
env:
|
|
VERSION: ${{ steps.version.outputs.VERSION }}
|
|
run: |
|
|
cd examples/production-deployment-k8s-helm
|
|
echo "=== Updating Chart.yaml ==="
|
|
echo "Current directory: $(pwd)"
|
|
echo ""
|
|
echo "Chart.yaml BEFORE updates:"
|
|
echo "----------------------------"
|
|
cat Chart.yaml
|
|
echo "----------------------------"
|
|
echo ""
|
|
# Update the version field in Chart.yaml
|
|
sed -i "s/^version:.*/version: ${VERSION}/" Chart.yaml
|
|
# Update the appVersion field in Chart.yaml to match
|
|
sed -i "s/^appVersion:.*/appVersion: \"${VERSION}\"/" Chart.yaml
|
|
echo "Chart.yaml AFTER updates:"
|
|
echo "----------------------------"
|
|
cat Chart.yaml
|
|
echo "----------------------------"
|
|
echo "========================="
|
|
|
|
- name: Package Helm chart
|
|
run: |
|
|
cd examples/production-deployment-k8s-helm
|
|
echo "=== Packaging Helm chart ==="
|
|
echo "Current directory: $(pwd)"
|
|
echo ""
|
|
echo "Files in directory before packaging:"
|
|
ls -la
|
|
echo ""
|
|
helm package .
|
|
echo ""
|
|
echo "Files in directory after packaging:"
|
|
ls -la
|
|
echo ""
|
|
echo "Package details:"
|
|
for pkg in tensorzero-*.tgz; do
|
|
if [ -f "$pkg" ]; then
|
|
echo " Package: $pkg"
|
|
echo " Size: $(ls -lh $pkg | awk '{print $5}')"
|
|
echo " MD5: $(md5sum $pkg | awk '{print $1}')"
|
|
echo " SHA256: $(sha256sum $pkg | awk '{print $1}')"
|
|
echo ""
|
|
echo " Package contents:"
|
|
tar -tzf "$pkg" | head -20
|
|
echo " ..."
|
|
fi
|
|
done
|
|
echo "========================="
|
|
|
|
- name: Configure AWS CLI for R2
|
|
env:
|
|
R2_ACCESS_KEY_ID: ${{ secrets.HELM_PUBLISH_ACCESS_KEY_ID }}
|
|
R2_ENDPOINT_URL: ${{ vars.R2_ENDPOINT_URL }}
|
|
R2_SECRET_ACCESS_KEY: ${{ secrets.HELM_PUBLISH_SECRET_ACCESS_KEY }}
|
|
run: |
|
|
echo "=== Configuring AWS CLI for R2 ==="
|
|
echo "R2 endpoint: $R2_ENDPOINT_URL"
|
|
aws configure set aws_access_key_id "$R2_ACCESS_KEY_ID"
|
|
aws configure set aws_secret_access_key "$R2_SECRET_ACCESS_KEY"
|
|
aws configure set default.region auto
|
|
aws configure set default.s3.signature_version s3v4
|
|
echo "AWS CLI configured"
|
|
echo "========================="
|
|
|
|
- name: Download existing index.yaml
|
|
continue-on-error: true
|
|
env:
|
|
R2_ENDPOINT_URL: ${{ vars.R2_ENDPOINT_URL }}
|
|
run: |
|
|
cd examples/production-deployment-k8s-helm
|
|
echo "=== Downloading existing index.yaml from R2 ==="
|
|
echo "Current directory: $(pwd)"
|
|
echo "R2 endpoint: $R2_ENDPOINT_URL"
|
|
echo ""
|
|
# Try to download existing index.yaml from R2
|
|
if aws s3 cp s3://tensorzero-helm-charts/index.yaml ./existing-index.yaml \
|
|
--endpoint-url "$R2_ENDPOINT_URL"; then
|
|
echo "Successfully downloaded existing index.yaml"
|
|
echo ""
|
|
echo "Existing index.yaml contents:"
|
|
echo "----------------------------"
|
|
cat existing-index.yaml
|
|
echo "----------------------------"
|
|
else
|
|
echo "No existing index.yaml found (this is normal for first run)"
|
|
fi
|
|
echo "========================="
|
|
|
|
- name: Generate index.yaml
|
|
run: |
|
|
cd examples/production-deployment-k8s-helm
|
|
echo "=== Generating index.yaml ==="
|
|
echo "Current directory: $(pwd)"
|
|
echo ""
|
|
echo "Package files present:"
|
|
ls -la tensorzero-*.tgz 2>/dev/null || echo "No package files found"
|
|
echo ""
|
|
if [ -f existing-index.yaml ]; then
|
|
echo "Merging with existing index.yaml"
|
|
helm repo index . --url https://helm.tensorzero.com --merge existing-index.yaml
|
|
else
|
|
echo "Creating new index.yaml (no existing index to merge)"
|
|
helm repo index . --url https://helm.tensorzero.com
|
|
fi
|
|
echo ""
|
|
echo "Generated index.yaml contents:"
|
|
echo "----------------------------"
|
|
cat index.yaml
|
|
echo "----------------------------"
|
|
echo ""
|
|
echo "index.yaml file details:"
|
|
echo " Size: $(ls -lh index.yaml | awk '{print $5}')"
|
|
echo " Lines: $(wc -l < index.yaml)"
|
|
echo " MD5: $(md5sum index.yaml | awk '{print $1}')"
|
|
echo "========================="
|
|
|
|
- name: Upload chart package to R2
|
|
env:
|
|
R2_ENDPOINT_URL: ${{ vars.R2_ENDPOINT_URL }}
|
|
run: |
|
|
cd examples/production-deployment-k8s-helm
|
|
CHART_FILE=$(ls tensorzero-*.tgz)
|
|
aws s3 cp "${CHART_FILE}" "s3://tensorzero-helm-charts/${CHART_FILE}" \
|
|
--endpoint-url "$R2_ENDPOINT_URL"
|
|
echo "Uploaded ${CHART_FILE} to R2"
|
|
|
|
- name: Upload index.yaml to R2
|
|
env:
|
|
R2_ENDPOINT_URL: ${{ vars.R2_ENDPOINT_URL }}
|
|
run: |
|
|
cd examples/production-deployment-k8s-helm
|
|
aws s3 cp index.yaml s3://tensorzero-helm-charts/index.yaml \
|
|
--endpoint-url "$R2_ENDPOINT_URL"
|
|
echo "Uploaded index.yaml to R2"
|