diff --git a/changes/ee/feat-9932-en.md b/changes/ee/feat-9932.en.md similarity index 100% rename from changes/ee/feat-9932-en.md rename to changes/ee/feat-9932.en.md diff --git a/changes/ee/feat-9932-zh.md b/changes/ee/feat-9932.zh.md similarity index 100% rename from changes/ee/feat-9932-zh.md rename to changes/ee/feat-9932.zh.md diff --git a/scripts/changelog-lang-templates/en b/scripts/changelog-lang-templates/en deleted file mode 100644 index 05c218c7e..000000000 --- a/scripts/changelog-lang-templates/en +++ /dev/null @@ -1,12 +0,0 @@ -# ${version} - -## Enhancements - -$(section feat) - -$(section perf) - -## Bug fixes - -$(section fix) - diff --git a/scripts/changelog-lang-templates/zh b/scripts/changelog-lang-templates/zh deleted file mode 100644 index 2bafd99d7..000000000 --- a/scripts/changelog-lang-templates/zh +++ /dev/null @@ -1,12 +0,0 @@ -# ${version} - -## 增强 - -$(section feat) - -$(section perf) - -## 修复 - -$(section fix) - diff --git a/scripts/format-changelog.sh b/scripts/format-changelog.sh deleted file mode 100755 index 87fbc60a2..000000000 --- a/scripts/format-changelog.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -set -euo pipefail -shopt -s nullglob -export LANG=C.UTF-8 - -[ "$#" -ne 4 ] && { - echo "Usage $0 " 1>&2; - exit 1 -} - -profile="${1}" -last_tag="${2}" -version="${3}" -output_dir="${4}" -languages=("en" "zh") -top_dir="$(git rev-parse --show-toplevel)" -templates_dir="$top_dir/scripts/changelog-lang-templates" -declare -a changes -changes=("") - -echo "generated changelogs from tag:${last_tag} to HEAD" - -item() { - local filename pr indent - filename="${1}" - pr="$(echo "${filename}" | sed -E 's/.*-([0-9]+)\.[a-z]+\.md$/\1/')" - indent="- [#${pr}](https://github.com/emqx/emqx/pull/${pr}) " - while read -r line; do - echo "${indent}${line}" - indent=" " - done < "${filename}" - echo -} - -section() { - local prefix=$1 - for file in "${changes[@]}"; do - if [[ $file =~ .*$prefix-.*$language.md ]]; then - item "$file" - fi - done -} - -generate() { - local language=$1 - local output="$output_dir/${version}_$language.md" - local template_file="$templates_dir/$language" - local template - if [ -f "$template_file" ]; then - template=$(cat "$template_file") - eval "echo \"$template\" > $output" - else - echo "Invalid language ${language}" 1>&2; - exit 1 - fi -} - -changes_dir=("$top_dir/changes/ce") -if [ "$profile" == "emqx-enterprise" ]; then - changes_dir+=("$top_dir/changes/ee") -fi - -while read -d "" -r file; do - changes+=("$file") -done < <(git diff --name-only -z -a "tags/${last_tag}...HEAD" "${changes_dir[@]}") - -for language in "${languages[@]}"; do - generate "$language" -done diff --git a/scripts/rel/cut.sh b/scripts/rel/cut.sh index 8d00694ac..60fe2f28d 100755 --- a/scripts/rel/cut.sh +++ b/scripts/rel/cut.sh @@ -223,9 +223,9 @@ generate_changelog () { from_tag="$(git describe --tags --abbrev=0 --match 'e*')" fi fi - local output_dir="changes" - ./scripts/format-changelog.sh $PROFILE "${from_tag}" "${TAG}" $output_dir - git add $output_dir + ./scripts/rel/format-changelog.sh -b "${from_tag}" -l 'en' -v "$TAG" > "changes/${TAG}.en.md" + ./scripts/rel/format-changelog.sh -b "${from_tag}" -l 'zh' -v "$TAG" > "changes/${TAG}.zh.md" + git add changes/"${TAG}".*.md [ -n "$(git status -s)" ] && git commit -m "chore: Generate changelog for ${TAG}" } diff --git a/scripts/rel/format-changelog.sh b/scripts/rel/format-changelog.sh new file mode 100755 index 000000000..3561ad55c --- /dev/null +++ b/scripts/rel/format-changelog.sh @@ -0,0 +1,143 @@ +#!/bin/bash +set -euo pipefail +shopt -s nullglob +export LANG=C.UTF-8 + +logerr() { + echo "$(tput setaf 1)ERROR: $1$(tput sgr0)" 1>&2 +} + +usage() { + cat <