From a6698098db933c7e173ab9199bac1a23d363a3e0 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 24 Sep 2025 09:04:00 +0200 Subject: [PATCH] release workflow: resolve relative references in changelog properly Instead of having sphinx-build only build CHANGELOG.rst, build the entire thing, so relative references (":doc:", ":ref:") can be resolved properly. Replace our sed-based hacks with 'markdown_http_base'. (cherry picked from commit 765ca54d59301836ae8a9404196eecb34b1b5c34) --- build_tools/release-notes.sh | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/build_tools/release-notes.sh b/build_tools/release-notes.sh index d5242a694..7b17b3bbd 100755 --- a/build_tools/release-notes.sh +++ b/build_tools/release-notes.sh @@ -5,27 +5,37 @@ set -e workspace_root=$(dirname "$0")/.. relnotes_tmp=$(mktemp -d) -mkdir "$relnotes_tmp/src" "$relnotes_tmp/out" +mkdir -p "$relnotes_tmp/fake-workspace" "$relnotes_tmp/out" +( + cd "$workspace_root" + cp -r doc_src CONTRIBUTING.rst README.rst "$relnotes_tmp/fake-workspace" +) 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. +' | sed '$d' +) +# 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/^----*$//' + sed -e '$s/^----*$//' >"$relnotes_tmp/fake-workspace"/CHANGELOG.rst # 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 "$@" + -d "$relnotes_tmp/doctree" "$relnotes_tmp/fake-workspace/doc_src" $relnotes_tmp/out \ + -D markdown_http_base="https://fishshell.com/docs/$minor_version" \ + -D markdown_uri_doc_suffix=".html" \ + "$@" + +# Delete changelog header +sed -n 1p "$relnotes_tmp/out/relnotes.md" | grep -Fxq "# Release notes" +sed -n 2p "$relnotes_tmp/out/relnotes.md" | grep -Fxq '' +sed -i 1,2d "$relnotes_tmp/out/relnotes.md" + { - cat "$relnotes_tmp/out/index.md" - <