Support RCs for changelogs (#1419)

This commit is contained in:
Roy Keene 2018-11-30 18:45:12 -06:00 committed by GitHub
commit e040fdaa12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 18 deletions

View file

@ -35,13 +35,13 @@ function milestones () {
) | sort -rV
}
function milestone_to_tag_date () {
local milestone
function tag_to_tag_date () {
local tag
local tag_url
milestone="$1"
tag="$1"
tag_url="$(_curl "https://api.github.com/repos/${repository}/git/refs/tags/${milestone}" | jq -r '.object.url')" || return 1
tag_url="$(_curl "https://api.github.com/repos/${repository}/git/refs/tags/${tag}" | jq -r 'if (type == "object") then . else .[] end | select(.ref=="refs/tags/'"${tag}"'") | .object.url')" || return 1
_curl "${tag_url}" | jq -r '.tagger.date | fromdateiso8601 | strftime("%Y-%m-%d")' 2>/dev/null || \
_curl "${tag_url}" | jq -r '.committer.date | fromdateiso8601 | strftime("%Y-%m-%d")' || return 1
}
@ -54,8 +54,19 @@ function parts_of_milestone () {
milestone_id="$2"
for state in closed open; do
_curl "https://api.github.com/repos/${repository}/issues?milestone=${milestone_id}&state=${state}" | \
jq -r '.[] | [.html_url, .number, .title, (.labels[] | .name)] | @tsv' || return 1
page='0'
while true; do
page=$[${page} + 1]
data="$(_curl "https://api.github.com/repos/${repository}/issues?milestone=${milestone_id}&state=${state}&page=${page}")"
item_count="$(echo "${data}" | jq -r '. | length')"
if [ "${item_count}" = '0' ]; then
break
fi
echo "${data}" | \
jq -r '.[] | [.html_url, .number, .title, (.labels[] | .name)] | @tsv' || return 1
done
done
}
@ -78,7 +89,7 @@ function print_item () {
function changelog () {
local repository start_tag flags_list
local milestones_info previous_milestones previous_milestone
local milestone_name previous_milestone_name milestone_date
local milestone_name previous_milestone_name milestone_date tag_name
local itemToTags itemToName itemURL categoryIds categoryId
local majorIds item_url item_id item_name item_tags skip_item
local category is_major breaking
@ -119,12 +130,16 @@ function changelog () {
else
start_output='true'
fi
start_tag_check="$(echo "${start_tag}" | sed 's@RC[0-9]*$@@')"
while IFS=$'\t' read -r milestone_name milestone_id; do
echo "Processing milestone: ${milestone_name}..." >&2
echo "Processing milestone: ${milestone_name} ..." >&2
tag_name="${milestone_name}"
if [ "${start_output}" = 'false' ]; then
if [ "${milestone_name}" = "${start_tag}" ]; then
if [ "${milestone_name}" = "${start_tag_check}" ]; then
start_output='true'
tag_name="${start_tag}"
fi
fi
@ -132,16 +147,16 @@ function changelog () {
continue
fi
milestone_date="$(milestone_to_tag_date "${milestone_name}")" || milestone_date=''
milestone_date="$(tag_to_tag_date "${tag_name}")" || milestone_date=''
previous_milestone_name="${previous_milestones[${milestone_name}]}"
if [ -z "${milestone_date}" -o -z "${previous_milestone_name}" ]; then
continue
fi
echo "## Release [${milestone_name}](https://github.com/nanocurrency/raiblocks/tree/${milestone_name}) (${milestone_date})"
echo "## Release [${tag_name}](https://github.com/nanocurrency/raiblocks/tree/${tag_name}) (${milestone_date})"
echo ""
echo "[Full Changelog](https://github.com/nanocurrency/raiblocks/compare/${previous_milestone_name}...${milestone_name})"
echo "[Full Changelog](https://github.com/nanocurrency/raiblocks/compare/${previous_milestone_name}...${tag_name})"
echo ""
unset itemToTags itemToName itemURL categoryIds

View file

@ -35,16 +35,18 @@ function make_source () {
tarball_creation
}
function source_information () {
local version_no_rc
local changelog_args
version_no_rc="$(echo "${VERSION}" | sed 's@RC[0-9]*$@@')"
DATE=`git log --tags --simplify-by-decoration --pretty="format:%ai %d" | head -1 |cut -d " " -f1-3`
COMMIT=`git log | head -1 | cut -d " " -f 2`
TAG_DATE=`TZ=UTC date -d"$DATE" +%s`
"${scriptDir}/changelog_generator" nanocurrency/raiblocks "V${version_no_rc}"
case "${VERSION}" in
*RC*)
"${scriptDir}/changelog_generator" nanocurrency/raiblocks "V${VERSION}" only
;;
*)
"${scriptDir}/changelog_generator" nanocurrency/raiblocks "V${VERSION}"
;;
esac
if [ ! -s CHANGELOG.md ]; then
echo "CHANGELOG not generated"