mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-03 19:42:15 +02:00
.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:
parent
108d8055d8
commit
5d3ffc9a27
@ -71,15 +71,36 @@ function regenerate_manifest() {
|
||||
popd || exit
|
||||
}
|
||||
|
||||
function join_by() {
|
||||
local delimiter="${1-}"
|
||||
local first="${2-}"
|
||||
if shift 2; then
|
||||
printf '%s' "${first}" "${@/#/${delimiter}}";
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_update_changelog() {
|
||||
local NAME="${1}"
|
||||
local VERSION="${2}"
|
||||
local URL="${3}"
|
||||
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
|
||||
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
|
||||
popd >/dev/null || exit
|
||||
}
|
||||
|
@ -36,19 +36,42 @@ done
|
||||
|
||||
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
|
||||
echo 'curl failed'
|
||||
function get_lwn_link() {
|
||||
local LINUX_VERSION="${1}"
|
||||
local url
|
||||
|
||||
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
|
||||
URL="https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tag/?h=v${VERSION_NEW}"
|
||||
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}"
|
||||
}
|
||||
|
||||
generate_update_changelog 'Linux' "${VERSION_NEW}" "${URL}" 'linux'
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user