Skip to content

Commit 43539a5

Browse files
committed
Update release calendar and improve update script
1 parent e60c0f5 commit 43539a5

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

docs/install/releases/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Best practices for installing Coder can be found on our [install](../index.md)
5353
pages.
5454

5555
## Release schedule
56-
56+
<!-- Autogenerated release calendar from scripts/update-release-calendar.sh -->
5757
<!-- RELEASE_CALENDAR_START -->
5858
| Release name | Release Date | Status | Latest Release |
5959
|------------------------------------------------|-------------------|------------------|----------------------------------------------------------------|
@@ -62,7 +62,7 @@ pages.
6262
| [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) |
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.0](https://github.com/coder/coder/releases/tag/v2.21.0) |
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) |
6666
| 2.22 | May 07, 2024 | Not Released | N/A |
6767
<!-- RELEASE_CALENDAR_END -->
6868

scripts/update-release-calendar.sh

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ current_year=$(date +"%Y")
2121
get_first_tuesday() {
2222
local year=$1
2323
local month=$2
24+
local first_day
25+
local days_until_tuesday
26+
local first_tuesday
2427

2528
# 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")
2730

2831
# 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))
3033

3134
# 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")
3336

3437
echo "$first_tuesday"
3538
}
@@ -43,12 +46,14 @@ format_date() {
4346
get_latest_patch() {
4447
local version_major=$1
4548
local version_minor=$2
49+
local tags
50+
local latest
4651

4752
# 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)
4954

5055
# Get the latest one
51-
local latest=$(echo "$tags" | tail -1)
56+
latest=$(echo "$tags" | tail -1)
5257

5358
if [ -z "$latest" ]; then
5459
# If no tags found, return empty
@@ -68,24 +73,33 @@ get_latest_patch() {
6873
generate_release_calendar() {
6974
local result=""
7075
local version_major=2
76+
local latest_version
77+
local version_minor
78+
local start_minor
7179

7280
# 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)
7583

7684
# Start with 3 unsupported releases back
77-
local start_minor=$((version_minor - 5))
85+
start_minor=$((version_minor - 5))
7886

7987
# 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"
8290

8391
# Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next)
8492
for i in {0..6}; do
8593
# Calculate release minor version
8694
local rel_minor=$((start_minor + i))
8795
# Format release name without the .x
8896
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
89103

90104
# Calculate release month and year based on release pattern
91105
# This is a simplified calculation assuming monthly releases
@@ -102,24 +116,22 @@ generate_release_calendar() {
102116
# Skip January releases starting from 2025
103117
if [[ $rel_month -eq 1 && $rel_year -ge 2025 ]]; then
104118
rel_month=2
105-
rel_year=$rel_year
119+
# No need to reassign rel_year to itself
106120
fi
107121

108122
# 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")
111125

112126
# 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")
115128
if [ -n "$latest_patch" ]; then
116129
patch_link="[v${latest_patch}](https://github.com/coder/coder/releases/tag/v${latest_patch})"
117130
else
118131
patch_link="N/A"
119132
fi
120133

121134
# Determine status
122-
local status
123135
if [[ "$release_date" > "$current_date" ]]; then
124136
status="Not Released"
125137
elif [[ $i -eq 6 ]]; then
@@ -136,7 +148,6 @@ generate_release_calendar() {
136148

137149
# Format version name and patch link based on release status
138150
# No links for unreleased versions
139-
local formatted_version_name
140151
if [[ "$status" == "Not Released" ]]; then
141152
formatted_version_name="$version_name"
142153
patch_link="N/A"
@@ -169,14 +180,14 @@ awk -v start_marker="$CALENDAR_START_MARKER" \
169180
-v new_calendar="$NEW_CALENDAR" \
170181
'
171182
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;
175186
found_start = 1;
176187
print_line = 0;
177-
next;
188+
next;
178189
}
179-
$0 ~ end_marker {
190+
$0 ~ end_marker {
180191
found_end = 1;
181192
print_line = 1;
182193
print;
@@ -188,4 +199,7 @@ awk -v start_marker="$CALENDAR_START_MARKER" \
188199
# Replace the original file with the updated version
189200
mv "${DOCS_FILE}.new" "$DOCS_FILE"
190201

202+
# run make fmt/markdown
203+
make fmt/markdown
204+
191205
echo "Successfully updated release calendar in $DOCS_FILE"

0 commit comments

Comments
 (0)