.github: Reflect more kernel versions in the changelog

It happens that kernel update PRs are created faster than we merge
them. In such case we create version gaps in the changelog. Remedy
that by adding links to all the released kernel versions between the
current one and the just released one.
This commit is contained in:
Krzesimir Nowak 2021-12-20 17:22:35 +01:00
parent 108d8055d8
commit 5d3ffc9a27
2 changed files with 57 additions and 13 deletions

View File

@ -71,15 +71,36 @@ function regenerate_manifest() {
popd || exit popd || exit
} }
function join_by() {
local delimiter="${1-}"
local first="${2-}"
if shift 2; then
printf '%s' "${first}" "${@/#/${delimiter}}";
fi
}
function generate_update_changelog() { function generate_update_changelog() {
local NAME="${1}" local NAME="${1}"
local VERSION="${2}" local VERSION="${2}"
local URL="${3}" local URL="${3}"
local UPDATE_NAME="${4}" local UPDATE_NAME="${4}"
shift 4
local file="changelog/updates/$(date '+%Y-%m-%d')-${UPDATE_NAME}-update.md"
local -a old_links
pushd "${SDK_OUTER_SRCDIR}/third_party/coreos-overlay" >/dev/null || exit pushd "${SDK_OUTER_SRCDIR}/third_party/coreos-overlay" >/dev/null || exit
if [[ -d changelog/updates ]]; then if [[ -d changelog/updates ]]; then
echo "- ${NAME} ([${VERSION}](${URL}))" > "changelog/updates/$(date '+%Y-%m-%d')-${UPDATE_NAME}-update.md" printf '%s %s ([%s](%s)' '-' "${NAME}" "${VERSION}" "${URL}" > "${file}"
if [[ $# -gt 0 ]]; then
echo -n ' (includes ' >> "${file}"
while [[ $# -gt 1 ]]; do
old_links+=( "[${1}](${2})" )
shift 2
done
printf '%s' "$(join_by ', ' "${old_links[@]}")" >> "${file}"
echo -n ')' >> "${file}"
fi
echo ')' >> "${file}"
fi fi
popd >/dev/null || exit popd >/dev/null || exit
} }

View File

@ -36,19 +36,42 @@ done
popd >/dev/null || exit popd >/dev/null || exit
if ! curl -sfA 'Chrome' -L 'http://www.google.com/search?hl=en&q=site%3Alwn.net+linux+'"${VERSION_NEW}" -o search.html; then function get_lwn_link() {
echo 'curl failed' local LINUX_VERSION="${1}"
touch search.html local url
fi
# can't use grep -m 1 -o … to replace head -n 1, because all the links
# seem to happen in one line, so grep prints all the links in the line
URL=$({ grep -o 'https://lwn.net/Articles/[0-9]\+' search.html || true ; } | head -n 1)
if [[ ! "${URL}" ]]; then
URL="https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tag/?h=v${VERSION_NEW}"
fi
rm search.html
generate_update_changelog 'Linux' "${VERSION_NEW}" "${URL}" 'linux' if ! curl -sfA 'Chrome' -L 'http://www.google.com/search?hl=en&q=site%3Alwn.net+linux+'"${LINUX_VERSION}" -o search.html >&2; then
echo 'curl failed' >&2
touch search.html
fi
# can't use grep -m 1 -o … to replace head -n 1, because all the links
# seem to happen in one line, so grep prints all the links in the line
url=$({ grep -o 'https://lwn.net/Articles/[0-9]\+' search.html || true ; } | head -n 1)
if [[ ! "${url}" ]]; then
echo 'no valid links found in the search result' >&2
url="https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tag/?h=v${LINUX_VERSION}"
fi
rm search.html
echo "${url}"
}
PATCH_VERSION_OLD=${VERSION_OLD##*.}
PATCH_VERSION_NEW=${VERSION_NEW##*.}
PATCH_NUM=$((PATCH_VERSION_NEW - 1))
OLD_VERSIONS_AND_URLS=()
while [[ ${PATCH_NUM} -gt ${PATCH_VERSION_OLD} ]]; do
TMP_VERSION="${VERSION_SHORT}.${PATCH_NUM}"
TMP_URL=$(get_lwn_link "${TMP_VERSION}")
OLD_VERSIONS_AND_URLS+=( "${TMP_VERSION}" "${TMP_URL}" )
: $((PATCH_NUM--))
done
URL=$(get_lwn_link "${VERSION_NEW}")
generate_update_changelog 'Linux' "${VERSION_NEW}" "${URL}" 'linux' "${OLD_VERSIONS_AND_URLS[@]}"
generate_patches sys-kernel coreos-sources Kernel generate_patches sys-kernel coreos-sources Kernel