Skip to content

Commit 9247659

Browse files
committed
build(chart): change log and release notes for helm chart
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 99222fc commit 9247659

File tree

5 files changed

+35
-43
lines changed

5 files changed

+35
-43
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
run: echo ${LATEST_TAG}
5050
- name: Update tag in docs and files
5151
run: ./update_tag_in_docs_and_files.sh ${LATEST_TAG} ${NEXT_TAG}
52+
- name: Update chart CHANGELOG
53+
run: ./generate_chart_changelog.sh HEAD
5254
- name: Build images
5355
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
5456
- name: Login Docker Hub

.github/workflows/helm-chart-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ jobs:
2525
git config user.name "$GITHUB_ACTOR"
2626
git config user.email "[email protected]"
2727
28+
- name: Get chart release notes (chart_release_notes.md)
29+
run: ./generate_chart_changelog.sh HEAD
30+
2831
- name: Run chart-releaser
2932
uses: helm/chart-releaser-action@main
3033
with:
3134
mark_as_latest: false
3235
skip_existing: true
3336
env:
3437
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
38+
CR_RELEASE_NOTES_FILE: RELEASE_NOTES.md

.github/workflows/update-chart-changelog.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,4 @@ ENV/
151151
/charts/*/charts
152152
/charts/*/**.lock
153153
/charts/*.tgz
154+
/charts/*/RELEASE_NOTES.md

generate_chart_changelog.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
CHART_DIR="./charts/selenium-grid"
55
CHANGELOG_FILE="./charts/selenium-grid/CHANGELOG.md"
66
TAG_PATTERN="selenium-grid"
7+
SET_TAG=${1:-""}
78

89
# Get current chart app version
910
CHART_APP_VERSION=$(find . \( -type d -name .git -prune \) -o -type f -name 'Chart.yaml' -print0 | xargs -0 cat | grep ^appVersion | cut -d ':' -f 2 | tr -d '[:space:]')
@@ -27,24 +28,27 @@ generate_changelog() {
2728
commit_range="${previous_tag}..${current_tag}"
2829
fi
2930

31+
change_title=$current_tag
32+
if [ "$SET_TAG" = "HEAD" ]; then
33+
current_tag="${SET_TAG}"
34+
CURRENT_CHART_VERSION=$(find . \( -type d -name .git -prune \) -o -type f -name 'Chart.yaml' -print0 | xargs -0 cat | grep ^version | cut -d ':' -f 2 | tr -d '[:space:]')
35+
change_title="${TAG_PATTERN}-${CURRENT_CHART_VERSION}"
36+
fi
37+
echo "Generating changelog for ${change_title}"
38+
3039
# Get the changes for each section (Added, Removed, Fixed, Changed)
3140
image_tag_changes=$(echo "Chart is using image tag $CHART_APP_VERSION" | sed -e 's/^/- /')
32-
k8s_versions_tested=$(echo "Chart is tested on Kubernetes versions: $(cat .github/workflows/helm-chart-test.yml | grep -oP "k8s-version: '\Kv.*(?=')" | tr '\n' ',')")
41+
k8s_versions_tested=$(echo "Chart is tested on Kubernetes versions: $(cat .github/workflows/helm-chart-test.yml | grep -oP "k8s-version: '\Kv.*(?=')" | tr '\n' ' ')" | sed -e 's/^/- /')
3342
added_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iE "^feat|^add" | sed -e 's/^/- /')
3443
removed_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iE "^remove|^deprecate|^delete" | sed -e 's/^/- /')
3544
fixed_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iE "^fix|^bug" | sed -e 's/^/- /')
3645
changed_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iEv "^feat|^add|^remove|^deprecate|^delete|^fix|^bug" | sed -e 's/^/- /')
3746

38-
if [[ $(cat $CHANGELOG_FILE) == *"${current_tag}"* ]]; then
39-
echo "Changelog already generated for ${current_tag}"
40-
exit 0
41-
fi
42-
4347
# Create a temporary file
4448
temp_file=$(mktemp)
4549

4650
# Write to the temporary file
47-
echo "## :heavy_check_mark: ${current_tag}" >> "$temp_file"
51+
echo "## :heavy_check_mark: ${change_title}" >> "$temp_file"
4852
echo "" >> "$temp_file"
4953
echo "$image_tag_changes" >> "$temp_file"
5054
echo "$k8s_versions_tested" >> "$temp_file"
@@ -74,11 +78,26 @@ generate_changelog() {
7478
echo "" >> "$temp_file"
7579
fi
7680

81+
# Create chart_release_notes.md
82+
release_notes_file="$CHART_DIR/RELEASE_NOTES.md"
83+
chart_description=$(find . \( -type d -name .git -prune \) -o -type f -name 'Chart.yaml' -print0 | xargs -0 cat | grep ^description | cut -d ':' -f 2)
84+
echo "$chart_description" > "$release_notes_file"
85+
echo "" >> "$release_notes_file"
86+
cat $temp_file >> "$release_notes_file"
87+
echo "Generated release notes at $release_notes_file"
88+
7789
# Append the existing content of CHANGELOG to the temporary file
7890
cat "$CHANGELOG_FILE" >> "$temp_file"
7991

80-
# Overwrite CHANGELOG with the content of the temporary file
81-
mv "$temp_file" "$CHANGELOG_FILE"
92+
if [[ $(cat $CHANGELOG_FILE) == *"${change_title}"* ]]; then
93+
echo "Changelog already generated for ${change_title}"
94+
rm -rf "$temp_file"
95+
exit 0
96+
else
97+
# Overwrite CHANGELOG with the content of the temporary file
98+
mv "$temp_file" "$CHANGELOG_FILE"
99+
fi
100+
82101
}
83102

84103
# Run the function to generate the changelog

0 commit comments

Comments
 (0)