Skip to content

Manual Release Beta Chart #29

Manual Release Beta Chart

Manual Release Beta Chart #29

name: Manual Release Beta Chart
# Manual trigger only
on:
workflow_dispatch:
inputs:
version:
description: 'Version to use for the release. Must contain "beta" (e.g. "0.0.1-beta").'
required: true
branch:
description: 'Branch to use for the release'
required: true
jobs:
build-and-publish-beta-chart:
environment: release
permissions:
contents: 'write'
packages: 'write'
id-token: write
actions: 'read'
runs-on: ubuntu-latest
steps:
# Step 1: Checkout and Setup
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
- name: Set up Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "Automated CZ Release"
- name: Fetch All Branches
run: git fetch --all
# Step 2: Helm Setup
- name: Install Helm
uses: azure/setup-helm@v3
- name: Build Cloudzero Agent Dependencies
run: helm dependency update charts/cloudzero-agent/
- name: Package Cloudzero Agent Chart
run: helm package charts/cloudzero-agent/ --destination .deploy
# Step 3: Validate and Set Version
- name: Validate Input Version
run: |
if [[ -z "${{ github.event.inputs.version }}" ]]; then
echo "Version input is required."
exit 1
fi
if [[ "${{ github.event.inputs.version }}" != *"beta"* ]]; then
echo "Version must contain 'beta'. Provided version: ${{ github.event.inputs.version }}"
exit 1
fi
echo "NEW_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Update Chart Version
run: |
VERSION_LINE=$(awk '/version:/ && !done {print NR; done=1}' charts/cloudzero-agent/Chart.yaml)
sed -i ''$VERSION_LINE's/.*/version: ${{ env.NEW_VERSION }}/' charts/cloudzero-agent/Chart.yaml
- name: Validate Release Notes are Present
run: |
if [ ! -f "charts/cloudzero-agent/docs/releases/${{ env.NEW_VERSION }}.md" ]; then
echo "Release notes for ${{ env.NEW_VERSION }} are missing. Please create a release notes file at docs/releases/${{ env.NEW_VERSION }}.md"
exit 1
fi
# Step 4: Package and Commit Chart
- name: Commit updated Chart.yaml
run: |
git add .
git commit -m "Update Chart.yaml to version ${{ env.NEW_VERSION }}"
git push origin ${{ github.event.inputs.branch }}
COMMIT_HASH=$(git rev-parse HEAD)
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
continue-on-error: true
# Step 7: Handle Artifacts and Update Pages
- name: Upload Cloudzero Agent Chart as Artifact
uses: actions/upload-artifact@v4
with:
name: agent-chart
path: .deploy/cloudzero-agent-${{ env.NEW_VERSION }}.tgz
- name: Checkout GH Pages
run: |
git checkout -f gh-pages
- name: Update Index
run: helm repo index --url https://cloudzero.github.io/cloudzero-charts/beta ./beta/
- name: Save Index in GH Pages
run: |
git add beta
git commit -m "Updating ${{ env.NEW_VERSION }} Index"
git push origin gh-pages
continue-on-error: true
- name: Update Docs for GH Pages
run: |
# cleanup garbage files
rm -fr .deploy charts/cloudzero-agent/charts
git reset --hard
# now checkout docs from main
git checkout ${{ github.event.inputs.branch }} -- charts/cloudzero-agent/docs charts/cloudzero-agent/README.md README.md
git add README.md charts/cloudzero-agent/docs charts/cloudzero-agent/README.md
git commit -m "Update docs for ${{ env.NEW_VERSION }}"
git push origin gh-pages
continue-on-error: true
# Step 5: Create GitHub Release
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.NEW_VERSION }}
tag_name: ${{ env.NEW_VERSION }}
files: .deploy/cloudzero-agent-${{ env.NEW_VERSION }}.tgz
make_latest: false
target_commitish: ${{ env.COMMIT_HASH }}
body_path: ${{ github.workspace }}/charts/cloudzero-agent/docs/releases/${{ env.NEW_VERSION }}.md