Skip to content

Commit d71cf84

Browse files
EgorPopelyaevsandreim
authored andcommitted
[Release|CI/CD] Add templates to publish release info texts and list of the released crates in release draft (#10455)
Closes: paritytech/release-engineering#276 --------- Co-authored-by: Andrei Sandu <[email protected]> (cherry picked from commit 1e5c58b)
1 parent 6f4dfc7 commit d71cf84

File tree

5 files changed

+123
-1
lines changed

5 files changed

+123
-1
lines changed

.github/workflows/release-30_publish_release_draft.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ jobs:
126126
fi
127127
echo "REL_TAG=$REF2" >> $GITHUB_ENV
128128
export VERSION=$(echo "$REF2" | sed -E 's/.*(stable[0-9]{4}(-[0-9]+)?).*$/\1/')
129-
130129
echo "Version: $VERSION"
131130
131+
if [[ ${NO_RUNTIMES} == "true" || ${CRATES_ONLY} == "true" ]]; then
132+
export STABLE_VERSION=$(sed -E 's/.*(stable[0-9]{4}).*$/\1/' <<< "$VERSION")
133+
export NODE_VERSION=v$(get_polkadot_node_version_from_code)
134+
fi
135+
132136
./scripts/release/build-changelogs.sh
133137
134138
- name: Archive artifact context.json
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Script to parse changed_crates file and extract crate names with versions.
4+
Extracts lines with 'name = "..."' and '+to = "..."' patterns and writes
5+
the crate names with versions to a new file in format: - crate_name@version
6+
"""
7+
8+
import re
9+
import os
10+
import argparse
11+
12+
def parse_crate_names(input_file, output_file):
13+
"""
14+
Parse the input file to extract crate names with versions and write them to output file.
15+
16+
Args:
17+
input_file (str): Path to the input file
18+
output_file (str): Path to the output file
19+
"""
20+
crates = []
21+
22+
# Pattern to match lines with name = "crate-name"
23+
name_pattern = r'name\s*=\s*"([^"]+)"'
24+
# Pattern to match lines with +to = "version"
25+
version_pattern = r'\+to\s*=\s*"([^"]+)"'
26+
27+
try:
28+
with open(input_file, 'r', encoding='utf-8') as f:
29+
lines = f.readlines()
30+
31+
current_crate = None
32+
for line_num, line in enumerate(lines, 1):
33+
# Look for lines that contain name = "something"
34+
name_match = re.search(name_pattern, line)
35+
if name_match:
36+
current_crate = name_match.group(1)
37+
print(f"Found crate name: {current_crate} (line {line_num})")
38+
39+
# Look ahead for the +to version line
40+
# Typically it's within the next few lines
41+
for lookahead_offset in range(1, 10):
42+
if line_num - 1 + lookahead_offset < len(lines):
43+
version_line = lines[line_num - 1 + lookahead_offset]
44+
version_match = re.search(version_pattern, version_line)
45+
if version_match:
46+
version = version_match.group(1)
47+
crates.append((current_crate, version))
48+
print(f" -> Version: {version} (line {line_num + lookahead_offset})")
49+
break
50+
51+
except FileNotFoundError:
52+
print(f"Error: Input file '{input_file}' not found.")
53+
return
54+
except Exception as e:
55+
print(f"Error reading input file: {e}")
56+
return
57+
58+
# Write crate names with versions to output file
59+
try:
60+
with open(output_file, 'w', encoding='utf-8') as f:
61+
f.write("The following crates were updated to the corresponding versions:\n\n")
62+
for crate_name, version in crates:
63+
f.write(f"- {crate_name}@{version}\n")
64+
print(f"\nSuccessfully extracted {len(crates)} crates with versions.")
65+
print(f"Output written to: {output_file}")
66+
67+
except Exception as e:
68+
print(f"Error writing output file: {e}")
69+
70+
def main():
71+
parser = argparse.ArgumentParser(
72+
description='Parse changed_crates file and extract crate names.'
73+
)
74+
parser.add_argument(
75+
'input_file',
76+
help='Path to the input file containing crate information'
77+
)
78+
parser.add_argument(
79+
'output_file',
80+
help='Path to the output file where crate names will be written'
81+
)
82+
83+
args = parser.parse_args()
84+
85+
print("Parsing crate names from diff file...")
86+
print(f"Input file: {args.input_file}")
87+
print(f"Output file: {args.output_file}")
88+
print("-" * 50)
89+
90+
parse_crate_names(args.input_file, args.output_file)
91+
92+
if __name__ == "__main__":
93+
main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{# List of chnaged crates with updated versions genearted during the crates relaease . -#}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{% if env.NO_RUNTIMES == "true" -%}
2+
ℹ️ **Please note:**
3+
4+
This is a patch release for the latest stable version: `{{ env.STABLE_VERSION }}`. If your nodes are already running on this stable release,
5+
you should upgrade to this patch version to get the latest fixes.
6+
7+
The tag corresponding to the current patch release `{{ env.REF2 }}` and matching the old pattern will be
8+
available under [polkadot-{{ env.NODE_VERSION }}](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-{{ env.NODE_VERSION }}).
9+
{% endif -%}
10+
11+
{% if env.CRATES_ONLY == "true" -%}
12+
ℹ️ **Please note:**
13+
14+
⚠️ This is a patch release for the stable version: `{{ env.STABLE_VERSION }}` and contains only patches and fixes to the crates (list
15+
below). No binary or docker images will be provided for this release.
16+
17+
The tag corresponding to the current patch release `{{ env.REF2 }}` and matching the old pattern will be
18+
available under [polkadot-{{ env.NODE_VERSION }}](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-{{ env.NODE_VERSION }}).
19+
{% endif -%}

scripts/release/templates/template.md.tera

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This release contains the changes from `{{ env.REF1 | replace(from="refs/tags/",
55
{# -- Manual free notes section -- #}
66
{% include "_free_notes.md.tera" -%}
77

8+
9+
{% include "release_info.md.tera" -%}
10+
11+
{% include "crates_list.md.tera" -%}
12+
813
{# -- Automatic section -- #}
914
{% include "changes.md.tera" -%}
1015

0 commit comments

Comments
 (0)