From f73b260a3a1373c2cde43b18da692efb3ef077bc Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 24 Sep 2025 08:20:08 +0200 Subject: [PATCH] release workflow: extract script for generating markdown release notes (cherry picked from commit 1519ea74bef3fab0926a4248fdf4ffb6d9478ee4) --- .github/workflows/release.yml | 45 ++++++----------------------------- build_tools/release-notes.sh | 37 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 38 deletions(-) create mode 100755 build_tools/release-notes.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ebd5c186b..df70f2631 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,44 +47,13 @@ jobs: set -x mkdir /tmp/fish-built FISH_ARTEFACT_PATH=/tmp/fish-built ./build_tools/make_tarball.sh - { - pip install sphinx-markdown-builder==0.6.8 - relnotes_tmp=$(mktemp -d) - mkdir "$relnotes_tmp/src" "$relnotes_tmp/out" - version=$(git describe) - minor_version=${version%.*} - changelog_for_this_version=$(awk "$relnotes_tmp/src"/index.rst \ - -e 's,:doc:`\(.*\) <\([^>]*\)>`,`\1 `_,g' \ - -e 's,:envvar:`\([^`]*\)`,``$\1``,g' \ - -e '$s/^----*$//' - - # In future, we could reuse doctree from when we made HTML docs. - sphinx-build -j 1 $(: "sphinx-markdown-builder is not marked concurrency-safe") \ - -W -E -b markdown -c doc_src \ - -d "$relnotes_tmp/doctree" "$relnotes_tmp/src" $relnotes_tmp/out - # Delete title - sed -n 1p "$relnotes_tmp/out/index.md" | grep -q "^# fish .*" - sed -n 2p "$relnotes_tmp/out/index.md" | grep -q '^$' - sed -i 1,2d "$relnotes_tmp/out/index.md" - { - cat "$relnotes_tmp/out/index.md" - </tmp/fish-built/release-notes.md - rm -r "$relnotes_tmp" - } + pip install sphinx-markdown-builder==0.6.8 + relnotes=/tmp/fish-built/release-notes.md + sh -x ./build_tools/release-notes.sh >"$relnotes" + # Delete title + sed -n 1p "$relnotes" | grep -q "^# fish .*" + sed -n 2p "$relnotes" | grep -q '^$' + sed -i 1,2d "$relnotes" - name: Upload tarball artifact uses: actions/upload-artifact@v4 with: diff --git a/build_tools/release-notes.sh b/build_tools/release-notes.sh new file mode 100755 index 000000000..d5242a694 --- /dev/null +++ b/build_tools/release-notes.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +workspace_root=$(dirname "$0")/.. + +relnotes_tmp=$(mktemp -d) +mkdir "$relnotes_tmp/src" "$relnotes_tmp/out" +version=$(sed 's,^fish \(\S*\) .*,\1,; 1q' "$workspace_root/CHANGELOG.rst") +minor_version=${version%.*} +changelog_for_this_version=$(awk <"$workspace_root/CHANGELOG.rst" ' + /^===/ { if (v++) { exit } } + { print } +' | sed '$d') +# Also fix up any relative references to other documentation files. +# Also remove spurious transitions at the end of the document. +printf %s "$changelog_for_this_version" | + sed >"$relnotes_tmp/src"/index.rst \ + -e 's,:doc:`\(.*\) <\([^>]*\)>`,`\1 `_,g' \ + -e 's,:envvar:`\([^`]*\)`,``$\1``,g' \ + -e '$s/^----*$//' + +# Use "-j 1" because sphinx-markdown-builder is not marked concurrency-safe. +sphinx-build >&2 -j 1 \ + -W -E -b markdown -c "$workspace_root/doc_src" \ + -d "$relnotes_tmp/doctree" "$relnotes_tmp/src" $relnotes_tmp/out "$@" +{ + cat "$relnotes_tmp/out/index.md" - <