Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/release-30_publish_release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ jobs:
fi
echo "REL_TAG=$REF2" >> $GITHUB_ENV
export VERSION=$(echo "$REF2" | sed -E 's/.*(stable[0-9]{4}(-[0-9]+)?).*$/\1/')

echo "Version: $VERSION"

if [[ ${NO_RUNTIMES} == "true" || ${CRATES_ONLY} == "true" ]]; then
export STABLE_VERSION=$(sed -E 's/.*(stable[0-9]{4}).*$/\1/' <<< "$VERSION")
export NODE_VERSION=v$(get_polkadot_node_version_from_code)
fi

./scripts/release/build-changelogs.sh

- name: Archive artifact context.json
Expand Down
93 changes: 93 additions & 0 deletions scripts/release/parse-crates-names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env python3
"""
Script to parse changed_crates file and extract crate names with versions.
Extracts lines with 'name = "..."' and '+to = "..."' patterns and writes
the crate names with versions to a new file in format: - crate_name@version
"""

import re
import os
import argparse

def parse_crate_names(input_file, output_file):
"""
Parse the input file to extract crate names with versions and write them to output file.

Args:
input_file (str): Path to the input file
output_file (str): Path to the output file
"""
crates = []

# Pattern to match lines with name = "crate-name"
name_pattern = r'name\s*=\s*"([^"]+)"'
# Pattern to match lines with +to = "version"
version_pattern = r'\+to\s*=\s*"([^"]+)"'

try:
with open(input_file, 'r', encoding='utf-8') as f:
lines = f.readlines()

current_crate = None
for line_num, line in enumerate(lines, 1):
# Look for lines that contain name = "something"
name_match = re.search(name_pattern, line)
if name_match:
current_crate = name_match.group(1)
print(f"Found crate name: {current_crate} (line {line_num})")

# Look ahead for the +to version line
# Typically it's within the next few lines
for lookahead_offset in range(1, 10):
if line_num - 1 + lookahead_offset < len(lines):
version_line = lines[line_num - 1 + lookahead_offset]
version_match = re.search(version_pattern, version_line)
if version_match:
version = version_match.group(1)
crates.append((current_crate, version))
print(f" -> Version: {version} (line {line_num + lookahead_offset})")
break

except FileNotFoundError:
print(f"Error: Input file '{input_file}' not found.")
return
except Exception as e:
print(f"Error reading input file: {e}")
return

# Write crate names with versions to output file
try:
with open(output_file, 'w', encoding='utf-8') as f:
f.write("The following crates were updated to the corresponding versions:\n\n")
for crate_name, version in crates:
f.write(f"- {crate_name}@{version}\n")
print(f"\nSuccessfully extracted {len(crates)} crates with versions.")
print(f"Output written to: {output_file}")

except Exception as e:
print(f"Error writing output file: {e}")

def main():
parser = argparse.ArgumentParser(
description='Parse changed_crates file and extract crate names.'
)
parser.add_argument(
'input_file',
help='Path to the input file containing crate information'
)
parser.add_argument(
'output_file',
help='Path to the output file where crate names will be written'
)

args = parser.parse_args()

print("Parsing crate names from diff file...")
print(f"Input file: {args.input_file}")
print(f"Output file: {args.output_file}")
print("-" * 50)

parse_crate_names(args.input_file, args.output_file)

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions scripts/release/templates/crates_list.md.tera
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{# List of chnaged crates with updated versions genearted during the crates relaease . -#}
19 changes: 19 additions & 0 deletions scripts/release/templates/release_info.md.tera
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% if env.NO_RUNTIMES == "true" -%}
ℹ️ **Please note:**

This is a patch release for the latest stable version: `{{ env.STABLE_VERSION }}`. If your nodes are already running on this stable release,
you should upgrade to this patch version to get the latest fixes.

The tag corresponding to the current patch release `{{ env.REF2 }}` and matching the old pattern will be
available under [polkadot-{{ env.NODE_VERSION }}](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-{{ env.NODE_VERSION }}).
{% endif -%}

{% if env.CRATES_ONLY == "true" -%}
ℹ️ **Please note:**

⚠️ This is a patch release for the stable version: `{{ env.STABLE_VERSION }}` and contains only patches and fixes to the crates (list
below). No binary or docker images will be provided for this release.

The tag corresponding to the current patch release `{{ env.REF2 }}` and matching the old pattern will be
available under [polkadot-{{ env.NODE_VERSION }}](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-{{ env.NODE_VERSION }}).
{% endif -%}
5 changes: 5 additions & 0 deletions scripts/release/templates/template.md.tera
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ This release contains the changes from `{{ env.REF1 | replace(from="refs/tags/",
{# -- Manual free notes section -- #}
{% include "_free_notes.md.tera" -%}


{% include "release_info.md.tera" -%}

{% include "crates_list.md.tera" -%}

{# -- Automatic section -- #}
{% include "changes.md.tera" -%}

Expand Down
Loading