|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: Release Helm OCI |
| 5 | +description: > |
| 6 | + Patch chart version/appVersion, refuse duplicate OCI versions on public |
| 7 | + releases, package the chart, and push to GHCR OCI. |
| 8 | +
|
| 9 | +inputs: |
| 10 | + chart-version: |
| 11 | + description: > |
| 12 | + Chart.yaml version and OCI tag — SemVer without leading v |
| 13 | + (e.g. 0.6.0 for tag releases, 0.0.0-dev for dev). |
| 14 | + required: true |
| 15 | + app-version: |
| 16 | + description: > |
| 17 | + Chart.yaml appVersion and default image tag |
| 18 | + (e.g. 0.6.0 for tag releases, dev for dev). |
| 19 | + required: true |
| 20 | + release-kind: |
| 21 | + description: "dev or public — controls the duplicate-version guard." |
| 22 | + required: true |
| 23 | + pin-sha: |
| 24 | + description: > |
| 25 | + Full commit SHA. When set on dev releases, a second chart is also pushed |
| 26 | + as 0.0.0-dev.<sha> with appVersion set to the same SHA, enabling exact |
| 27 | + version pinning alongside the floating 0.0.0-dev tag. Both chart version |
| 28 | + and appVersion use the full SHA so the chart tag matches the image tag |
| 29 | + pushed by docker-build.yml. |
| 30 | + required: false |
| 31 | + default: "" |
| 32 | + |
| 33 | +runs: |
| 34 | + using: composite |
| 35 | + steps: |
| 36 | + - name: Log in to GHCR |
| 37 | + uses: docker/login-action@v3 |
| 38 | + with: |
| 39 | + registry: ghcr.io |
| 40 | + username: ${{ github.actor }} |
| 41 | + password: ${{ github.token }} |
| 42 | + |
| 43 | + - name: Install Helm |
| 44 | + uses: azure/setup-helm@v4 |
| 45 | + |
| 46 | + - name: Stage chart and patch version |
| 47 | + id: prep |
| 48 | + env: |
| 49 | + CHART_VERSION: ${{ inputs.chart-version }} |
| 50 | + APP_VERSION: ${{ inputs.app-version }} |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + set -euo pipefail |
| 54 | + CHART_DIR="${RUNNER_TEMP}/chart-build" |
| 55 | + cp -a deploy/helm/openshell/. "${CHART_DIR}" |
| 56 | + sed -i "s/^version:.*/version: ${CHART_VERSION}/" "${CHART_DIR}/Chart.yaml" |
| 57 | + sed -i "s/^appVersion:.*/appVersion: \"${APP_VERSION}\"/" "${CHART_DIR}/Chart.yaml" |
| 58 | + echo "chart_dir=${CHART_DIR}" >> "$GITHUB_OUTPUT" |
| 59 | + echo "chart_version=${CHART_VERSION}" >> "$GITHUB_OUTPUT" |
| 60 | +
|
| 61 | + - name: Refuse duplicate chart version |
| 62 | + if: inputs.release-kind == 'public' |
| 63 | + env: |
| 64 | + CHART_VERSION: ${{ steps.prep.outputs.chart_version }} |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + set -euo pipefail |
| 68 | + OCI_CHART="oci://ghcr.io/nvidia/openshell/helm-chart" |
| 69 | + if helm show chart "${OCI_CHART}" --version "${CHART_VERSION}" >/dev/null 2>&1; then |
| 70 | + echo "::error::Chart ${CHART_VERSION} is already published. Use a new tag or delete the existing package first." |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | +
|
| 74 | + - name: Package Helm chart |
| 75 | + env: |
| 76 | + CHART_DIR: ${{ steps.prep.outputs.chart_dir }} |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + helm package "${CHART_DIR}" --destination /tmp |
| 81 | + ls /tmp/helm-chart-*.tgz |
| 82 | +
|
| 83 | + - name: Push Helm chart to GHCR OCI |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + set -euo pipefail |
| 87 | + helm push /tmp/helm-chart-*.tgz oci://ghcr.io/nvidia/openshell |
| 88 | +
|
| 89 | + - name: Push SHA-pinned chart |
| 90 | + if: inputs.pin-sha != '' |
| 91 | + env: |
| 92 | + PIN_SHA: ${{ inputs.pin-sha }} |
| 93 | + CHART_DIR: ${{ steps.prep.outputs.chart_dir }} |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + set -euo pipefail |
| 97 | + SHA_CHART_DIR="${RUNNER_TEMP}/chart-build-sha" |
| 98 | + cp -a "${CHART_DIR}/." "${SHA_CHART_DIR}" |
| 99 | + sed -i "s/^version:.*/version: 0.0.0-dev.${PIN_SHA}/" "${SHA_CHART_DIR}/Chart.yaml" |
| 100 | + sed -i "s/^appVersion:.*/appVersion: \"${PIN_SHA}\"/" "${SHA_CHART_DIR}/Chart.yaml" |
| 101 | + helm package "${SHA_CHART_DIR}" --destination /tmp/sha-pin |
| 102 | + helm push /tmp/sha-pin/helm-chart-*.tgz oci://ghcr.io/nvidia/openshell |
0 commit comments