diff --git a/.github/actions/git-release-create/action.yml b/.github/actions/git-release-create/action.yml deleted file mode 100644 index c9086c7..0000000 --- a/.github/actions/git-release-create/action.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: "Helm Chart Release Tag" -description: "Generates release notes and creates a new GitHub release for a Helm Chart tag" - -runs: - using: "composite" - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Print commit SHA - shell: bash - run: echo ${{ github.sha }} - - name: Tag modified Helm Chart - shell: bash - run: | - set +e - ${GITHUB_ACTION_PATH}/git-release-fix.sh &> ${GITHUB_WORKSPACE}/bash_output.txt - env: - COMMIT_HASH: ${{ github.sha }} - - - name: Bash Output - shell: bash - if: always() - run: | - if [ -f "${GITHUB_WORKSPACE}/bash_output.txt" ]; then - echo "::group:: Bash Script Output" - cat ${GITHUB_WORKSPACE}/bash_output.txt - echo "::endgroup::" - fi - - if [ -f "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt" ]; then - echo "::group:: PR Status Check Human Friendly Output" - cat "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt" - echo "::endgroup::" - fi - - if [ -f "${GITHUB_WORKSPACE}/github-workflow-commands.txt" ]; then - cat "${GITHUB_WORKSPACE}/github-workflow-commands.txt" - fi diff --git a/.github/actions/git-release-create/git-release-fix.sh b/.github/actions/git-release-create/git-release-fix.sh deleted file mode 100755 index 9f913d5..0000000 --- a/.github/actions/git-release-create/git-release-fix.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -################################################################### -# Script Name : github release create -# Description : This script fetches all Git tags, checks if a GitHub release already exists for -# each tag, and if not, generates release notes and creates a new GitHub release -# for the tag. It searches for a previous tag that starts with the same name as the -# current tag but has a lower semantic version. -# Args : - -# Hint : This script is not meant for any pipeline just for cleanup! -################################################################### -set +e - -# Fetch all tags from the remote -gh auth status - -git fetch --tags - -# Get all tags -tags=$(git tag) - -# Fetch all existing releases -existing_releases=$(gh release list --limit 99999 --json tagName --jq '.[].tagName') - -# Loop through each tag -for tag in $tags; do - if echo "$existing_releases" | grep -q "^$tag$"; then - echo "Release for tag $tag already exists. Skipping..." - continue - fi - - # Find the previous tag with the same prefix but lower semantic version - previous_tag="" - prefix="" - prefix=$(echo "$tag" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+)$//') - previous_tag=$(git tag -l "${prefix}*" | sort -V | grep -B1 "$tag" | head -n 1) - - release_notes="" - # Generate release notes using the GitHub CLI - if [ -n "$previous_tag" ] && [ "$previous_tag" != "$tag" ]; then - release_notes=$(gh api repos/:owner/:repo/releases/generate-notes -f tag_name="$tag" -f previous_tag_name="$previous_tag" -q '.body') - printf 'tag: %s != previous_tag: %s \n %s' "$tag" "$previous_tag" "$release_notes" - else - release_notes=$(gh api repos/:owner/:repo/releases/generate-notes -f tag_name="$tag" -q '.body') - printf 'tag: %s == previous_tag: %s \n %s' "$tag" "$previous_tag" "$release_notes" - fi - - # Create a release for each tag - gh release create "$tag" --title "$tag" --notes "$release_notes" --verify-tag --latest=false - -done diff --git a/.github/actions/git-tag-modified-helm-chart/action.yml b/.github/actions/git-tag-modified-helm-chart/action.yml deleted file mode 100644 index 675748c..0000000 --- a/.github/actions/git-tag-modified-helm-chart/action.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: 'Tag modified Helm Chart' -description: 'Create Git Tag for every modified Helm Chart' - -runs: - using: "composite" - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Print commit SHA - shell: bash - run: echo ${{ github.sha }} - - name: Tag modified Helm Chart - shell: bash - run: | - set +e - ${GITHUB_ACTION_PATH}/git-tag-modified-helm-chart.sh &> ${GITHUB_WORKSPACE}/bash_output.txt - env: - COMMIT_HASH: ${{ github.sha }} - - - name: Bash Output - shell: bash - if: always() - run: | - if [ -f "${GITHUB_WORKSPACE}/bash_output.txt" ]; then - echo "::group:: Bash Script Output" - cat ${GITHUB_WORKSPACE}/bash_output.txt - echo "::endgroup::" - fi - - if [ -f "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt" ]; then - echo "::group:: PR Status Check Human Friendly Output" - cat "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt" - echo "::endgroup::" - fi - - if [ -f "${GITHUB_WORKSPACE}/github-workflow-commands.txt" ]; then - cat "${GITHUB_WORKSPACE}/github-workflow-commands.txt" - fi \ No newline at end of file diff --git a/.github/actions/git-tag-modified-helm-chart/git-tag-modified-helm-chart.sh b/.github/actions/git-tag-modified-helm-chart/git-tag-modified-helm-chart.sh deleted file mode 100755 index aac3899..0000000 --- a/.github/actions/git-tag-modified-helm-chart/git-tag-modified-helm-chart.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -################################################################### -#Script Name : git tag modified helm chart -#Description : creates a git tag for each modified helm chart -#Args : - -#Hint : Only works with Helm Chart Version compare -################################################################### -SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) -# shellcheck disable=SC1091 -source "$SCRIPT_DIR"/../shared-variables.sh - -declare resultPwd exitCode - -set +e -echo "The script you are running has:" -echo "basename: [$(basename "$0")]" -echo "dirname : [$(dirname "$0")]" -echo "pwd : [$(pwd)]" - -declare -a filesToRemove=("pr-status-check-human-friendly.txt" "modified_files.txt") -REMOVE_FILES_IF_EXISTS "$resultPwd" "${filesToRemove[@]}" -################################################################### -if [ -z "$COMMIT_HASH" ]; then - COMMIT_HASH="89b624080bb62e7f5ac340d81fef96c9d6446d22" - echo "!!! WARNING: \$COMMIT_HASH NEEDS TO BE SET e.g. Default set COMMIT_HASH=${COMMIT_HASH}! \"export COMMIT_HASH=${COMMIT_HASH}\"!!!" - exit 1 -fi - - -################################################################### -# Function to print a row with fixed-width columns -print_row() { - printf "%-70s %-50s %-15s %-15s\n" "$1" "$2" "$3" "$4" -} - -git_tag_check() { - local tag=$1 - git rev-parse -q --verify "refs/tags/$tag" &>/dev/null -} -################################################################### - -# List modified files of commit -git diff-tree --no-commit-id --name-only -r "$COMMIT_HASH" >modified_files.txt -# shellcheck disable=SC2181 -if [ $? != 0 ]; then - exit 1 -fi -# Iterate over the array of paths with filenames and extract the directory paths -unique_paths=() -while IFS= read -r path; do - - dir=$(dirname "$path") - - if [[ "$dir" == *templates ]]; then - dir=${dir%/*} - fi - dir=${dir%*/templates*} # retain the part before "/templates" - - if [ -f "$dir/Chart.yaml" ] || [ -f "$dir/Chart.yml" ]; then - unique_paths+=("$dir") - fi -done <"modified_files.txt" - -if [ ${#unique_paths[@]} -eq 0 ]; then - echo -e "No Helm Charts have been modified!\n" - echo -e "List of Modified files:" - cat "modified_files.txt" - exit "$exitCode" -fi - -# Sort and remove duplicates from the list of paths -# shellcheck disable=SC2207 -unique_paths=($(echo "${unique_paths[@]}" | tr ' ' '\n' | sort -u)) -{ - # Header row - printf "%-70s %-50s %-15s %-15s\n" "Modified Helm Chart:" "Name:" "Version:" "Status:" - - git checkout "$COMMIT_HASH" - - for helmChart in "${unique_paths[@]}"; do - chartVersion=$(yq -r eval '.version' "$helmChart/Chart.yaml") - chartName=$(yq -r eval '.name' "$helmChart/Chart.yaml") - gitTag="$chartName-$chartVersion" - if git_tag_check "$gitTag"; then - print_row "$helmChart" "$chartName" "$chartVersion" "-" - else - - git tag "$gitTag" "$COMMIT_HASH" - # shellcheck disable=SC2181 - if [ $? != 0 ]; then - print_row "$helmChart" "$chartName" "$chartVersion" "ERROR: git tag $gitTag" - exit 1 - fi - - git push origin "$gitTag" - # shellcheck disable=SC2181 - if [ $? != 0 ]; then - print_row "$helmChart" "$chartName" "$chartVersion" "ERROR: git push origin $gitTag" - exit 1 - fi - - print_row "$helmChart" "$chartName" "$chartVersion" "git tagged&pushed $gitTag" - - fi - - done - -} >>"$resultPwd/pr-status-check-human-friendly.txt" - -cat "$resultPwd/pr-status-check-human-friendly.txt" - -exit "$exitCode" diff --git a/.github/actions/shared-variables.sh b/.github/actions/shared-variables.sh deleted file mode 100755 index 587ddce..0000000 --- a/.github/actions/shared-variables.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -################################################################### -#Script Name : -#Description : -#Args : - -#Hint : -################################################################### -set -e -resultPwd=$(pwd) -helmChartListingFileName="helm-charts-templated.yaml" -emptyManifestString="WARNING: This chart is deprecated" -newLineString="-------------------------------------------------------------------------------------------------------------------------" -msgHelpStart="" -#msgEverythingIsFine="/人◕ __ ◕人\ Everything seems to be all right (⌐⊙_⊙)" -msgEverythingIsFine="☺ √" -exitCode=0 -# Define color escape codes -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -BOLD='\033[1m' -UNDERLINE='\033[4m' -REVERSE='\033[7m' -RESET='\033[0m' # Reset color -################################################################### -declare -a filesToRemove=("pr-status-check-human-friendly.txt" "github-workflow-commands.txt") -################################################################### -function REMOVE_FILES_IF_EXISTS { - arr=("$@") - for fileToRemove in "${arr[@]}" - do - if [ -f "$1/$fileToRemove" ]; then - rm "$1/$fileToRemove" - #echo "removed $1/$fileToRemove" - fi - done -} -function ASSERT_FILE_EXISTS_WITH_MSG { - if [ ! -f "$1/$2" ]; then - echo "!! ERROR missing file $1/$2 !!$3" - exit 1 - fi -} -################################################################### -if [ -n "$GITHUB_WORKSPACE" ]; then - cd "$GITHUB_WORKSPACE" || exit - resultPwd=$GITHUB_WORKSPACE -fi -REMOVE_FILES_IF_EXISTS "$resultPwd" "${filesToRemove[@]}" -################################################################### -export helmChartListingFileName emptyManifestString newLineString exitCode resultPwd helmChartListTemplatedManifestsFileName msgHelpStart msgEverythingIsFine RED GREEN YELLOW BLUE BOLD UNDERLINE RESET REVERSE \ No newline at end of file diff --git a/.github/workflows/git-release-create.yml b/.github/workflows/git-release-create.yml deleted file mode 100644 index 04b1ba1..0000000 --- a/.github/workflows/git-release-create.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Helm Chart Release Tag - -on: - workflow_call: {} - workflow_dispatch: {} - - - -jobs: - git-release-create: - name: Helm Chart Release Tag - runs-on: ubuntu-latest - steps: - - name: Login to GitHub Enterprise with token - run: | - env - gh version - echo ${{ secrets.CO_GOLDEN_PATH_SERVICEUSER_GH_TOKEN }} | gh auth login --with-token - - - name: Create Github Releases for Helm Chart Tags - uses: openmcp-project/blueprint-building-blocks/.github/actions/git-release-create@main \ No newline at end of file diff --git a/.github/workflows/git-tag-modified-helm-chart.yml b/.github/workflows/git-tag-modified-helm-chart.yml deleted file mode 100644 index a4df887..0000000 --- a/.github/workflows/git-tag-modified-helm-chart.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Tag modified Helm Chart - -on: - workflow_call: {} - -permissions: - contents: write # to be able to publish a GitHub release - id-token: write # to enable use of OIDC for npm provenance - -jobs: - git-tag-modified-helm-chart: - name: Tag modified Helm Chart - runs-on: ubuntu-latest - steps: - - uses: openmcp-project/blueprint-building-blocks/.github/actions/git-tag-modified-helm-chart@main \ No newline at end of file diff --git a/.github/workflows/helm-charts-release-to-gh-oci.yml b/.github/workflows/helm-charts-release-to-gh-oci.yml index 520ead6..2b9fae7 100644 --- a/.github/workflows/helm-charts-release-to-gh-oci.yml +++ b/.github/workflows/helm-charts-release-to-gh-oci.yml @@ -1,8 +1,10 @@ name: Release Charts on: - workflow_call: {} workflow_dispatch: {} + push: + branches: + - main jobs: release: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 02a4cee..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Semantic Release - -on: - workflow_dispatch: {} - push: - branches: - - main - -permissions: - contents: write # to be able to publish a GitHub release - id-token: write # to enable use of OIDC for npm provenance - -jobs: - git-tag-modify-helm-chart: - name: Helm Chart Github Tags - uses: "openmcp-project/blueprint-building-blocks/.github/workflows/git-tag-modified-helm-chart.yml@main" - secrets: inherit - release: - name: Release - runs-on: ubuntu-latest - permissions: - contents: write # to be able to publish a GitHub release - issues: write # to be able to comment on released issues - pull-requests: write # to be able to comment on released pull requests - id-token: write # to enable use of OIDC for npm provenance - packages: write # to be able to publish a GitHub Packages - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.CO_GOLDEN_PATH_SERVICEUSER_GH_TOKEN }} - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ">=20.8" - check-latest: true - - name: Install dependencies - run: | - npm install semantic-release - npm install @semantic-release/changelog - npm install conventional-changelog-conventionalcommits - npm install @semantic-release/git - env: - GITHUB_TOKEN: ${{ secrets.CO_GOLDEN_PATH_SERVICEUSER_GH_TOKEN }} - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.CO_GOLDEN_PATH_SERVICEUSER_GH_TOKEN }} - run: npx semantic-release - git-release-create: - uses: "openmcp-project/blueprint-building-blocks/.github/workflows/gh-pages-release.yml@main" - name: Helm Chart Github Releases - needs: release - secrets: inherit - \ No newline at end of file diff --git a/scripts/ci/git-tags-rename.sh b/scripts/ci/git-tags-rename.sh deleted file mode 100755 index 9f7abd0..0000000 --- a/scripts/ci/git-tags-rename.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -################################################################### -#Script Name : Renaming Git Tags -#Description : Renames Git Tags with "/" to "-" -#Args : - -#Hint : This script is not meant for any pipeline just for cleanup! -################################################################### -# Fetch all tags from the remote -git fetch --tags - -# Get all tags -tags=$(git tag) - -# Loop through each tag -for tag in $tags; do - # Check if the tag contains "/" - if [[ "$tag" == *"/"* ]]; then - # Replace "/" with "-" - new_tag=$(echo "$tag" | tr '/' '-') - echo "new: $new_tag old: $tag" - # Rename the tag - git tag "$new_tag" "$tag" - git tag -d "$tag" - git push origin :"$tag" - git push origin "$new_tag" - fi -done diff --git a/scripts/ci/github-releases-delete.sh b/scripts/ci/github-releases-delete.sh deleted file mode 100755 index 8970c5b..0000000 --- a/scripts/ci/github-releases-delete.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -################################################################### -# Script Name : github-releases-delete.sh -# Description : This script deletes all GitHub releases in a repository. -# Args : --limit (optional) - The maximum number of releases to fetch. -################################################################### - -# Default limit -LIMIT=100 - -# Parse optional arguments -while [[ "$#" -gt 0 ]]; do - case $1 in - --limit) - LIMIT="$2" - shift - ;; - *) - echo "Unknown parameter passed: $1" - exit 1 - ;; - esac - shift -done - -# Ensure the GitHub CLI is authenticated -gh auth login --with-token <(echo "$GITHUB_TOKEN") - -echo "Fetch all releases (limit: $LIMIT)..." -releases=$(gh release list --limit "$LIMIT" --json tagName --jq '.[].tagName') - -# Loop through each release and delete it -count=0 -for release in $releases; do - echo "Deleting release: $release" - gh release delete "$release" --yes - count=$((count + 1)) -done - -echo "All $count releases have been deleted."