Skip to content

Commit fc921a5

Browse files
authored
chore(docs): update release calendar dates and next release calculation (coder#17560)
1 parent 118f12a commit fc921a5

File tree

2 files changed

+77
-35
lines changed

2 files changed

+77
-35
lines changed

docs/install/releases/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ pages.
5757
<!-- RELEASE_CALENDAR_START -->
5858
| Release name | Release Date | Status | Latest Release |
5959
|------------------------------------------------|-------------------|------------------|----------------------------------------------------------------|
60-
| [2.16](https://coder.com/changelog/coder-2-16) | November 05, 2024 | Not Supported | [v2.16.1](https://github.com/coder/coder/releases/tag/v2.16.1) |
61-
| [2.17](https://coder.com/changelog/coder-2-17) | December 03, 2024 | Not Supported | [v2.17.3](https://github.com/coder/coder/releases/tag/v2.17.3) |
62-
| [2.18](https://coder.com/changelog/coder-2-18) | February 04, 2025 | Not Supported | [v2.18.5](https://github.com/coder/coder/releases/tag/v2.18.5) |
60+
| [2.16](https://coder.com/changelog/coder-2-16) | October 01, 2024 | Not Supported | [v2.16.1](https://github.com/coder/coder/releases/tag/v2.16.1) |
61+
| [2.17](https://coder.com/changelog/coder-2-17) | November 05, 2024 | Not Supported | [v2.17.3](https://github.com/coder/coder/releases/tag/v2.17.3) |
62+
| [2.18](https://coder.com/changelog/coder-2-18) | December 03, 2024 | Not Supported | [v2.18.5](https://github.com/coder/coder/releases/tag/v2.18.5) |
6363
| [2.19](https://coder.com/changelog/coder-2-19) | February 04, 2025 | Security Support | [v2.19.1](https://github.com/coder/coder/releases/tag/v2.19.1) |
6464
| [2.20](https://coder.com/changelog/coder-2-20) | March 04, 2025 | Stable | [v2.20.2](https://github.com/coder/coder/releases/tag/v2.20.2) |
65-
| [2.21](https://coder.com/changelog/coder-2-21) | April 01, 2025 | Mainline | [v2.21.1](https://github.com/coder/coder/releases/tag/v2.21.1) |
66-
| 2.22 | May 07, 2024 | Not Released | N/A |
65+
| [2.21](https://coder.com/changelog/coder-2-21) | April 01, 2025 | Mainline | [v2.21.0](https://github.com/coder/coder/releases/tag/v2.21.0) |
66+
| 2.22 | May 06, 2025 | Not Released | N/A |
6767
<!-- RELEASE_CALENDAR_END -->
6868

6969
> [!TIP]

scripts/update-release-calendar.sh

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,34 @@ set -euo pipefail
88

99
DOCS_FILE="docs/install/releases/index.md"
1010

11-
# Define unique markdown comments as anchors
1211
CALENDAR_START_MARKER="<!-- RELEASE_CALENDAR_START -->"
1312
CALENDAR_END_MARKER="<!-- RELEASE_CALENDAR_END -->"
1413

15-
# Get current date
1614
current_date=$(date +"%Y-%m-%d")
1715
current_month=$(date +"%m")
1816
current_year=$(date +"%Y")
1917

20-
# Function to get the first Tuesday of a given month and year
2118
get_first_tuesday() {
2219
local year=$1
2320
local month=$2
2421
local first_day
2522
local days_until_tuesday
2623
local first_tuesday
2724

28-
# Find the first day of the month
2925
first_day=$(date -d "$year-$month-01" +"%u")
3026

31-
# Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2)
3227
days_until_tuesday=$((first_day == 2 ? 0 : (9 - first_day) % 7))
3328

34-
# Get the date of the first Tuesday
3529
first_tuesday=$(date -d "$year-$month-01 +$days_until_tuesday days" +"%Y-%m-%d")
3630

3731
echo "$first_tuesday"
3832
}
3933

40-
# Function to format date as "Month DD, YYYY"
34+
# Format date as "Month DD, YYYY"
4135
format_date() {
4236
date -d "$1" +"%B %d, %Y"
4337
}
4438

45-
# Function to get the latest patch version for a minor release
4639
get_latest_patch() {
4740
local version_major=$1
4841
local version_minor=$2
@@ -52,18 +45,33 @@ get_latest_patch() {
5245
# Get all tags for this minor version
5346
tags=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep "^v$version_major\\.$version_minor\\." | sort -V)
5447

55-
# Get the latest one
5648
latest=$(echo "$tags" | tail -1)
5749

5850
if [ -z "$latest" ]; then
59-
# If no tags found, return empty
6051
echo ""
6152
else
62-
# Return without the v prefix
6353
echo "${latest#v}"
6454
fi
6555
}
6656

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+
6775
# Generate releases table showing:
6876
# - 3 previous unsupported releases
6977
# - 1 security support release (n-2)
@@ -84,15 +92,31 @@ generate_release_calendar() {
8492
# Start with 3 unsupported releases back
8593
start_minor=$((version_minor - 5))
8694

87-
# Initialize the calendar table with an additional column for latest release
8895
result="| Release name | Release Date | Status | Latest Release |\n"
8996
result+="|--------------|--------------|--------|----------------|\n"
9097

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+
91116
# Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next)
92117
for i in {0..6}; do
93118
# Calculate release minor version
94119
local rel_minor=$((start_minor + i))
95-
# Format release name without the .x
96120
local version_name="$version_major.$rel_minor"
97121
local release_date
98122
local formatted_date
@@ -101,22 +125,41 @@ generate_release_calendar() {
101125
local status
102126
local formatted_version_name
103127

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
120163
fi
121164

122165
# Get release date (first Tuesday of the month)
@@ -147,7 +190,6 @@ generate_release_calendar() {
147190
fi
148191

149192
# Format version name and patch link based on release status
150-
# No links for unreleased versions
151193
if [[ "$status" == "Not Released" ]]; then
152194
formatted_version_name="$version_name"
153195
patch_link="N/A"

0 commit comments

Comments
 (0)