|
| 1 | +################################################################################ |
| 2 | +# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> # |
| 3 | +# Edit Makefile.maker.yaml instead. # |
| 4 | +################################################################################ |
| 5 | + |
| 6 | +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company |
| 7 | +# SPDX-License-Identifier: Apache-2.0 |
| 8 | + |
| 9 | +name: Helm OCI Package GHCR |
| 10 | +"on": |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - new-helm-oci |
| 14 | + tags: |
| 15 | + - '*' |
| 16 | + workflow_dispatch: {} |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + packages: write |
| 20 | +jobs: |
| 21 | + build-and-push-helm-package: |
| 22 | + name: Build and publish Helm Chart OCI |
| 23 | + runs-on: large_runner_16core_64gb |
| 24 | + steps: |
| 25 | + - name: Check out code |
| 26 | + uses: actions/checkout@v6 |
| 27 | + - name: Install Helm |
| 28 | + uses: azure/setup-helm@v4.3.1 |
| 29 | + - name: Lint Helm Chart |
| 30 | + run: helm lint charts/openstack-hypervisor-operator |
| 31 | + - name: Package Helm Chart |
| 32 | + run: | |
| 33 | + # try to detect a version from the git tags, only if the tag is exactly on the commit, otherwise we might get a version from a previous tag which would be wrong |
| 34 | + APP_VERSION=$(git describe --tags --exact-match ${{ github.sha }} 2>/dev/null || echo "") |
| 35 | + if [ -n "$APP_VERSION" ]; then |
| 36 | + VERSION=$(echo -n "$APP_VERSION" | sed -E 's/^v//') |
| 37 | + fi |
| 38 | +
|
| 39 | + # use the git sha as version, if no version could be detected from the tags |
| 40 | + if [ -z "$APP_VERSION" ]; then |
| 41 | + APP_VERSION=$(echo -n "sha-${{ github.sha }}") |
| 42 | + fi |
| 43 | + if [ -z "$VERSION" ] && [ -n "$APP_VERSION" ]; then |
| 44 | + VERSION="$(helm show chart charts/openstack-hypervisor-operator | grep -E "^version:" | awk '{print $2}' )+${APP_VERSION:0:11}" |
| 45 | + fi |
| 46 | +
|
| 47 | + HELM_ARGS=--dependency-update |
| 48 | + if [ -n "$APP_VERSION" ]; then |
| 49 | + HELM_ARGS="$HELM_ARGS --app-version $APP_VERSION" |
| 50 | + fi |
| 51 | + if [ -n "$VERSION" ]; then |
| 52 | + HELM_ARGS="$HELM_ARGS --version $VERSION" |
| 53 | + fi |
| 54 | + echo "Running helm packkage with $HELM_ARGS" |
| 55 | + helm package charts/openstack-hypervisor-operator --destination ./chart $HELM_ARGS |
| 56 | + - name: Log in to the Container registry |
| 57 | + uses: docker/login-action@v4 |
| 58 | + with: |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + registry: ghcr.io |
| 61 | + username: ${{ github.actor }} |
| 62 | + - name: Push Helm Chart to ghcr.io |
| 63 | + run: helm push ./chart/*.tgz oci://ghcr.io/${{ github.repository_owner }}/charts |
0 commit comments