From 66351f55db3e7f756b073ff8d28ee1dd1d44504a Mon Sep 17 00:00:00 2001 From: mikhail-klimko Date: Mon, 14 Oct 2024 15:01:09 +0300 Subject: [PATCH] feat: add changelog (#513) --- charts/cf-runtime/Chart.yaml | 6 ++-- charts/cf-runtime/README.md | 2 +- scripts/generate-changelog.sh | 53 +++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100755 scripts/generate-changelog.sh diff --git a/charts/cf-runtime/Chart.yaml b/charts/cf-runtime/Chart.yaml index 43cb5edc..92a9e213 100644 --- a/charts/cf-runtime/Chart.yaml +++ b/charts/cf-runtime/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 description: A Helm chart for Codefresh Runner name: cf-runtime -version: 6.4.4 +version: 6.4.5 keywords: - codefresh - runner @@ -17,8 +17,8 @@ annotations: artifacthub.io/containsSecurityUpdates: "false" # Supported kinds: `added`, `changed`, `deprecated`, `removed`, `fixed`, `security`: artifacthub.io/changes: | - - kind: security - description: "updating docker-puller with security fixes" + - kind: added + description: "add changelog into release" dependencies: - name: cf-common repository: oci://quay.io/codefresh/charts diff --git a/charts/cf-runtime/README.md b/charts/cf-runtime/README.md index 8b9d427e..df145184 100644 --- a/charts/cf-runtime/README.md +++ b/charts/cf-runtime/README.md @@ -1,6 +1,6 @@ ## Codefresh Runner -![Version: 6.4.4](https://img.shields.io/badge/Version-6.4.4-informational?style=flat-square) +![Version: 6.4.5](https://img.shields.io/badge/Version-6.4.5-informational?style=flat-square) Helm chart for deploying [Codefresh Runner](https://codefresh.io/docs/docs/installation/codefresh-runner/) to Kubernetes. diff --git a/scripts/generate-changelog.sh b/scripts/generate-changelog.sh new file mode 100755 index 00000000..f631e2aa --- /dev/null +++ b/scripts/generate-changelog.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Check if the correct number of arguments is provided +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign input arguments to variables +CHART_YAML="$1" +CHANGELOG_FILE="$2" + +# Check if the Chart.yaml file exists +if [ ! -f "$CHART_YAML" ]; then + echo "Error: Chart.yaml file not found at $CHART_YAML" + exit 1 +fi + +# Extract the artifacthub.io/changes section from the Chart.yaml +CHANGES=$(sed -n '/artifacthub.io\/changes: |/,/^dependencies:/p' "$CHART_YAML" | sed '1d;$d') + +echo $CHANGES + +# Create associative arrays to store changes by kind +declare -A changes_by_kind + +# Iterate through the changes and group them by kind +current_kind="" +while read -r line; do + if [[ $line == *"- kind:"* ]]; then + current_kind=$(echo "$line" | sed 's/.*kind: //') + # Initialize an empty array for the kind if it doesn't exist + if [[ -z "${changes_by_kind[$current_kind]}" ]]; then + changes_by_kind[$current_kind]="" + fi + elif [[ $line == *"description:"* ]]; then + description=$(echo "$line" | sed 's/.*description: "//;s/"//') + # Append the description to the corresponding kind + changes_by_kind[$current_kind]+="- $description"$'\n' + fi +done <<< "$CHANGES" + +# Create the CHANGELOG.md file and write the header +echo "# Changelog" > "$CHANGELOG_FILE" +echo "" >> "$CHANGELOG_FILE" + +# Write the changes grouped by kind to the CHANGELOG.md file +for kind in "${!changes_by_kind[@]}"; do + if [[ -n "${changes_by_kind[$kind]}" ]]; then + echo "## $kind" >> "$CHANGELOG_FILE" + echo "${changes_by_kind[$kind]}" >> "$CHANGELOG_FILE" + fi +done