Skip to content

Commit de2dc35

Browse files
EliShteinmanclaude
andcommitted
feat(ci): opt-in Helm chart publish in airgap-build workflow
Adds workflow_dispatch input `publish_chart` (default false). When true and the run is a full build (variant=both, platforms=both, no tag_override), a new phase 5 runs after the image push and: 1. Reads the old appVersion + chart version from Chart.yaml 2. Auto-bumps the chart patch version (X.Y.Z -> X.Y.(Z+1)) and replaces the old HASH with the new HASH across Chart.yaml, examples/values-openshift-airgapped.yaml, README.md, README-he.md 3. Commits as github-actions[bot] with "chore(helm): bump chart X.Y.Z, appVersion <HASH>" and pushes 4. helm package + helm push to oci://registry-1.docker.io/<user> 5. Writes a summary section with version delta and install command Patch-only by design — non-patch bumps remain manual per BUILD.md step 5 (the user opts out by leaving publish_chart=false and runs the chart push by hand). Skipped automatically on partial builds and override tags since those are testing flows that should not produce a chart release. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f11328a commit de2dc35

1 file changed

Lines changed: 140 additions & 0 deletions

File tree

.github/workflows/airgap-build.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ on:
4141
normal builds.
4242
type: string
4343
default: ''
44+
publish_chart:
45+
description: >-
46+
After the image push, also auto-bump the Helm chart (patch version
47+
+ appVersion -> new HASH), commit to this branch, and push the
48+
chart as OCI artifact. Only runs on full builds (variant=both,
49+
platforms=both, no tag_override). For non-patch bumps build the
50+
chart manually.
51+
type: boolean
52+
default: false
4453

4554
env:
4655
REPO: a0533057932/redis-docs
@@ -794,3 +803,134 @@ jobs:
794803
echo '```'
795804
fi
796805
} >> "$GITHUB_STEP_SUMMARY"
806+
807+
# =========================================================================
808+
# Phase 5: publish_chart — opt-in. Auto-bump Helm chart patch + appVersion,
809+
# commit to this branch, package and push the chart as an OCI artifact.
810+
# Only on full builds. For non-patch bumps, build the chart manually.
811+
# =========================================================================
812+
publish_chart:
813+
name: 5. Publish Helm chart (opt-in)
814+
needs: [setup, docker]
815+
if: >-
816+
inputs.publish_chart == true &&
817+
inputs.variant == 'both' &&
818+
inputs.platforms == 'both' &&
819+
inputs.tag_override == ''
820+
runs-on: ubuntu-24.04
821+
permissions:
822+
contents: write
823+
steps:
824+
- uses: actions/checkout@v4
825+
with:
826+
ref: ${{ github.ref }}
827+
# default GITHUB_TOKEN has write perms on this repo; no PAT needed
828+
token: ${{ secrets.GITHUB_TOKEN }}
829+
830+
- name: Bump chart files
831+
id: bump
832+
env:
833+
NEW_HASH: ${{ needs.setup.outputs.hash }}
834+
run: |
835+
set -euo pipefail
836+
CHART=helm/redis-docs/Chart.yaml
837+
838+
OLD_VERSION=$(grep '^version:' "$CHART" | awk '{print $2}')
839+
OLD_HASH=$(grep '^appVersion:' "$CHART" | sed -E 's/.*"([^"]+)".*/\1/')
840+
841+
if [ "$OLD_HASH" = "$NEW_HASH" ]; then
842+
echo "appVersion already $NEW_HASH — nothing to bump" >&2
843+
echo "changed=false" >> "$GITHUB_OUTPUT"
844+
exit 0
845+
fi
846+
847+
# Auto-bump patch (X.Y.Z -> X.Y.(Z+1))
848+
IFS=. read -r MAJ MIN PATCH <<<"$OLD_VERSION"
849+
NEW_VERSION="$MAJ.$MIN.$((PATCH + 1))"
850+
851+
# Replace HASH everywhere (covers Chart.yaml appVersion + tag refs)
852+
sed -i "s|${OLD_HASH}|${NEW_HASH}|g" \
853+
helm/redis-docs/Chart.yaml \
854+
helm/redis-docs/examples/values-openshift-airgapped.yaml \
855+
helm/redis-docs/README.md \
856+
helm/redis-docs/README-he.md
857+
858+
# Bump chart version
859+
sed -i "s/^version: .*/version: ${NEW_VERSION}/" "$CHART"
860+
861+
{
862+
echo "old_version=$OLD_VERSION"
863+
echo "new_version=$NEW_VERSION"
864+
echo "old_hash=$OLD_HASH"
865+
echo "new_hash=$NEW_HASH"
866+
echo "changed=true"
867+
} >> "$GITHUB_OUTPUT"
868+
869+
- name: Commit & push
870+
if: steps.bump.outputs.changed == 'true'
871+
env:
872+
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
873+
NEW_HASH: ${{ steps.bump.outputs.new_hash }}
874+
run: |
875+
set -euo pipefail
876+
git config user.name "github-actions[bot]"
877+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
878+
git add helm/
879+
git commit -m "chore(helm): bump chart ${NEW_VERSION}, appVersion ${NEW_HASH}"
880+
git push
881+
882+
- name: Install Helm
883+
if: steps.bump.outputs.changed == 'true'
884+
uses: azure/setup-helm@v4
885+
886+
- name: Helm registry login
887+
if: steps.bump.outputs.changed == 'true'
888+
env:
889+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
890+
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
891+
run: |
892+
echo "$DOCKERHUB_TOKEN" | helm registry login \
893+
-u "$DOCKERHUB_USERNAME" --password-stdin registry-1.docker.io
894+
895+
- name: Package & push chart
896+
if: steps.bump.outputs.changed == 'true'
897+
id: chart_push
898+
env:
899+
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
900+
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
901+
run: |
902+
set -euo pipefail
903+
helm package helm/redis-docs/ -d /tmp/
904+
helm push "/tmp/redis-docs-${NEW_VERSION}.tgz" \
905+
"oci://registry-1.docker.io/${DOCKERHUB_USERNAME}"
906+
907+
- name: Write chart summary
908+
if: always()
909+
env:
910+
STATUS: ${{ job.status }}
911+
CHANGED: ${{ steps.bump.outputs.changed }}
912+
OLD_VERSION: ${{ steps.bump.outputs.old_version }}
913+
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
914+
NEW_HASH: ${{ steps.bump.outputs.new_hash }}
915+
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
916+
run: |
917+
{
918+
echo ""
919+
echo "## Helm chart publish: \`$STATUS\`"
920+
echo ""
921+
if [ "$CHANGED" != "true" ]; then
922+
echo "Chart appVersion was already up to date — nothing pushed."
923+
else
924+
echo "| Field | Value |"
925+
echo "|-------|-------|"
926+
echo "| version | \`$OLD_VERSION\` -> \`$NEW_VERSION\` |"
927+
echo "| appVersion | \`$NEW_HASH\` |"
928+
echo "| OCI ref | \`oci://registry-1.docker.io/$DOCKERHUB_USERNAME/redis-docs:$NEW_VERSION\` |"
929+
echo ""
930+
echo "### Install"
931+
echo '```bash'
932+
echo "helm install <release> oci://registry-1.docker.io/$DOCKERHUB_USERNAME/redis-docs \\"
933+
echo " --version $NEW_VERSION --set route.enabled=true"
934+
echo '```'
935+
fi
936+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)