Skip to content

Commit c1c174b

Browse files
authored
ci(helm): derive chart versions from git tags (#1273)
1 parent e0efb32 commit c1c174b

4 files changed

Lines changed: 40 additions & 33 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Docker image release
33
"on":
44
push:
55
tags:
6-
- "*"
6+
- "v*.*.*"
77

88
permissions:
99
contents: read
@@ -30,6 +30,10 @@ jobs:
3030
- name: Build and push image
3131
shell: bash
3232
run: |
33+
image=nvcr.io/nvstaging/lepton/gpud
34+
version="${GITHUB_REF_NAME#v}"
35+
3336
./scripts/build-docker.sh \
34-
--tag "nvcr.io/nvstaging/lepton/gpud:${GITHUB_REF_NAME#v}" \
37+
--tag "$image:$version" \
38+
--tag "$image:latest" \
3539
--push

.github/workflows/helm.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Helm chart release
22

33
"on":
44
push:
5-
branches:
6-
- main
5+
tags:
6+
- "v*.*.*"
77

88
permissions:
99
contents: write
@@ -29,15 +29,18 @@ jobs:
2929
chart=deployments/helm/gpud
3030
pages_dir="$RUNNER_TEMP/gh-pages"
3131
name="$(awk '$1 == "name:" { print $2; exit }' "$chart/Chart.yaml")"
32-
version="$(awk '$1 == "version:" { print $2; exit }' "$chart/Chart.yaml")"
32+
version="${GITHUB_REF_NAME#v}"
3333
package="$pages_dir/$name-$version.tgz"
3434
3535
git fetch origin gh-pages:refs/remotes/origin/gh-pages
3636
git worktree add --detach "$pages_dir" origin/gh-pages
3737
3838
if [[ ! -f "$package" || ! -f "$pages_dir/index.yaml" ]]; then
3939
if [[ ! -f "$package" ]]; then
40-
helm package "$chart" --destination "$pages_dir"
40+
helm package "$chart" \
41+
--version "$version" \
42+
--app-version "$version" \
43+
--destination "$pages_dir"
4144
fi
4245
helm repo index "$pages_dir" --url https://leptonai.github.io/gpud
4346
fi

deployments/helm/gpud/Chart.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: v2
22
name: gpud
33
description: GPUd Helm chart for Kubernetes
44
type: application
5-
version: 0.12.7
6-
appVersion: "0.12.7"
5+
# Overridden from the pushed git tag by the release workflow.
6+
version: 0.0.0
7+
appVersion: "latest"
78
icon: https://assets.nvidiagrid.net/ngc/logos/Infrastructure.png

scripts/build-docker.sh

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# OPTIONS
1818
# ==============================================================================
1919
#
20-
# --tag TAG Docker image tag (required)
20+
# --tag TAG Docker image tag (required, repeatable)
2121
# --platform PLAT Target platforms (default: linux/amd64,linux/arm64)
2222
# --os-name NAME Base OS name (default: ubuntu)
2323
# --os-version VER Base OS version (default: 22.04)
@@ -132,7 +132,7 @@ PLATFORMS="linux/amd64,linux/arm64"
132132
OS_NAME="ubuntu"
133133
OS_VERSION="22.04"
134134
CUDA_VERSION="12.4.1"
135-
TAG=""
135+
TAGS=()
136136
PUSH=false
137137
LOAD=false
138138
NO_CACHE=false
@@ -174,7 +174,7 @@ show_help() {
174174
while [[ $# -gt 0 ]]; do
175175
case $1 in
176176
--tag)
177-
TAG="$2"
177+
TAGS+=("$2")
178178
shift 2
179179
;;
180180
--platform)
@@ -220,10 +220,11 @@ while [[ $# -gt 0 ]]; do
220220
done
221221

222222
# Validate required arguments
223-
if [[ -z "$TAG" ]]; then
223+
if [[ ${#TAGS[@]} -eq 0 ]]; then
224224
log_error "Docker image tag is required. Use --tag to specify."
225225
exit 1
226226
fi
227+
TAG="${TAGS[0]}"
227228

228229
# Check for Dockerfile
229230
if [[ ! -f "$PROJECT_ROOT/Dockerfile" ]]; then
@@ -250,44 +251,42 @@ if [[ "$LOAD" == "true" && "$PLATFORMS" == *","* ]]; then
250251
fi
251252

252253
# Build the command
253-
BUILD_CMD="docker buildx build"
254-
255-
# Add platform
256-
BUILD_CMD="$BUILD_CMD --platform $PLATFORMS"
257-
258-
# Add build args
259-
BUILD_CMD="$BUILD_CMD --build-arg OS_NAME=$OS_NAME"
260-
BUILD_CMD="$BUILD_CMD --build-arg OS_VERSION=$OS_VERSION"
261-
BUILD_CMD="$BUILD_CMD --build-arg CUDA_VERSION=$CUDA_VERSION"
262-
263-
# Add tag
264-
BUILD_CMD="$BUILD_CMD -t $TAG"
254+
BUILD_CMD=(
255+
docker buildx build
256+
--platform "$PLATFORMS"
257+
--build-arg "OS_NAME=$OS_NAME"
258+
--build-arg "OS_VERSION=$OS_VERSION"
259+
--build-arg "CUDA_VERSION=$CUDA_VERSION"
260+
)
261+
262+
for tag in "${TAGS[@]}"; do
263+
BUILD_CMD+=(--tag "$tag")
264+
done
265265

266-
# Add Dockerfile
267-
BUILD_CMD="$BUILD_CMD -f $PROJECT_ROOT/Dockerfile"
266+
BUILD_CMD+=(-f "$PROJECT_ROOT/Dockerfile")
268267

269268
# Add optional flags
270269
if [[ "$PUSH" == "true" ]]; then
271-
BUILD_CMD="$BUILD_CMD --push"
270+
BUILD_CMD+=(--push)
272271
fi
273272

274273
if [[ "$LOAD" == "true" ]]; then
275-
BUILD_CMD="$BUILD_CMD --load"
274+
BUILD_CMD+=(--load)
276275
fi
277276

278277
if [[ "$NO_CACHE" == "true" ]]; then
279-
BUILD_CMD="$BUILD_CMD --no-cache"
278+
BUILD_CMD+=(--no-cache)
280279
fi
281280

282281
# Add context
283-
BUILD_CMD="$BUILD_CMD $PROJECT_ROOT"
282+
BUILD_CMD+=("$PROJECT_ROOT")
284283

285284
# Print build information
286285
echo ""
287286
log_info "========================================"
288287
log_info "GPUd Docker Build"
289288
log_info "========================================"
290-
log_info "Tag: $TAG"
289+
log_info "Tags: ${TAGS[*]}"
291290
log_info "Platforms: $PLATFORMS"
292291
log_info "OS: $OS_NAME $OS_VERSION"
293292
log_info "CUDA Version: $CUDA_VERSION"
@@ -300,11 +299,11 @@ echo ""
300299

301300
log_step "Building Docker image..."
302301
echo ""
303-
log_info "Command: $BUILD_CMD"
302+
log_info "Command: ${BUILD_CMD[*]}"
304303
echo ""
305304

306305
# Execute build
307-
eval "$BUILD_CMD"
306+
"${BUILD_CMD[@]}"
308307

309308
BUILD_STATUS=$?
310309

0 commit comments

Comments
 (0)