@@ -21,15 +21,18 @@ current_year=$(date +"%Y")
21
21
get_first_tuesday () {
22
22
local year=$1
23
23
local month=$2
24
+ local first_day
25
+ local days_until_tuesday
26
+ local first_tuesday
24
27
25
28
# Find the first day of the month
26
- local first_day=$( date -d " $year -$month -01" +" %u" )
29
+ first_day=$( date -d " $year -$month -01" +" %u" )
27
30
28
31
# Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2)
29
- local days_until_tuesday=$(( first_day == 2 ? 0 : (9 - first_day) % 7 ))
32
+ days_until_tuesday=$(( first_day == 2 ? 0 : (9 - first_day) % 7 ))
30
33
31
34
# Get the date of the first Tuesday
32
- local first_tuesday=$( date -d " $year -$month -01 +$days_until_tuesday days" +" %Y-%m-%d" )
35
+ first_tuesday=$( date -d " $year -$month -01 +$days_until_tuesday days" +" %Y-%m-%d" )
33
36
34
37
echo " $first_tuesday "
35
38
}
@@ -43,12 +46,14 @@ format_date() {
43
46
get_latest_patch () {
44
47
local version_major=$1
45
48
local version_minor=$2
49
+ local tags
50
+ local latest
46
51
47
52
# Get all tags for this minor version
48
- local tags=$( cd " $( git rev-parse --show-toplevel) " && git tag | grep " ^v$version_major \\ .$version_minor \\ ." | sort -V)
53
+ tags=$( cd " $( git rev-parse --show-toplevel) " && git tag | grep " ^v$version_major \\ .$version_minor \\ ." | sort -V)
49
54
50
55
# Get the latest one
51
- local latest=$( echo " $tags " | tail -1)
56
+ latest=$( echo " $tags " | tail -1)
52
57
53
58
if [ -z " $latest " ]; then
54
59
# If no tags found, return empty
@@ -68,24 +73,33 @@ get_latest_patch() {
68
73
generate_release_calendar () {
69
74
local result=" "
70
75
local version_major=2
76
+ local latest_version
77
+ local version_minor
78
+ local start_minor
71
79
72
80
# Find the current minor version by looking at the last mainline release tag
73
- local latest_version=$( cd " $( git rev-parse --show-toplevel) " && git tag | grep ' ^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1)
74
- local version_minor=$( echo " $latest_version " | cut -d. -f2)
81
+ latest_version=$( cd " $( git rev-parse --show-toplevel) " && git tag | grep ' ^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1)
82
+ version_minor=$( echo " $latest_version " | cut -d. -f2)
75
83
76
84
# Start with 3 unsupported releases back
77
- local start_minor=$(( version_minor - 5 ))
85
+ start_minor=$(( version_minor - 5 ))
78
86
79
87
# Initialize the calendar table with an additional column for latest release
80
- result=" | Release name | Release Date | Status | Latest Release |\n"
81
- result+=" |-------------|-------------------|---------- --------|----------------|\n"
88
+ result=" | Release name | Release Date | Status | Latest Release |\n"
89
+ result+=" |-------------- |--------------| --------|----------------|\n"
82
90
83
91
# Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next)
84
92
for i in {0..6}; do
85
93
# Calculate release minor version
86
94
local rel_minor=$(( start_minor + i))
87
95
# Format release name without the .x
88
96
local version_name=" $version_major .$rel_minor "
97
+ local release_date
98
+ local formatted_date
99
+ local latest_patch
100
+ local patch_link
101
+ local status
102
+ local formatted_version_name
89
103
90
104
# Calculate release month and year based on release pattern
91
105
# This is a simplified calculation assuming monthly releases
@@ -102,24 +116,22 @@ generate_release_calendar() {
102
116
# Skip January releases starting from 2025
103
117
if [[ $rel_month -eq 1 && $rel_year -ge 2025 ]]; then
104
118
rel_month=2
105
- rel_year= $rel_year
119
+ # No need to reassign rel_year to itself
106
120
fi
107
121
108
122
# Get release date (first Tuesday of the month)
109
- local release_date=$( get_first_tuesday $rel_year $( printf " %02d" $rel_month ) )
110
- local formatted_date=$( format_date " $release_date " )
123
+ release_date=$( get_first_tuesday " $rel_year " " $( printf " %02d" " $rel_month " ) " )
124
+ formatted_date=$( format_date " $release_date " )
111
125
112
126
# Get latest patch version
113
- local latest_patch=$( get_latest_patch $version_major $rel_minor )
114
- local patch_link=" "
127
+ latest_patch=$( get_latest_patch " $version_major " " $rel_minor " )
115
128
if [ -n " $latest_patch " ]; then
116
129
patch_link=" [v${latest_patch} ](https://github.com/coder/coder/releases/tag/v${latest_patch} )"
117
130
else
118
131
patch_link=" N/A"
119
132
fi
120
133
121
134
# Determine status
122
- local status
123
135
if [[ " $release_date " > " $current_date " ]]; then
124
136
status=" Not Released"
125
137
elif [[ $i -eq 6 ]]; then
@@ -136,7 +148,6 @@ generate_release_calendar() {
136
148
137
149
# Format version name and patch link based on release status
138
150
# No links for unreleased versions
139
- local formatted_version_name
140
151
if [[ " $status " == " Not Released" ]]; then
141
152
formatted_version_name=" $version_name "
142
153
patch_link=" N/A"
@@ -169,14 +180,14 @@ awk -v start_marker="$CALENDAR_START_MARKER" \
169
180
-v new_calendar=" $NEW_CALENDAR " \
170
181
'
171
182
BEGIN { found_start = 0; found_end = 0; print_line = 1; }
172
- $0 ~ start_marker {
173
- print;
174
- print new_calendar;
183
+ $0 ~ start_marker {
184
+ print;
185
+ print new_calendar;
175
186
found_start = 1;
176
187
print_line = 0;
177
- next;
188
+ next;
178
189
}
179
- $0 ~ end_marker {
190
+ $0 ~ end_marker {
180
191
found_end = 1;
181
192
print_line = 1;
182
193
print;
@@ -188,4 +199,7 @@ awk -v start_marker="$CALENDAR_START_MARKER" \
188
199
# Replace the original file with the updated version
189
200
mv " ${DOCS_FILE} .new" " $DOCS_FILE "
190
201
202
+ # run make fmt/markdown
203
+ make fmt/markdown
204
+
191
205
echo " Successfully updated release calendar in $DOCS_FILE "
0 commit comments