Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit166d88e

Browse files
authored
docs: add automatic release calendar updates in docs (#17531)
1 parentad38a3b commit166d88e

File tree

3 files changed

+269
-12
lines changed

3 files changed

+269
-12
lines changed

‎.github/workflows/release.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,3 +924,55 @@ jobs:
924924
continue-on-error:true
925925
run:|
926926
make sqlc-push
927+
928+
update-calendar:
929+
name:"Update release calendar in docs"
930+
runs-on:"ubuntu-latest"
931+
needs:[release, publish-homebrew, publish-winget, publish-sqlc]
932+
if:${{ !inputs.dry_run }}
933+
permissions:
934+
contents:write
935+
pull-requests:write
936+
steps:
937+
-name:Harden Runner
938+
uses:step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf# v2.11.1
939+
with:
940+
egress-policy:audit
941+
942+
-name:Checkout repository
943+
uses:actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683# v4.2.2
944+
with:
945+
fetch-depth:0# Needed to get all tags for version calculation
946+
947+
-name:Set up Git
948+
run:|
949+
git config user.name "Coder CI"
950+
git config user.email "cdrci@coder.com"
951+
952+
-name:Run update script
953+
run:|
954+
./scripts/update-release-calendar.sh
955+
make fmt/markdown
956+
957+
-name:Check for changes
958+
id:check_changes
959+
run:|
960+
if git diff --quiet docs/install/releases/index.md; then
961+
echo "No changes detected in release calendar."
962+
echo "changes=false" >> $GITHUB_OUTPUT
963+
else
964+
echo "Changes detected in release calendar."
965+
echo "changes=true" >> $GITHUB_OUTPUT
966+
fi
967+
968+
-name:Create Pull Request
969+
if:steps.check_changes.outputs.changes == 'true'
970+
uses:peter-evans/create-pull-request@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0# v3.0.0
971+
with:
972+
commit-message:"docs: update release calendar"
973+
title:"docs: update release calendar"
974+
body:|
975+
This PR automatically updates the release calendar in the docs.
976+
branch:bot/update-release-calendar
977+
delete-branch:true
978+
labels:docs

‎docs/install/releases/index.md

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

5555
##Release schedule
56-
57-
| Release name| Release Date| Status|
58-
|--------------|--------------------|------------------|
59-
| 2.12.x| June 04, 2024| Not Supported|
60-
|2.13.x| July 02, 2024| Not Supported|
61-
|2.14.x| August 06, 2024| Not Supported|
62-
|2.15.x| September 03, 2024| Not Supported|
63-
|2.16.x| October 01, 2024| Not Supported|
64-
|2.17.x| November 05, 2024| Not Supported|
65-
|2.18.x| December 03, 2024| Security Support|
66-
| 2.19.x| February 04, 2024| Stable|
67-
| 2.20.x| March 05, 2024| Mainline|
56+
<!-- Autogenerated release calendar from scripts/update-release-calendar.sh-->
57+
<!-- RELEASE_CALENDAR_START-->
58+
| Release name| Release Date| Status| Latest Release|
59+
|------------------------------------------------|-------------------|------------------|----------------------------------------------------------------|
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)|
63+
|[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)|
64+
|[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|
67+
<!-- RELEASE_CALENDAR_END-->
6868

6969
>[!TIP]
7070
>We publish a

‎scripts/update-release-calendar.sh

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# This script automatically updates the release calendar in docs/install/releases/index.md
6+
# It calculates the releases based on the first Tuesday of each month rule
7+
# and updates the status of each release (Not Supported, Security Support, Stable, Mainline, Not Released)
8+
9+
DOCS_FILE="docs/install/releases/index.md"
10+
11+
# Define unique markdown comments as anchors
12+
CALENDAR_START_MARKER="<!-- RELEASE_CALENDAR_START -->"
13+
CALENDAR_END_MARKER="<!-- RELEASE_CALENDAR_END -->"
14+
15+
# Get current date
16+
current_date=$(date +"%Y-%m-%d")
17+
current_month=$(date +"%m")
18+
current_year=$(date +"%Y")
19+
20+
# Function to get the first Tuesday of a given month and year
21+
get_first_tuesday() {
22+
local year=$1
23+
local month=$2
24+
local first_day
25+
local days_until_tuesday
26+
local first_tuesday
27+
28+
# Find the first day of the month
29+
first_day=$(date -d"$year-$month-01" +"%u")
30+
31+
# Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2)
32+
days_until_tuesday=$((first_day==2?0: (9- first_day)%7))
33+
34+
# Get the date of the first Tuesday
35+
first_tuesday=$(date -d"$year-$month-01 +$days_until_tuesday days" +"%Y-%m-%d")
36+
37+
echo"$first_tuesday"
38+
}
39+
40+
# Function to format date as "Month DD, YYYY"
41+
format_date() {
42+
date -d"$1" +"%B %d, %Y"
43+
}
44+
45+
# Function to get the latest patch version for a minor release
46+
get_latest_patch() {
47+
local version_major=$1
48+
local version_minor=$2
49+
local tags
50+
local latest
51+
52+
# Get all tags for this minor version
53+
tags=$(cd"$(git rev-parse --show-toplevel)"&& git tag| grep"^v$version_major\\.$version_minor\\."| sort -V)
54+
55+
# Get the latest one
56+
latest=$(echo"$tags"| tail -1)
57+
58+
if [-z"$latest" ];then
59+
# If no tags found, return empty
60+
echo""
61+
else
62+
# Return without the v prefix
63+
echo"${latest#v}"
64+
fi
65+
}
66+
67+
# Generate releases table showing:
68+
# - 3 previous unsupported releases
69+
# - 1 security support release (n-2)
70+
# - 1 stable release (n-1)
71+
# - 1 mainline release (n)
72+
# - 1 next release (n+1)
73+
generate_release_calendar() {
74+
local result=""
75+
local version_major=2
76+
local latest_version
77+
local version_minor
78+
local start_minor
79+
80+
# Find the current minor version by looking at the last mainline release tag
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)
83+
84+
# Start with 3 unsupported releases back
85+
start_minor=$((version_minor-5))
86+
87+
# Initialize the calendar table with an additional column for latest release
88+
result="| Release name | Release Date | Status | Latest Release |\n"
89+
result+="|--------------|--------------|--------|----------------|\n"
90+
91+
# Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next)
92+
foriin {0..6};do
93+
# Calculate release minor version
94+
local rel_minor=$((start_minor+ i))
95+
# Format release name without the .x
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
103+
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
120+
fi
121+
122+
# Get release date (first Tuesday of the month)
123+
release_date=$(get_first_tuesday"$rel_year""$(printf"%02d""$rel_month")")
124+
formatted_date=$(format_date"$release_date")
125+
126+
# Get latest patch version
127+
latest_patch=$(get_latest_patch"$version_major""$rel_minor")
128+
if [-n"$latest_patch" ];then
129+
patch_link="[v${latest_patch}](https://github.com/coder/coder/releases/tag/v${latest_patch})"
130+
else
131+
patch_link="N/A"
132+
fi
133+
134+
# Determine status
135+
if [["$release_date">"$current_date" ]];then
136+
status="Not Released"
137+
elif [[$i-eq 6 ]];then
138+
status="Not Released"
139+
elif [[$i-eq 5 ]];then
140+
status="Mainline"
141+
elif [[$i-eq 4 ]];then
142+
status="Stable"
143+
elif [[$i-eq 3 ]];then
144+
status="Security Support"
145+
else
146+
status="Not Supported"
147+
fi
148+
149+
# Format version name and patch link based on release status
150+
# No links for unreleased versions
151+
if [["$status"=="Not Released" ]];then
152+
formatted_version_name="$version_name"
153+
patch_link="N/A"
154+
else
155+
formatted_version_name="[$version_name](https://coder.com/changelog/coder-$version_major-$rel_minor)"
156+
fi
157+
158+
# Add row to table
159+
result+="|$formatted_version_name |$formatted_date |$status |$patch_link |\n"
160+
done
161+
162+
echo -e"$result"
163+
}
164+
165+
# Check if the markdown comments exist in the file
166+
if! grep -q"$CALENDAR_START_MARKER""$DOCS_FILE"||! grep -q"$CALENDAR_END_MARKER""$DOCS_FILE";then
167+
echo"Error: Markdown comment anchors not found in$DOCS_FILE"
168+
echo"Please add the following anchors around the release calendar table:"
169+
echo"$CALENDAR_START_MARKER"
170+
echo"$CALENDAR_END_MARKER"
171+
exit 1
172+
fi
173+
174+
# Generate the new calendar table content
175+
NEW_CALENDAR=$(generate_release_calendar)
176+
177+
# Update the file while preserving the rest of the content
178+
awk -v start_marker="$CALENDAR_START_MARKER" \
179+
-v end_marker="$CALENDAR_END_MARKER" \
180+
-v new_calendar="$NEW_CALENDAR" \
181+
'
182+
BEGIN { found_start = 0; found_end = 0; print_line = 1; }
183+
$0 ~ start_marker {
184+
print;
185+
print new_calendar;
186+
found_start = 1;
187+
print_line = 0;
188+
next;
189+
}
190+
$0 ~ end_marker {
191+
found_end = 1;
192+
print_line = 1;
193+
print;
194+
next;
195+
}
196+
print_line || !found_start || found_end { print }
197+
'"$DOCS_FILE">"${DOCS_FILE}.new"
198+
199+
# Replace the original file with the updated version
200+
mv"${DOCS_FILE}.new""$DOCS_FILE"
201+
202+
# run make fmt/markdown
203+
make fmt/markdown
204+
205+
echo"Successfully updated release calendar in$DOCS_FILE"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp