From 9df14b06b0a2f07205d7707d05ca6e9637736c2c Mon Sep 17 00:00:00 2001 From: Johann Gnaucke Date: Tue, 17 Jun 2025 15:44:09 +0200 Subject: [PATCH 1/3] Add Github action for publishing OCI artifacts --- .github/workflows/images.yaml | 17 ++++++++++++++++ .gitignore | 2 ++ hack/push-artifacts.sh | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100755 hack/push-artifacts.sh diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index 2b2d04c8..ff22aac8 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -8,6 +8,23 @@ on: - v* jobs: + helm-oci: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: azure/setup-helm@v4.3.0 + - name: Push artifacts + run: hack/push-artifacts.sh ghcr.io/stackitcloud/yawol/yawol-controller build: runs-on: ubuntu-latest permissions: diff --git a/.gitignore b/.gitignore index eb3b04c3..2b9ea8dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +artifacts + # Binaries for programs and plugins *.exe *.exe~ diff --git a/hack/push-artifacts.sh b/hack/push-artifacts.sh new file mode 100755 index 00000000..80740bb8 --- /dev/null +++ b/hack/push-artifacts.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +chart_name=yawol-controller +helm_artifacts=artifacts/charts +rm -rf "$helm_artifacts" +mkdir -p "$helm_artifacts" + +function image_registry() { + echo "$1" | cut -d '/' -f -2 +} + +function image_repo() { + echo "$1" | cut -d ':' -f 1 +} + +function image_tag() { + git describe --tag --always --dirty +} + +## HELM +cp -r charts/${chart_name} "$helm_artifacts" +yq -i "\ + ( .image.repository = \"$(image_repo "$1")\" ) | \ + ( .image.tag = \"$(image_tag "$1")\" )\ +" "$helm_artifacts/${chart_name}/values.yaml" + +# push to registry +if [ "$PUSH" != "true" ] ; then + echo "Skip pushing artifacts because PUSH is not set to 'true'" + exit 0 +fi + +helm package "$helm_artifacts/${chart_name}" --version "$(image_tag "$1")" -d "$helm_artifacts" > /dev/null 2>&1 +helm push "$helm_artifacts/${chart_name}-"* "oci://$(image_registry "$1")/charts" From ec9076c96c4f460e3c6e99e52b987d8fed7526d4 Mon Sep 17 00:00:00 2001 From: Johann Gnaucke Date: Tue, 17 Jun 2025 15:45:12 +0200 Subject: [PATCH 2/3] set PUSH to true for OCI helm chart --- .github/workflows/images.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index ff22aac8..814b609f 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -24,7 +24,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - uses: azure/setup-helm@v4.3.0 - name: Push artifacts - run: hack/push-artifacts.sh ghcr.io/stackitcloud/yawol/yawol-controller + run: PUSH=true hack/push-artifacts.sh ghcr.io/stackitcloud/yawol/yawol-controller build: runs-on: ubuntu-latest permissions: From 27a22de24d51eb981bbbfb9fd128949d77989ac5 Mon Sep 17 00:00:00 2001 From: Johann Gnaucke Date: Mon, 23 Jun 2025 10:15:14 +0200 Subject: [PATCH 3/3] Update hack/push-artifacts.sh Co-authored-by: Marcel Boehm Signed-off-by: Johann Gnaucke --- hack/push-artifacts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/push-artifacts.sh b/hack/push-artifacts.sh index 80740bb8..4cb7c784 100755 --- a/hack/push-artifacts.sh +++ b/hack/push-artifacts.sh @@ -29,7 +29,7 @@ yq -i "\ " "$helm_artifacts/${chart_name}/values.yaml" # push to registry -if [ "$PUSH" != "true" ] ; then +if [ "${PUSH:=}" != "true" ] ; then echo "Skip pushing artifacts because PUSH is not set to 'true'" exit 0 fi