Skip to content

Commit

Permalink
Add add-commit bash script and call it in helm-repo-update script and…
Browse files Browse the repository at this point in the history
… update CHANGELOG with commits as per new standard
  • Loading branch information
Hritik Batra committed Aug 23, 2024
1 parent da6d399 commit 44a0e0e
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ All releases and the changes included in them (pulled from git commits added sin
- Updated aws-efs-csi-driver from version 3.0.7 to 3.0.8
- Updated argo-cd from version 7.4.1 to 7.4.2

### KubeAid Improvements
- ca279e10 Update changelog format
- a553cce0 fixed the ingress alignment
- c78a3a5b small spelling fix and add log delition and garbage collection history
- 52b24a6d harbor clean up doc
- ca004f96 Fixed cilium template condition
- 044ed1b6 Added a readme file for azure cluster api
- 2e5db425 fix: fixed the env and secret name as per new object name for puppetserver
- 86a3774a fix: added namespace support to postgresql puppetserver
- 334bfb84 fixes:
- 62e841a7 Added a helm chart for azure cluster api
- 98f94caa Fixed Yaml linting
- d6f40a65 Added capz version
- edf3a588 Added Azure capz helm chart
- 5c93bc15 setup matomo in k8s

## 1.1.0
### Minor Changes
Expand Down
39 changes: 39 additions & 0 deletions bin/add-commits.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Get the latest tag from the changelog file
changelog_file="CHANGELOG.md"
latest_tag=$(grep -oP '^## \K[0-9]+\.[0-9]+\.[0-9]+' "$changelog_file" | head -n1)

echo "$latest_tag"

# Get the commit log since the latest tag
commit_log=$(git log "$latest_tag"..origin/master --oneline --no-merges)

# Format the commit log into bullet points
formatted_commit_log=$(echo "$commit_log" | awk '{print "- " $0}') # to keep sha in front
# formatted_commit_log=$(echo "$commit_log" | awk '{sha=$1; $1=""; print "-" $0" "sha}') # to keep sha later

# Create a temporary file for the formatted commit log
temp_file="temp.md"
{
echo "### KubeAid Improvements"
echo "$formatted_commit_log"
echo ""
} > "$temp_file"

# Update the changelog file
awk -v tag="## ${latest_tag}" -v file="$temp_file" '
$0 == tag {
while ((getline line < file) > 0) {
print line
}
}
{ print }
' "$changelog_file" > "${changelog_file}.tmp" && mv "${changelog_file}.tmp" "$changelog_file"

rm "$temp_file"

commit_msg="Add commit since ${latest_tag} tag to CHANGELOG.md"

git add CHANGELOG.md
git commit -m "$commit_msg"
12 changes: 11 additions & 1 deletion bin/helm-repo-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Usage $0 [OPTIONS]:
--actions Run inside a GitHub or Gitea Action [Default: false] (Only in CI)
--skip-charts Skip updating certain charts [Default: none]
--chart-version Helm chart version [Default: latest]
--add-commits Add commits since last tag in changelog [Default: false]
-h|--help
Example:
Expand All @@ -40,6 +41,7 @@ declare UPDATE_HELM_CHART=
declare SKIP_CHARTS=
declare ARGOCD_CHART_PATH="argocd-helm-charts"
declare CHART_VERSION=
declare ADD_COMMITS=false

[ $# -eq 0 ] && { ARGFAIL; exit 1; }

Expand Down Expand Up @@ -77,6 +79,9 @@ while [[ $# -gt 0 ]]; do

shift
;;
--add-commits)
ADD_COMMITS=true
;;
-h|--help)
ARGFAIL
exit
Expand Down Expand Up @@ -292,7 +297,7 @@ EOF
# Check if the current date section exists
if ! grep -q "^## $date" "$changelog_file"; then
sed -i "/All releases and the changes included in them (pulled from git commits added since last release) will be detailed in this file./a\\\n## $date" CHANGELOG.md
sed -i "/$date/a\\### Patch Changes %%^^\n" CHANGELOG.md
sed -i "/$date/a\\### Patch Changes %%^^" CHANGELOG.md
sed -i "/$date/a\\### Minor Changes %%^^\n" CHANGELOG.md
sed -i "/$date/a\\### Major Changes %%^^\n" CHANGELOG.md
fi
Expand Down Expand Up @@ -347,6 +352,11 @@ if "$UPDATE_ALL"; then
if [ "$ACTIONS" = false ]; then
git switch -c "$branch_name" --track origin/master
fi

if $ADD_COMMITS; then
bash ./bin/add-commits.sh
fi

while read -r path; do
# find ./"$ARGOCD_CHART_PATH" -maxdepth 1 -mindepth 1 -type d | sort | while read -r path; do
chart_name=$(basename "$path")
Expand Down

0 comments on commit 44a0e0e

Please sign in to comment.