Run go-makefile-maker #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################ | |
| # This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> # | |
| # Edit Makefile.maker.yaml instead. # | |
| ################################################################################ | |
| # SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Helm OCI Package GHCR | |
| "on": | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - '*' | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-and-push-helm-package: | |
| name: Build and publish Helm Chart OCI | |
| runs-on: large_runner_16core_64gb | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Install Helm | |
| uses: azure/setup-helm@v5 | |
| - name: Lint Helm Chart | |
| run: helm lint charts/openstack-hypervisor-operator | |
| - name: Package Helm Chart | |
| run: | | |
| APP_VERSION="" | |
| # use version from the helm chart itself as a base | |
| VERSION="$(helm show chart charts/openstack-hypervisor-operator | grep -E "^version:" | awk '{print $2}')" | |
| # try to detect a version from the git tags, set APP_VERSION only if this commit has been tagged | |
| CURRENT_TAG=$(git describe --tags --exact-match ${{ github.sha }} 2>/dev/null || echo "") | |
| LAST_TAG=$((git describe --tags --abbrev=0 2>/dev/null | sed -E 's/^v//') || echo "") | |
| if [ -n "$CURRENT_TAG" ]; then | |
| APP_VERSION="$CURRENT_TAG" | |
| VERSION=$(echo -n "$CURRENT_TAG" | sed -E 's/^v//') | |
| elif [ -n "$LAST_TAG" ]; then | |
| VERSION="$LAST_TAG" | |
| fi | |
| # use the git sha as app-version if no version could be detected from the tags | |
| if [ -z "$APP_VERSION" ]; then | |
| APP_VERSION="sha-${{ github.sha }}" | |
| fi | |
| # append truncated sha to version for uniqueness on untagged commits | |
| if [[ "$APP_VERSION" == sha-* ]]; then | |
| VERSION="$VERSION+${APP_VERSION:0:11}" | |
| fi | |
| HELM_ARGS=--dependency-update | |
| if [ -n "$APP_VERSION" ]; then | |
| HELM_ARGS="$HELM_ARGS --app-version $APP_VERSION" | |
| fi | |
| if [ -n "$VERSION" ]; then | |
| HELM_ARGS="$HELM_ARGS --version $VERSION" | |
| fi | |
| echo "Running helm package with $HELM_ARGS" | |
| helm package charts/openstack-hypervisor-operator --destination ./chart $HELM_ARGS | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v4 | |
| with: | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| - name: Push Helm Chart to ghcr.io | |
| run: helm push ./chart/*.tgz oci://ghcr.io/${{ github.repository_owner }}/charts |