@@ -8,41 +8,34 @@ set -euo pipefail
8
8
9
9
DOCS_FILE=" docs/install/releases/index.md"
10
10
11
- # Define unique markdown comments as anchors
12
11
CALENDAR_START_MARKER=" <!-- RELEASE_CALENDAR_START -->"
13
12
CALENDAR_END_MARKER=" <!-- RELEASE_CALENDAR_END -->"
14
13
15
- # Get current date
16
14
current_date=$( date +" %Y-%m-%d" )
17
15
current_month=$( date +" %m" )
18
16
current_year=$( date +" %Y" )
19
17
20
- # Function to get the first Tuesday of a given month and year
21
18
get_first_tuesday () {
22
19
local year=$1
23
20
local month=$2
24
21
local first_day
25
22
local days_until_tuesday
26
23
local first_tuesday
27
24
28
- # Find the first day of the month
29
25
first_day=$( date -d " $year -$month -01" +" %u" )
30
26
31
- # Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2)
32
27
days_until_tuesday=$(( first_day == 2 ? 0 : (9 - first_day) % 7 ))
33
28
34
- # Get the date of the first Tuesday
35
29
first_tuesday=$( date -d " $year -$month -01 +$days_until_tuesday days" +" %Y-%m-%d" )
36
30
37
31
echo " $first_tuesday "
38
32
}
39
33
40
- # Function to format date as "Month DD, YYYY"
34
+ # Format date as "Month DD, YYYY"
41
35
format_date () {
42
36
date -d " $1 " +" %B %d, %Y"
43
37
}
44
38
45
- # Function to get the latest patch version for a minor release
46
39
get_latest_patch () {
47
40
local version_major=$1
48
41
local version_minor=$2
@@ -52,18 +45,33 @@ get_latest_patch() {
52
45
# Get all tags for this minor version
53
46
tags=$( cd " $( git rev-parse --show-toplevel) " && git tag | grep " ^v$version_major \\ .$version_minor \\ ." | sort -V)
54
47
55
- # Get the latest one
56
48
latest=$( echo " $tags " | tail -1)
57
49
58
50
if [ -z " $latest " ]; then
59
- # If no tags found, return empty
60
51
echo " "
61
52
else
62
- # Return without the v prefix
63
53
echo " ${latest# v} "
64
54
fi
65
55
}
66
56
57
+ get_next_release_month () {
58
+ local current_month=$1
59
+ local next_month=$(( current_month + 1 ))
60
+
61
+ # Handle December -> February transition (skip January)
62
+ if [[ $next_month -eq 13 ]]; then
63
+ next_month=2 # Skip to February
64
+ return $next_month
65
+ fi
66
+
67
+ # Skip January for all years starting 2025
68
+ if [[ $next_month -eq 1 ]]; then
69
+ next_month=2
70
+ fi
71
+
72
+ return $next_month
73
+ }
74
+
67
75
# Generate releases table showing:
68
76
# - 3 previous unsupported releases
69
77
# - 1 security support release (n-2)
@@ -84,15 +92,31 @@ generate_release_calendar() {
84
92
# Start with 3 unsupported releases back
85
93
start_minor=$(( version_minor - 5 ))
86
94
87
- # Initialize the calendar table with an additional column for latest release
88
95
result=" | Release name | Release Date | Status | Latest Release |\n"
89
96
result+=" |--------------|--------------|--------|----------------|\n"
90
97
98
+ # Find the latest release month and year
99
+ local current_release_minor=$(( version_minor - 1 )) # Current stable release
100
+ local tag_date
101
+ tag_date=$( cd " $( git rev-parse --show-toplevel) " && git log -1 --format=%ai " v$version_major .$current_release_minor .0" 2> /dev/null || echo " " )
102
+
103
+ local current_release_month
104
+ local current_release_year
105
+
106
+ if [ -n " $tag_date " ]; then
107
+ # Extract month and year from tag date
108
+ current_release_month=$( date -d " $tag_date " +" %m" )
109
+ current_release_year=$( date -d " $tag_date " +" %Y" )
110
+ else
111
+ # Default to current month/year if tag not found
112
+ current_release_month=$current_month
113
+ current_release_year=$current_year
114
+ fi
115
+
91
116
# Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next)
92
117
for i in {0..6}; do
93
118
# Calculate release minor version
94
119
local rel_minor=$(( start_minor + i))
95
- # Format release name without the .x
96
120
local version_name=" $version_major .$rel_minor "
97
121
local release_date
98
122
local formatted_date
@@ -101,22 +125,41 @@ generate_release_calendar() {
101
125
local status
102
126
local formatted_version_name
103
127
104
- # Calculate release month and year based on release pattern
105
- # This is a simplified calculation assuming monthly releases
106
- local rel_month=$(( (current_month - (5 - i) + 12 ) % 12 ))
107
- [[ $rel_month -eq 0 ]] && rel_month=12
108
- local rel_year=$current_year
109
- if [[ $rel_month -gt $current_month ]]; then
110
- rel_year=$(( rel_year - 1 ))
111
- fi
112
- if [[ $rel_month -lt $current_month && $i -gt 5 ]]; then
113
- rel_year=$(( rel_year + 1 ))
114
- fi
115
-
116
- # Skip January releases starting from 2025
117
- if [[ $rel_month -eq 1 && $rel_year -ge 2025 ]]; then
118
- rel_month=2
119
- # No need to reassign rel_year to itself
128
+ # Calculate the release month and year based on the current release's date
129
+ # For previous releases, go backward in the release_months array
130
+ # For future releases, go forward
131
+ local month_offset=$(( i - 4 )) # 4 is the index of the stable release (i=4)
132
+
133
+ # Start from the current stable release month
134
+ local rel_month=$current_release_month
135
+ local rel_year=$current_release_year
136
+
137
+ # Apply the offset to get the target release month
138
+ if [ $month_offset -lt 0 ]; then
139
+ # For previous releases, go backward
140
+ for (( j = 0 ; j > month_offset; j-- )) ; do
141
+ rel_month=$(( rel_month - 1 ))
142
+ if [ $rel_month -eq 0 ]; then
143
+ rel_month=12
144
+ rel_year=$(( rel_year - 1 ))
145
+ elif [ $rel_month -eq 1 ]; then
146
+ # Skip January (go from February to December of previous year)
147
+ rel_month=12
148
+ rel_year=$(( rel_year - 1 ))
149
+ fi
150
+ done
151
+ elif [ $month_offset -gt 0 ]; then
152
+ # For future releases, go forward
153
+ for (( j = 0 ; j < month_offset; j++ )) ; do
154
+ rel_month=$(( rel_month + 1 ))
155
+ if [ $rel_month -eq 13 ]; then
156
+ rel_month=2 # Skip from December to February
157
+ rel_year=$(( rel_year + 1 ))
158
+ elif [ $rel_month -eq 1 ]; then
159
+ # Skip January
160
+ rel_month=2
161
+ fi
162
+ done
120
163
fi
121
164
122
165
# Get release date (first Tuesday of the month)
@@ -147,7 +190,6 @@ generate_release_calendar() {
147
190
fi
148
191
149
192
# Format version name and patch link based on release status
150
- # No links for unreleased versions
151
193
if [[ " $status " == " Not Released" ]]; then
152
194
formatted_version_name=" $version_name "
153
195
patch_link=" N/A"
0 commit comments