Skip to content

Commit 4c23e97

Browse files
Xunzhuoszedan-rh
authored andcommitted
ci(helm): add workflow to publish Helm chart to GHCR on merge (vllm-project#649)
1 parent eda54d1 commit 4c23e97

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

.github/workflows/helm-publish.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Publish Helm Chart
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'deploy/helm/**'
9+
- '.github/workflows/helm-publish.yml'
10+
workflow_dispatch:
11+
12+
env:
13+
HELM_VERSION: v3.14.0
14+
CHART_PATH: deploy/helm/semantic-router
15+
REGISTRY: ghcr.io
16+
CHART_NAME: semantic-router
17+
18+
jobs:
19+
publish-chart:
20+
name: Publish Helm Chart to GHCR
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Helm
30+
uses: azure/setup-helm@v4
31+
with:
32+
version: ${{ env.HELM_VERSION }}
33+
34+
- name: Set lowercase repository owner
35+
run: echo "REPOSITORY_OWNER_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
36+
37+
- name: Log in to GitHub Container Registry
38+
run: |
39+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.REGISTRY }} --username ${{ github.actor }} --password-stdin
40+
41+
- name: Modify chart version to latest
42+
run: |
43+
echo "::group::Modify Chart.yaml"
44+
# Backup original Chart.yaml
45+
cp ${{ env.CHART_PATH }}/Chart.yaml ${{ env.CHART_PATH }}/Chart.yaml.bak
46+
47+
# Replace version with 'v0.0.0-latest' (valid semver with prerelease tag)
48+
sed -i 's/^version:.*/version: v0.0.0-latest/' ${{ env.CHART_PATH }}/Chart.yaml
49+
50+
echo "Modified Chart.yaml:"
51+
grep '^version:' ${{ env.CHART_PATH }}/Chart.yaml
52+
echo "::endgroup::"
53+
54+
- name: Package Helm chart
55+
run: |
56+
echo "::group::Package Chart"
57+
mkdir -p ./dist
58+
helm package ${{ env.CHART_PATH }} --destination ./dist
59+
echo "::endgroup::"
60+
61+
echo "::group::Packaged Chart"
62+
ls -lh ./dist/
63+
echo "::endgroup::"
64+
65+
- name: Push chart to GHCR
66+
run: |
67+
echo "::group::Push to GHCR"
68+
CHART_PACKAGE="./dist/${{ env.CHART_NAME }}-v0.0.0-latest.tgz"
69+
70+
# Push to GHCR using OCI format with v0.0.0-latest tag
71+
helm push "${CHART_PACKAGE}" oci://${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER_LOWER }}/charts
72+
73+
echo "::endgroup::"
74+
75+
echo "✓ Chart published successfully!"
76+
echo "Chart: ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER_LOWER }}/charts/${{ env.CHART_NAME }}:v0.0.0-latest"
77+
78+
- name: Restore original Chart.yaml
79+
if: always()
80+
run: |
81+
# Restore original Chart.yaml
82+
if [ -f "${{ env.CHART_PATH }}/Chart.yaml.bak" ]; then
83+
mv ${{ env.CHART_PATH }}/Chart.yaml.bak ${{ env.CHART_PATH }}/Chart.yaml
84+
echo "Chart.yaml restored"
85+
fi
86+
87+
- name: Create release summary
88+
run: |
89+
cat >> $GITHUB_STEP_SUMMARY << EOF
90+
## 📦 Helm Chart Published
91+
92+
**Chart:** \`${{ env.CHART_NAME }}\`
93+
**Version:** \`v0.0.0-latest\`
94+
**Registry:** \`${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER_LOWER }}/charts\`
95+
96+
### Installation
97+
98+
\`\`\`bash
99+
# Pull the chart
100+
helm pull oci://${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER_LOWER }}/charts/${{ env.CHART_NAME }} --version v0.0.0-latest
101+
102+
# Install directly
103+
helm install semantic-router oci://${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER_LOWER }}/charts/${{ env.CHART_NAME }} \\
104+
--version v0.0.0-latest \\
105+
--namespace vllm-semantic-router-system \\
106+
--create-namespace
107+
\`\`\`
108+
109+
### Upgrade
110+
111+
\`\`\`bash
112+
helm upgrade semantic-router oci://${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER_LOWER }}/charts/${{ env.CHART_NAME }} \\
113+
--version v0.0.0-latest \\
114+
--namespace vllm-semantic-router-system
115+
\`\`\`
116+
EOF
117+
118+
- name: Logout from registry
119+
if: always()
120+
run: |
121+
helm registry logout ${{ env.REGISTRY }} || true
122+

0 commit comments

Comments
 (0)