From 772d59204949dffa32dde5c9efcd31e8e3868d06 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Fri, 8 Dec 2023 20:15:50 +0700 Subject: [PATCH] Add script to generate chart CHANGELOG after released (#2054) Signed-off-by: Viet Nguyen Duc --- .github/workflows/helm-chart-release.yml | 15 +++++ charts/selenium-grid/CHANGELOG.md | 19 +++++- generate_chart_changelog.sh | 85 ++++++++++++++++++++++++ update_tag_in_docs_and_files.sh | 4 +- 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100755 generate_chart_changelog.sh diff --git a/.github/workflows/helm-chart-release.yml b/.github/workflows/helm-chart-release.yml index 252ca1840..5d3ee3f2b 100644 --- a/.github/workflows/helm-chart-release.yml +++ b/.github/workflows/helm-chart-release.yml @@ -27,3 +27,18 @@ jobs: uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Update chart CHANGELOG + run: ./generate_chart_changelog.sh + + - name: Commit files + run: | + git config --local user.email "selenium-ci@users.noreply.github.com" + git config --local user.name "Selenium CI Bot" + git commit -m "Update chart CHANGELOG [skip ci]" -a + + - name: Push changes + uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # master + with: + github_token: ${{ secrets.SELENIUM_CI_TOKEN }} + branch: trunk diff --git a/charts/selenium-grid/CHANGELOG.md b/charts/selenium-grid/CHANGELOG.md index 4f3e5f405..2642b79eb 100644 --- a/charts/selenium-grid/CHANGELOG.md +++ b/charts/selenium-grid/CHANGELOG.md @@ -1,6 +1,21 @@ -# Change Log +## :heavy_check_mark: selenium-grid-0.26.0 -All notable changes to this helm chart will be documented in this file. +- Chart is using image tag 4.16.0-20231206 + +### Added +- feat(chart): Add default annotations for ingress nginx controller (#2047) :: Viet Nguyen Duc +- feat: Video image with based FFmpeg-6.1 on Ubuntu-22.04 (#2042) :: Viet Nguyen Duc + +### Fixed +- bug(#1824): Container ENV SE_NODE_SESSION_TIMEOUT not take effect (#2044) :: Viet Nguyen Duc +- bug(#2038): Rollback io.opentelemetry 1.31.0 - add test tracing enabled (#2040) :: Viet Nguyen Duc + +### Changed +- Update tag in docs and files :: Selenium CI Bot +- Update chart CHANGELOG [skip ci] :: Viet Nguyen Duc +- test(chart): Parallel tests execution against autoscaling in Kubernetes (#2046) :: Viet Nguyen Duc +- test(chart): Chart template render and assert output (#2043) :: Viet Nguyen Duc +- test(chart): Add test for setting registry to pull images (#2036) :: Viet Nguyen Duc ## :heavy_check_mark: 0.25.3 diff --git a/generate_chart_changelog.sh b/generate_chart_changelog.sh new file mode 100755 index 000000000..4afaedfb6 --- /dev/null +++ b/generate_chart_changelog.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# Specify the output file for the CHANGELOG +CHART_DIR="./charts/selenium-grid" +CHANGELOG_FILE="./charts/selenium-grid/CHANGELOG.md" +TAG_PATTERN="selenium-grid" + +# Get current chart app version +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:]') + +# Generate the changelog +generate_changelog() { + # Get a list of tags sorted by commit date + tags=($(git tag --sort=committerdate | grep "^$TAG_PATTERN")) + tags_size=${#tags[@]} + + # Check if there are tags + if [ ${#tags[@]} -eq 0 ]; then + commit_range="HEAD" + elif [ ${#tags[@]} -eq 1 ]; then + previous_tag="${tags[$tags_size-1]}" + current_tag="HEAD" + commit_range="${previous_tag}..${current_tag}" + else + previous_tag="${tags[$tags_size-2]}" + current_tag="${tags[$tags_size-1]}" + commit_range="${previous_tag}..${current_tag}" + fi + + # Get the changes for each section (Added, Removed, Fixed, Changed) + image_tag_changes=$(echo "Chart is using image tag $CHART_APP_VERSION" | sed -e 's/^/- /') + added_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iE "^feat|^add" | sed -e 's/^/- /') + removed_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iE "^remove|^deprecate|^delete" | sed -e 's/^/- /') + fixed_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iE "^fix|^bug" | sed -e 's/^/- /') + changed_changes=$(git log --pretty=format:"%s :: %an" "$commit_range" -- "$CHART_DIR" | grep -iEv "^feat|^add|^remove|^deprecate|^delete|^fix|^bug" | sed -e 's/^/- /') + + if [[ $(cat $CHANGELOG_FILE) == *"${current_tag}"* ]]; then + echo "Changelog already generated for ${current_tag}" + exit 0 + fi + + # Create a temporary file + temp_file=$(mktemp) + + # Write to the temporary file + echo "## :heavy_check_mark: ${current_tag}" >> "$temp_file" + echo "" >> "$temp_file" + echo "$image_tag_changes" >> "$temp_file" + echo "" >> "$temp_file" + + if [ -n "$added_changes" ]; then + echo "### Added" >> "$temp_file" + echo "$added_changes" >> "$temp_file" + echo "" >> "$temp_file" + fi + + if [ -n "$removed_changes" ]; then + echo "### Removed" >> "$temp_file" + echo "$removed_changes" >> "$temp_file" + echo "" >> "$temp_file" + fi + + if [ -n "$fixed_changes" ]; then + echo "### Fixed" >> "$temp_file" + echo "$fixed_changes" >> "$temp_file" + echo "" >> "$temp_file" + fi + + if [ -n "$changed_changes" ]; then + echo "### Changed" >> "$temp_file" + echo "$changed_changes" >> "$temp_file" + echo "" >> "$temp_file" + fi + + # Append the existing content of CHANGELOG to the temporary file + cat "$CHANGELOG_FILE" >> "$temp_file" + + # Overwrite CHANGELOG with the content of the temporary file + mv "$temp_file" "$CHANGELOG_FILE" +} + +# Run the function to generate the changelog +generate_changelog + +echo "Changelog generated successfully at $CHANGELOG_FILE" diff --git a/update_tag_in_docs_and_files.sh b/update_tag_in_docs_and_files.sh index 3783f30f5..135b06b1a 100755 --- a/update_tag_in_docs_and_files.sh +++ b/update_tag_in_docs_and_files.sh @@ -11,14 +11,14 @@ echo -e "\033[0;32m LATEST_TAG -> ${LATEST_TAG}\033[0m" echo -e "\033[0;32m NEXT_TAG -> ${NEXT_TAG}\033[0m" # If you want to test this locally and you are using macOS, do `brew install gnu-sed` and change `sed` for `gsed`. -find . \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/${LATEST_TAG}/${NEXT_TAG}/g" +find . \( -type d -name .git -prune \) -o -type f ! -name 'CHANGELOG.md' -print0 | xargs -0 sed -i "s/${LATEST_TAG}/${NEXT_TAG}/g" echo -e "\033[0;32m Updating date used in some docs and files...\033[0m" echo -e "\033[0;32m LATEST_DATE -> ${LATEST_DATE}\033[0m" echo -e "\033[0;32m NEXT_DATE -> ${NEXT_DATE}\033[0m" # If you want to test this locally and you are using macOS, do `brew install gnu-sed` and change `sed` for `gsed`. -find . \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/${LATEST_DATE}/${NEXT_DATE}/g" +find . \( -type d -name .git -prune \) -o -type f ! -name 'CHANGELOG.md' -print0 | xargs -0 sed -i "s/${LATEST_DATE}/${NEXT_DATE}/g" # Bump chart version and appVersion if next tag is different if [ "$latest_chart_app_version" == $LATEST_TAG ] && [ "$latest_chart_app_version" != "$NEXT_TAG" ]; then