@@ -29,7 +29,7 @@ commit_with_message() {
2929# input: none
3030# output: list of filtered runtimes
3131get_filtered_runtimes_list () {
32- grep_filters=(" runtime.*" " test|template|starters|substrate" )
32+ grep_filters=(" runtime.*" " test|template|starters|substrate|docs " )
3333
3434 git grep spec_version: | grep .rs: | grep -e " ${grep_filters[0]} " | grep " lib.rs" | grep -vE " ${grep_filters[1]} " | cut -d: -f1
3535}
@@ -91,13 +91,20 @@ function get_spec_version() {
9191reorder_prdocs () {
9292 VERSION=" $1 "
9393
94- printf " [+] ℹ️ Reordering prdocs:"
94+ printf " [+] ℹ️ Reordering prdocs:\n "
9595
9696 VERSION=$( sed -E ' s/^v([0-9]+\.[0-9]+\.[0-9]+).*$/\1/' <<< " $VERSION" ) # getting reed of the 'v' prefix
97- mkdir -p " prdoc/$VERSION "
98- mv prdoc/pr_* .prdoc prdoc/$VERSION
99- git add -A
100- commit_with_message " Reordering prdocs for the release $VERSION "
97+
98+ # Check if there are any prdoc files to move
99+ if ls prdoc/pr_* .prdoc 1> /dev/null 2>&1 ; then
100+ mkdir -p " prdoc/$VERSION "
101+ mv prdoc/pr_* .prdoc prdoc/$VERSION
102+ git add -A
103+ commit_with_message " Reordering prdocs for the release $VERSION "
104+ echo " ✅ Successfully reordered prdocs"
105+ else
106+ echo " ⚠️ No prdoc files found to reorder"
107+ fi
101108}
102109
103110# Bump the binary version of the polkadot-parachain binary with the
@@ -204,3 +211,50 @@ function get_s3_url_base() {
204211 ;;
205212 esac
206213}
214+
215+ # Bump spec_version in a runtime file based on release type
216+ # For patch release: bump last 3 digits (patch part) by 1
217+ # For new stable release: bump middle part (minor) by 1, reset patch to 0
218+ #
219+ # input:
220+ # - file: path to the runtime file
221+ # - is_patch_release: "true" for patch release, "false" for new stable
222+ # output: prints the new spec_version, modifies file in place
223+ bump_spec_version () {
224+ local file=$1
225+ local is_patch_release=$2
226+
227+ # Extract current spec_version from file (format: X_YYY_ZZZ)
228+ local current_spec=$( grep -oP ' spec_version:\s*\K[0-9]+_[0-9]+_[0-9]+' " $file " | head -1)
229+
230+ if [ -z " $current_spec " ]; then
231+ echo " ⚠️ Warning: Could not find spec_version in $file "
232+ return 1
233+ fi
234+
235+ # Parse the spec_version (format: X_YYY_ZZZ)
236+ local major=$( echo " $current_spec " | cut -d' _' -f1)
237+ local minor=$( echo " $current_spec " | cut -d' _' -f2)
238+ local patch=$( echo " $current_spec " | cut -d' _' -f3)
239+
240+ # Remove leading zeros for arithmetic
241+ minor=$(( 10 #$minor ))
242+ patch=$(( 10 #$patch ))
243+
244+ if [ " $is_patch_release " = " true" ]; then
245+ # Patch release: bump patch part by 1
246+ patch=$(( patch + 1 ))
247+ else
248+ # New stable release: bump minor by 1, reset patch to 0
249+ minor=$(( minor + 1 ))
250+ patch=0
251+ fi
252+
253+ # Format back to X_YYY_ZZZ format (with proper zero padding)
254+ local new_spec=$( printf " %d_%03d_%03d" " $major " " $minor " " $patch " )
255+
256+ # Replace in file
257+ sed -ri " s/spec_version: ${current_spec} ,/spec_version: ${new_spec} ,/" " $file "
258+
259+ echo " $new_spec "
260+ }
0 commit comments