|
| 1 | +name: Provider release (image + chart) |
| 2 | + |
| 3 | +# Builds and publishes a single provider's container image and Helm chart from |
| 4 | +# the monorepo, stamped with that provider's OWN version — not the hub version. |
| 5 | +# |
| 6 | +# Triggered by a per-provider release tag `providers/<name>/v<X.Y.Z>` (cut by |
| 7 | +# `cmd/kedge-release`). The provider name and version are parsed from the tag; |
| 8 | +# the image is tagged `vX.Y.Z` and `X.Y.Z`, and the chart's version/appVersion |
| 9 | +# are set to that version. Because every provider chart leaves `image.tag` empty |
| 10 | +# (→ defaults to `.Chart.AppVersion`), the deployed chart resolves to the |
| 11 | +# matching provider-versioned image built here. |
| 12 | +# |
| 13 | +# This is the sole publisher of provider images/charts. The hub `v*` release |
| 14 | +# (images.yaml / helm-images.yaml) builds providers in build-only PR validation |
| 15 | +# mode and no longer publishes them, and the split-*.yaml mirrors publish source |
| 16 | +# only (no version tag → no mirror image build), so there is no double-build. |
| 17 | + |
| 18 | +on: |
| 19 | + push: |
| 20 | + tags: |
| 21 | + - 'providers/*/v*' |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + packages: write |
| 26 | + id-token: write |
| 27 | + |
| 28 | +env: |
| 29 | + REGISTRY: ghcr.io |
| 30 | + |
| 31 | +jobs: |
| 32 | + release: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout repository |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Parse provider + version from tag |
| 39 | + id: tag |
| 40 | + run: | |
| 41 | + set -euo pipefail |
| 42 | + # refs/tags/providers/<name>/vX.Y.Z |
| 43 | + FULL="${GITHUB_REF#refs/tags/}" # providers/code/v0.0.9 |
| 44 | + REST="${FULL#providers/}" # code/v0.0.9 |
| 45 | + PROVIDER="${REST%%/*}" # code |
| 46 | + VERSION="${FULL##*/}" # v0.0.9 |
| 47 | + [ -d "providers/${PROVIDER}" ] || { echo "unknown provider ${PROVIDER}"; exit 1; } |
| 48 | + [ -f "providers/${PROVIDER}/Dockerfile" ] || { echo "no Dockerfile for ${PROVIDER}"; exit 1; } |
| 49 | + # Image repo matches the provider chart's values.yaml image.repository. |
| 50 | + # app-studio is published under a nested path; the rest are flat. |
| 51 | + case "${PROVIDER}" in |
| 52 | + app-studio) IMAGE="${{ github.repository_owner }}/kedge/app-studio-provider" ;; |
| 53 | + *) IMAGE="${{ github.repository_owner }}/kedge-${PROVIDER}-provider" ;; |
| 54 | + esac |
| 55 | + echo "provider=${PROVIDER}" >> "$GITHUB_OUTPUT" |
| 56 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" # v0.0.9 (chart appVersion + image tag) |
| 57 | + echo "semver=${VERSION#v}" >> "$GITHUB_OUTPUT" # 0.0.9 (chart version, OCI convention) |
| 58 | + echo "image=${IMAGE}" >> "$GITHUB_OUTPUT" |
| 59 | +
|
| 60 | + - name: Log in to the Container registry |
| 61 | + uses: docker/login-action@v3 |
| 62 | + with: |
| 63 | + registry: ${{ env.REGISTRY }} |
| 64 | + username: ${{ github.actor }} |
| 65 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + |
| 67 | + - name: Set up Docker Buildx |
| 68 | + uses: docker/setup-buildx-action@v3 |
| 69 | + |
| 70 | + - name: Build and push image |
| 71 | + uses: docker/build-push-action@v6 |
| 72 | + with: |
| 73 | + context: ./providers/${{ steps.tag.outputs.provider }} |
| 74 | + file: ./providers/${{ steps.tag.outputs.provider }}/Dockerfile |
| 75 | + platforms: linux/amd64,linux/arm64 |
| 76 | + push: true |
| 77 | + tags: | |
| 78 | + ${{ env.REGISTRY }}/${{ steps.tag.outputs.image }}:${{ steps.tag.outputs.version }} |
| 79 | + ${{ env.REGISTRY }}/${{ steps.tag.outputs.image }}:${{ steps.tag.outputs.semver }} |
| 80 | +
|
| 81 | + - name: Install Helm |
| 82 | + uses: azure/setup-helm@v3 |
| 83 | + with: |
| 84 | + version: 'v3.12.0' |
| 85 | + |
| 86 | + - name: Package and push chart |
| 87 | + env: |
| 88 | + HELM_EXPERIMENTAL_OCI: 1 |
| 89 | + run: | |
| 90 | + set -euo pipefail |
| 91 | + echo "${{ github.token }}" | helm registry login "${REGISTRY}" --username ${{ github.actor }} --password-stdin |
| 92 | +
|
| 93 | + chart_dir="providers/${{ steps.tag.outputs.provider }}/deploy/chart/" |
| 94 | + chart_name=$(grep -E '^name:' "${chart_dir}Chart.yaml" | head -1 | awk '{print $2}') |
| 95 | +
|
| 96 | + # Chart version follows OCI/semver convention (no 'v'); appVersion keeps |
| 97 | + # the 'v' so the chart's image.tag default (.Chart.AppVersion) matches |
| 98 | + # the 'vX.Y.Z' image tag pushed above. |
| 99 | + CHART_VERSION="${{ steps.tag.outputs.semver }}" |
| 100 | + APP_VERSION="${{ steps.tag.outputs.version }}" |
| 101 | +
|
| 102 | + # lint renders templates against default values (package only tars), so |
| 103 | + # a broken template fails here rather than shipping. |
| 104 | + helm lint "$chart_dir" |
| 105 | + # Stamp version + appVersion at package time via flags rather than |
| 106 | + # rewriting Chart.yaml, so the checked-out source is never mutated. |
| 107 | + helm package "$chart_dir" --version "${CHART_VERSION}" --app-version "${APP_VERSION}" |
| 108 | + helm push "${chart_name}-${CHART_VERSION}.tgz" "oci://${REGISTRY}/${{ github.repository_owner }}/charts" |
| 109 | + echo "Pushed oci://${REGISTRY}/${{ github.repository_owner }}/charts/${chart_name}:${CHART_VERSION} (appVersion ${APP_VERSION})" |
0 commit comments