Skip to content

Commit

Permalink
feat: add changelog (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-klimko authored Oct 14, 2024
1 parent 4286302 commit 66351f5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
6 changes: 3 additions & 3 deletions charts/cf-runtime/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cf-runtime/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
53 changes: 53 additions & 0 deletions scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <path_to_Chart.yaml> <path_to_CHANGELOG.md>"
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

0 comments on commit 66351f5

Please sign in to comment.