Skip to content

Commit 7e0de01

Browse files
committed
Add workflows/generate-release-notes.yml and release-notes/v2.13.adoc
1 parent 8d8a76e commit 7e0de01

File tree

4 files changed

+420
-4
lines changed

4 files changed

+420
-4
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
-- This filter transforms Asciidoctor's admonition blocks into GitHub Flavored Markdown alerts.
2+
3+
-- This filter works by finding a Div with class "admonitionblock", then
4+
-- walking its contents to find the table cell (<td>) with class "content".
5+
-- It then extracts the content of that cell, prepends a GFM alert header
6+
-- like "[!NOTE]", and wraps the whole thing in a blockquote.
7+
8+
-- Define a walker to find the content cell.
9+
-- We use a variable in the parent scope to store the result.
10+
local content_cell_blocks = nil
11+
local walker = {
12+
Cell = function(cell)
13+
-- The admonition content is in a cell with class "content".
14+
if cell.attr.classes:includes('content') then
15+
content_cell_blocks = cell.content
16+
end
17+
return cell
18+
end
19+
}
20+
21+
function Div(div)
22+
-- Asciidoctor creates a div with class "admonitionblock" and a second class
23+
-- for the type (e.g., "note", "important").
24+
if not div.classes:includes("admonitionblock") then
25+
return div -- Not an admonition block, do nothing.
26+
end
27+
28+
-- Determine the admonition type from the div's classes.
29+
local admonition_type = ""
30+
local type_map = { note = "NOTE", important = "IMPORTANT", tip = "TIP", warning = "WARNING", caution = "CAUTION" }
31+
for class, type in pairs(type_map) do
32+
if div.classes:includes(class) then
33+
admonition_type = type
34+
break
35+
end
36+
end
37+
38+
if admonition_type == "" then
39+
return div -- Unknown admonition type, do nothing.
40+
end
41+
42+
-- Reset and run the walker to find the content cell's blocks.
43+
content_cell_blocks = nil
44+
pandoc.walk_block(div, walker)
45+
46+
if content_cell_blocks then
47+
-- The cell content is wrapped in further divs (e.g., class="paragraph").
48+
-- We need to extract the actual content blocks from them.
49+
local extracted_blocks = {}
50+
for _, block in ipairs(content_cell_blocks) do
51+
if block.t == 'Div' and block.content then
52+
for _, inner_block in ipairs(block.content) do
53+
table.insert(extracted_blocks, inner_block)
54+
end
55+
else
56+
table.insert(extracted_blocks, block)
57+
end
58+
end
59+
60+
-- Create the GFM alert header, e.g., '[!IMPORTANT]'
61+
local alert_header = pandoc.Para{
62+
pandoc.RawInline('markdown', '[!' .. admonition_type .. ']')
63+
}
64+
65+
-- Prepend the header and wrap everything in a BlockQuote.
66+
table.insert(extracted_blocks, 1, alert_header)
67+
return pandoc.BlockQuote(extracted_blocks)
68+
end
69+
70+
-- If we didn't find a content cell, return the div unchanged.
71+
return div
72+
end
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# .github/workflows/generate-release.yml
2+
name: Generate and Store Release Notes
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'The release version (e.g., v2.13)'
9+
required: true
10+
default: 'v2.13'
11+
12+
jobs:
13+
build-and-commit:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write # Needed to create the release
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Ruby for Asciidoctor
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: '3.1' # Or any recent version
26+
bundler-cache: true
27+
28+
- name: Install Asciidoctor
29+
run: gem install asciidoctor
30+
31+
- name: Install Pandoc
32+
run: sudo apt-get update && sudo apt-get install -y pandoc
33+
34+
- name: Convert AsciiDoc to HTML
35+
run: |
36+
VERSION=${{ inputs.version }}
37+
INPUT_FILE="versions/v${VERSION}/modules/en/pages/release-notes/${VERSION}.adoc"
38+
OUTPUT_FILE="${VERSION}.html"
39+
40+
if [ ! -f "$INPUT_FILE" ]; then
41+
echo "Error: Input file $INPUT_FILE not found."
42+
exit 1
43+
fi
44+
45+
asciidoctor -o "$OUTPUT_FILE" "$INPUT_FILE"
46+
47+
- name: Convert HTML to GitHub-Flavored Markdown
48+
run: |
49+
VERSION=${{ inputs.version }}
50+
HTML_FILE="${VERSION}.html"
51+
MARKDOWN_FILE="${VERSION}.md"
52+
53+
pandoc --from html-native_divs \
54+
--to gfm \
55+
--lua-filter=./.github/workflows/filters/admonition-filter.lua \
56+
--output "$MARKDOWN_FILE" \
57+
"$HTML_FILE"
58+
59+
- name: Push HTML and Markdown to release-notes branch
60+
uses: ad-m/github-push-action@master
61+
with:
62+
github_token: ${{ secrets.GITHUB_TOKEN }}
63+
branch: release-notes
64+
force: true
65+
tags: false
66+
files: |
67+
${{ inputs.version }}.html
68+
${{ inputs.version }}.md
69+
commit_message: 'docs: Add release notes for v${{ inputs.version }}'

versions/v2.13/modules/en/pages/release-notes.adoc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
ifeval::["{build-type}" != "srfa"]
33
:page-languages: [en, zh]
44
endif::[]
5-
:revdate: 2025-11-18
5+
:revdate: 2025-12-09
66
:page-revdate: {revdate}
77

88
== Current Version
99

1010
|===
1111
| Version | Release Notes | Support Matrix | Prime | Community
1212

13-
| v2.12.4
14-
| https://github.com/rancher/rancher/releases/tag/v2.12.4[View]
13+
| v2.13.0
14+
| xref:release-notes/v2.13.adoc[View] / https://github.com/rancher/rancher/releases/tag/v2.13.0[GitHub Release]
15+
| N/A
1516
| N/A
16-
| &#10003;
1717
| N/A
1818
|===
1919

@@ -22,6 +22,12 @@ endif::[]
2222
|===
2323
| Version | Release Notes | Support Matrix | Prime | Community
2424

25+
| v2.12.4
26+
| https://github.com/rancher/rancher/releases/tag/v2.12.4[View]
27+
| N/A
28+
| &#10003;
29+
| N/A
30+
2531
| v2.12.3
2632
| https://github.com/rancher/rancher/releases/tag/v2.12.3[View]
2733
| https://www.suse.com/suse-rancher/support-matrix/all-supported-versions/rancher-v2-12-3/[View]

0 commit comments

Comments
 (0)