diff --git a/tools/scripts/changelog.sh b/tools/scripts/changelog.sh index 3c3cc3132..980d6d120 100755 --- a/tools/scripts/changelog.sh +++ b/tools/scripts/changelog.sh @@ -25,7 +25,7 @@ START_TAG=${3:-""} LABEL_FEATURE=${LABEL_FEATURE:-"release/feature-new"} -LABEL_CHANGED=${LABEL_BUG:-"release/feature-changed"} +LABEL_CHANGED=${LABEL_CHANGED:-"release/feature-changed"} LABEL_BUG=${LABEL_BUG:-"release/bug"} PROJECT_REPO=${PROJECT_REPO:-""} [ -n "$PROJECT_REPO" ] || { echo "miss PROJECT_REPO"; exit 1 ; } @@ -39,7 +39,21 @@ echo "generate changelog to directory ${OUTPUT_DIR}" cd ${PROJECT_ROOT_PATH} #============================ +echo "-------------- generate latest release version tag --------------" +LATEST_RELEASE_VERISON=$(curl --retry 10 -s https://api.github.com/repos/spidernet-io/egressgateway/releases | grep '"tag_name":' | grep -Eo "v([0-9]+\.[0-9]+\.[0-9])" | sort -r | head -n 1) +LATEST_RELEASE_VERISON=` grep -oE "[0-9]+\.[0-9]+\.[0-9]+" <<< "${LATEST_RELEASE_VERISON}" ` +if [ -z "${LATEST_RELEASE_VERISON}" ] ; then + LATEST_X=0 + LATEST_Y=0 + LATEST_Z=0 +else + LATEST_X=${LATEST_RELEASE_VERISON%%.*} + TMP=${LATEST_RELEASE_VERISON%.*} + LATEST_Y=${TMP#*.} + LATEST_Z=${LATEST_RELEASE_VERISON##*.} +fi +#============================ ORIGIN_START_TAG=${START_TAG} if [ -z "${START_TAG}" ] ; then echo "-------------- generate start tag" @@ -61,8 +75,8 @@ if [ -z "${START_TAG}" ] ; then if (( V_X > 0 )); then START_X=$(( V_X - 1 )) # ?? - START_Y=0 - START_Z=0 + START_Y=$LATEST_Y + START_Z=$LATEST_Z else echo "error, $DEST_TAG, all 0" exit 0 @@ -128,7 +142,7 @@ for COMMIT in ${ALL_COMMIT} ; do # https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting # When using GITHUB_TOKEN, the rate limit is 1,000 requests per hour per repository # GitHub Enterprise Cloud's rate limit applies, and the limit is 15,000 requests per hour per repository. - COMMIT_INFO=` curl -s -H "Accept: application/vnd.github.groot-preview+json" -H "Authorization: Bearer ${GH_TOKEN}" https://api.github.com/repos/${PROJECT_REPO}/commits/${COMMIT}/pulls ` + COMMIT_INFO=` curl --retry 10 -s -H "Accept: application/vnd.github.groot-preview+json" -H "Authorization: Bearer ${GH_TOKEN}" https://api.github.com/repos/${PROJECT_REPO}/commits/${COMMIT}/pulls ` PR=` jq -r '.[].number' <<< "${COMMIT_INFO}" ` [ -n "${PR}" ] || { echo "warning, failed to find PR number for commit ${COMMIT} " ; echo "${COMMIT_INFO}" ; echo "" ; continue ; } if grep " ${PR} " <<< " ${PR_LIST} " &>/dev/null ; then @@ -162,6 +176,8 @@ echo "generate changelog md" FILE_CHANGELOG="${OUTPUT_DIR}/changelog_from_${START_TAG}_to_${DEST_TAG}.md" echo > ${FILE_CHANGELOG} echo "# ${DEST_TAG}" >> ${FILE_CHANGELOG} +echo "Welcome to the ${DEST_TAG} release of egressgateway!" >> ${FILE_CHANGELOG} +echo "Compared with version:${START_TAG}, version:${DEST_TAG} has the following updates." >> ${FILE_CHANGELOG} echo "" >> ${FILE_CHANGELOG} echo "***" >> ${FILE_CHANGELOG} echo "" >> ${FILE_CHANGELOG} @@ -199,7 +215,7 @@ if [ -n "${FIX_PR}" ]; then echo "" >> ${FILE_CHANGELOG} fi # -echo "## Totoal " >> ${FILE_CHANGELOG} +echo "## Total " >> ${FILE_CHANGELOG} echo "" >> ${FILE_CHANGELOG} echo "Pull request number: ${TOTAL_COUNT}" >> ${FILE_CHANGELOG} echo "" >> ${FILE_CHANGELOG}