Manual Release Beta Chart #21
Workflow file for this run
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
name: Manual Release Beta Chart | |
# Manual trigger only | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to use for the release (beta suffix will be automatically appended (e.g. "0.0.1" + "-beta"))' | |
required: false | |
default: '' | |
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 Insights Controller Dependencies | |
run: helm dependency update charts/cloudzero-insights-controller/ | |
- name: Package Insights Controller Chart | |
run: helm package charts/cloudzero-insights-controller/ --destination .deploy | |
- 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: Determine Version | |
- name: Get Github Tag Version | |
id: version | |
uses: flatherskevin/semver-action@v1 | |
with: | |
incrementLevel: patch | |
source: tags | |
- name: Determine Chart Version | |
run: | | |
NEW_VERSION=${{ github.event.inputs.version || steps.version.outputs.nextVersion }} | |
echo "NEW_VERSION=$NEW_VERSION-beta" >> $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: Update Chart Version for insights-controller | |
run: | | |
VERSION_LINE=$(awk '/version:/ && !done {print NR; done=1}' charts/cloudzero-insights-controller/Chart.yaml) | |
sed -i ''$VERSION_LINE's/.*/version: ${{ env.NEW_VERSION }}/' charts/cloudzero-insights-controller/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: Package Chart | |
run: | | |
helm package charts/cloudzero-agent/ --destination .deploy | |
helm package charts/cloudzero-insights-controller/ --destination .deploy | |
- 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 Insight Controller Chart as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: insights-controller-chart | |
path: .deploy/cloudzero-insights-controller-${{ env.NEW_VERSION }}.tgz | |
- 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: Move release Tarball | |
run: | | |
cp .deploy/cloudzero-insights-controller-${{ env.NEW_VERSION }}.tgz ./beta/ | |
cp .deploy/cloudzero-agent-${{ env.NEW_VERSION }}.tgz ./beta/ | |
rm -fr .deploy | |
- name: Update Index | |
run: helm repo index --url https://cloudzero.github.io/cloudzero-charts/beta ./beta/ | |
- name: Save Index in GH Pages | |
run: | | |
# copy the new chart and index.yaml | |
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 main -- 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 |