add target changelog which turns a package.xml into markdown

This commit is contained in:
Uwe Steinmann 2023-01-20 10:48:28 +01:00
parent 7bfc2c4602
commit 42828065ce

View File

@ -67,4 +67,31 @@ doc:
apidoc:
tools/apigen/bin/apigen SeedDMS_Core/Core --exclude "tests/*" --output html
.PHONY: doc webdav webapp repository
# Turn the package.xml file into CHANGELOG.md
#
# The idea is to form blocks of lines separated by an empty line.
# Echo block consists of the version number, release date und notes.
# This blocks are turned into single lines which are than sorted.
# Afterwards the single lines are turned back into blocks.
#
# It first uses sgrep to extract the version, date und notes. This is
# feed to sed to isolated the date and version and put them on separate
# lines. Each version
# forms a block of n lines with the first two being the version and date.
# All remaining lines are notes. Blocks are separated by an empty line.
# It's important to form blocks without ane empty lines because the following
# awk will create a single line from each block which can then be sorted
# (or simply reversed in order).
# Because the blocks are listed in the wrong order (last version first and
# previous version last, e.g. 5.1.29, 3.3.0, 3.3.1, ...., 5.1.27, 5.1.28) they
# need to be reversed in order. This is done by turning each block into line
# with the former new lines replaced by a '|'. So it's basically a '|' separated
# csv file which is then reversed in order by 'sort -r'. In order to separate
# blocks by a newline, each line of that output is appended by another
# line break. Result is put back
# into the original format by replacing all '|' by newline.
#
changelog:
@sgrep 'stag("DATE") .. etag("DATE") or ((stag("RELEASE") .. etag("RELEASE")) in (stag("VERSION") .. etag("VERSION"))) or inner(stag("NOTES") __ etag("NOTES"))' SeedDMS_Core/package.xml | sed -e 's#^ *<date>\([-0-9]*\)</date><release>\([0-9.]*\)</release>#\n\n\2 (\1)\n---------------------#' | awk -F'\n' -vRS='' -vOFS='|' '{$$1=$$1}1' | sort -V -r | sed 's/$$/\n/' | tr '|' '\n'
.PHONY: doc webdav webapp repository changelog