diff --git a/.github/workflows/stable-release.yaml b/.github/workflows/stable-release.yaml index bea1b27d..0716799c 100644 --- a/.github/workflows/stable-release.yaml +++ b/.github/workflows/stable-release.yaml @@ -3,7 +3,10 @@ name: Stable release -on: workflow_dispatch +on: + create: + tags: + - "v*" permissions: read-all @@ -33,8 +36,35 @@ jobs: NAME: ${{ matrix.adapters }} secrets: inherit + update-image-tags-in-helm-charts: + if: github.repository == '5GSEC/nimbus' + needs: [ release-nimbus-image, release-adapters-image ] + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Get tag + id: tag + run: | + if [ ${{ github.ref }} == "refs/heads/main" ]; then + echo "tag=latest" >> $GITHUB_OUTPUT + else + echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + fi + + - name: Update images tag + run: | + ./scripts/update-image-tag.sh ${{ steps.tag.outputs.tag }} + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + release_helm_charts: if: github.repository == '5GSEC/nimbus' + needs: [ update-image-tags-in-helm-charts ] permissions: contents: write runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 0ea437bc..2bed4867 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes ##@ Build .PHONY: build -build: manifests generate fmt vet ## Build manager binary. +build: fmt vet ## Build manager binary. @go build -ldflags="-s" -o bin/"${BINARY_NAME}" ./cmd .PHONY: run diff --git a/scripts/update-image-tag.sh b/scripts/update-image-tag.sh new file mode 100755 index 00000000..f8fdf1d0 --- /dev/null +++ b/scripts/update-image-tag.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2023 Authors of Nimbus + +if ! command -v yq >/dev/null; then + echo "Installing yq..." + go install github.com/mikefarah/yq/v4@latest +fi + +TAG=$1 +DEPLOYMENT_ROOT_DIR="deployments" +DIRECTORIES=("${DEPLOYMENT_ROOT_DIR}/nimbus" "${DEPLOYMENT_ROOT_DIR}/nimbus-k8tls" \ + "${DEPLOYMENT_ROOT_DIR}/nimbus-kubearmor" "${DEPLOYMENT_ROOT_DIR}/nimbus-kyverno" "${DEPLOYMENT_ROOT_DIR}/nimbus-netpol") + +echo "Updating tag to $TAG" +for directory in "${DIRECTORIES[@]}"; do + yq -i ".image.tag = \"$TAG\"" "${directory}/values.yaml" +done