From 9ba00cebea840ad237961c9671db9d628c5c0e00 Mon Sep 17 00:00:00 2001 From: M Atif Ali Date: Wed, 23 Apr 2025 10:43:30 +0000 Subject: [PATCH 1/4] docs: add automatic release calendar updates in docs Closes #13821 --- .github/workflows/release.yaml | 58 +++++++++ docs/install/releases/index.md | 22 ++-- scripts/update-release-calendar.sh | 191 +++++++++++++++++++++++++++++ 3 files changed, 260 insertions(+), 11 deletions(-) create mode 100755 scripts/update-release-calendar.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 94d7b6f9ae5e4..4889378389812 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -924,3 +924,61 @@ jobs: continue-on-error: true run: | make sqlc-push + + update-calendar: + name: "Update release calendar in docs" + runs-on: "ubuntu-latest" + needs: [release, publish-homebrew, publish-winget, publish-sqlc] + if: ${{ !inputs.dry_run }} + permissions: + contents: write + pull-requests: write + steps: + - name: Harden Runner + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 # Needed to get all tags for version calculation + + - name: Set up Git + run: | + git config user.name "Coder Bot" + git config user.email "coder-bot@coder.com" + + - name: Run update script + run: | + ./scripts/update-release-calendar.sh + + - name: Check for changes + id: check_changes + run: | + if git diff --quiet docs/install/releases/index.md; then + echo "No changes detected in release calendar." + echo "changes=false" >> $GITHUB_OUTPUT + else + echo "Changes detected in release calendar." + echo "changes=true" >> $GITHUB_OUTPUT + fi + + - name: Create Pull Request + if: steps.check_changes.outputs.changes == 'true' + uses: peter-evans/create-pull-request@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 + with: + commit-message: "docs: update release calendar" + title: "docs: update release calendar" + body: | + This PR automatically updates the release calendar in the docs. + + The calendar shows: + - Not Supported (older versions) + - Security Support (`n-2`) + - Stable (`n-1`) + - Mainline (`n`) + - Next Release (`n+1`, Not Released) + branch: bot/update-release-calendar + delete-branch: true + labels: docs diff --git a/docs/install/releases/index.md b/docs/install/releases/index.md index d0ab0d1a05d5e..e92a70a320e6d 100644 --- a/docs/install/releases/index.md +++ b/docs/install/releases/index.md @@ -54,17 +54,17 @@ pages. ## Release schedule -| Release name | Release Date | Status | -|--------------|--------------------|------------------| -| 2.12.x | June 04, 2024 | Not Supported | -| 2.13.x | July 02, 2024 | Not Supported | -| 2.14.x | August 06, 2024 | Not Supported | -| 2.15.x | September 03, 2024 | Not Supported | -| 2.16.x | October 01, 2024 | Not Supported | -| 2.17.x | November 05, 2024 | Not Supported | -| 2.18.x | December 03, 2024 | Security Support | -| 2.19.x | February 04, 2024 | Stable | -| 2.20.x | March 05, 2024 | Mainline | + +| Release name | Release Date | Status | Latest Release | +|-------------|-------------------|------------------|----------------| +| [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) | +| [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) | +| [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) | +| [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) | +| [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) | +| [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) | +| 2.22 | May 07, 2024 | Not Released | N/A | + > [!TIP] > We publish a diff --git a/scripts/update-release-calendar.sh b/scripts/update-release-calendar.sh new file mode 100755 index 0000000000000..7241a80374ec3 --- /dev/null +++ b/scripts/update-release-calendar.sh @@ -0,0 +1,191 @@ +#!/bin/bash + +set -euo pipefail + +# This script automatically updates the release calendar in docs/install/releases/index.md +# It calculates the releases based on the first Tuesday of each month rule +# and updates the status of each release (Not Supported, Security Support, Stable, Mainline, Not Released) + +DOCS_FILE="docs/install/releases/index.md" + +# Define unique markdown comments as anchors +CALENDAR_START_MARKER="" +CALENDAR_END_MARKER="" + +# Get current date +current_date=$(date +"%Y-%m-%d") +current_month=$(date +"%m") +current_year=$(date +"%Y") + +# Function to get the first Tuesday of a given month and year +get_first_tuesday() { + local year=$1 + local month=$2 + + # Find the first day of the month + local first_day=$(date -d "$year-$month-01" +"%u") + + # Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2) + local days_until_tuesday=$((first_day == 2 ? 0 : (9 - first_day) % 7)) + + # Get the date of the first Tuesday + local first_tuesday=$(date -d "$year-$month-01 +$days_until_tuesday days" +"%Y-%m-%d") + + echo "$first_tuesday" +} + +# Function to format date as "Month DD, YYYY" +format_date() { + date -d "$1" +"%B %d, %Y" +} + +# Function to get the latest patch version for a minor release +get_latest_patch() { + local version_major=$1 + local version_minor=$2 + + # Get all tags for this minor version + local tags=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep "^v$version_major\\.$version_minor\\." | sort -V) + + # Get the latest one + local latest=$(echo "$tags" | tail -1) + + if [ -z "$latest" ]; then + # If no tags found, return empty + echo "" + else + # Return without the v prefix + echo "${latest#v}" + fi +} + +# Generate releases table showing: +# - 3 previous unsupported releases +# - 1 security support release (n-2) +# - 1 stable release (n-1) +# - 1 mainline release (n) +# - 1 next release (n+1) +generate_release_calendar() { + local result="" + local version_major=2 + + # Find the current minor version by looking at the last mainline release tag + local latest_version=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep '^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1) + local version_minor=$(echo "$latest_version" | cut -d. -f2) + + # Start with 3 unsupported releases back + local start_minor=$((version_minor - 5)) + + # Initialize the calendar table with an additional column for latest release + result="| Release name | Release Date | Status | Latest Release |\n" + result+="|-------------|-------------------|------------------|----------------|\n" + + # Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next) + for i in {0..6}; do + # Calculate release minor version + local rel_minor=$((start_minor + i)) + # Format release name without the .x + local version_name="$version_major.$rel_minor" + + # Calculate release month and year based on release pattern + # This is a simplified calculation assuming monthly releases + local rel_month=$(( (current_month - (5 - i) + 12) % 12 )) + [[ $rel_month -eq 0 ]] && rel_month=12 + local rel_year=$current_year + if [[ $rel_month -gt $current_month ]]; then + rel_year=$((rel_year - 1)) + fi + if [[ $rel_month -lt $current_month && $i -gt 5 ]]; then + rel_year=$((rel_year + 1)) + fi + + # Skip January releases starting from 2025 + if [[ $rel_month -eq 1 && $rel_year -ge 2025 ]]; then + rel_month=2 + rel_year=$rel_year + fi + + # Get release date (first Tuesday of the month) + local release_date=$(get_first_tuesday $rel_year $(printf "%02d" $rel_month)) + local formatted_date=$(format_date "$release_date") + + # Get latest patch version + local latest_patch=$(get_latest_patch $version_major $rel_minor) + local patch_link="" + if [ -n "$latest_patch" ]; then + patch_link="[v${latest_patch}](https://github.com/coder/coder/releases/tag/v${latest_patch})" + else + patch_link="N/A" + fi + + # Determine status + local status + if [[ "$release_date" > "$current_date" ]]; then + status="Not Released" + elif [[ $i -eq 6 ]]; then + status="Not Released" + elif [[ $i -eq 5 ]]; then + status="Mainline" + elif [[ $i -eq 4 ]]; then + status="Stable" + elif [[ $i -eq 3 ]]; then + status="Security Support" + else + status="Not Supported" + fi + + # Format version name and patch link based on release status + # No links for unreleased versions + local formatted_version_name + if [[ "$status" == "Not Released" ]]; then + formatted_version_name="$version_name" + patch_link="N/A" + else + formatted_version_name="[$version_name](https://coder.com/changelog/coder-$version_major-$rel_minor)" + fi + + # Add row to table + result+="| $formatted_version_name | $formatted_date | $status | $patch_link |\n" + done + + echo -e "$result" +} + +# Check if the markdown comments exist in the file +if ! grep -q "$CALENDAR_START_MARKER" "$DOCS_FILE" || ! grep -q "$CALENDAR_END_MARKER" "$DOCS_FILE"; then + echo "Error: Markdown comment anchors not found in $DOCS_FILE" + echo "Please add the following anchors around the release calendar table:" + echo " $CALENDAR_START_MARKER" + echo " $CALENDAR_END_MARKER" + exit 1 +fi + +# Generate the new calendar table content +NEW_CALENDAR=$(generate_release_calendar) + +# Update the file while preserving the rest of the content +awk -v start_marker="$CALENDAR_START_MARKER" \ + -v end_marker="$CALENDAR_END_MARKER" \ + -v new_calendar="$NEW_CALENDAR" \ + ' + BEGIN { found_start = 0; found_end = 0; print_line = 1; } + $0 ~ start_marker { + print; + print new_calendar; + found_start = 1; + print_line = 0; + next; + } + $0 ~ end_marker { + found_end = 1; + print_line = 1; + print; + next; + } + print_line || !found_start || found_end { print } + ' "$DOCS_FILE" > "${DOCS_FILE}.new" + +# Replace the original file with the updated version +mv "${DOCS_FILE}.new" "$DOCS_FILE" + +echo "Successfully updated release calendar in $DOCS_FILE" \ No newline at end of file From 95e2f1ab0091df9516b31e25a9697947286566cf Mon Sep 17 00:00:00 2001 From: M Atif Ali Date: Wed, 23 Apr 2025 13:25:08 +0000 Subject: [PATCH 2/4] format the output and simplify PR description --- .github/workflows/release.yaml | 26 ++++++++++---------------- docs/install/releases/index.md | 16 ++++++++-------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4889378389812..040054eb84cbc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -924,7 +924,7 @@ jobs: continue-on-error: true run: | make sqlc-push - + update-calendar: name: "Update release calendar in docs" runs-on: "ubuntu-latest" @@ -938,21 +938,22 @@ jobs: uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 with: egress-policy: audit - + - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: - fetch-depth: 0 # Needed to get all tags for version calculation - + fetch-depth: 0 # Needed to get all tags for version calculation + - name: Set up Git run: | - git config user.name "Coder Bot" - git config user.email "coder-bot@coder.com" - + git config user.name "Coder CI" + git config user.email "cdrci@coder.com" + - name: Run update script run: | ./scripts/update-release-calendar.sh - + make fmt/markdown + - name: Check for changes id: check_changes run: | @@ -963,7 +964,7 @@ jobs: echo "Changes detected in release calendar." echo "changes=true" >> $GITHUB_OUTPUT fi - + - name: Create Pull Request if: steps.check_changes.outputs.changes == 'true' uses: peter-evans/create-pull-request@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 @@ -972,13 +973,6 @@ jobs: title: "docs: update release calendar" body: | This PR automatically updates the release calendar in the docs. - - The calendar shows: - - Not Supported (older versions) - - Security Support (`n-2`) - - Stable (`n-1`) - - Mainline (`n`) - - Next Release (`n+1`, Not Released) branch: bot/update-release-calendar delete-branch: true labels: docs diff --git a/docs/install/releases/index.md b/docs/install/releases/index.md index e92a70a320e6d..0f19ded3289d4 100644 --- a/docs/install/releases/index.md +++ b/docs/install/releases/index.md @@ -55,15 +55,15 @@ pages. ## Release schedule -| Release name | Release Date | Status | Latest Release | -|-------------|-------------------|------------------|----------------| -| [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) | -| [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) | -| [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) | +| Release name | Release Date | Status | Latest Release | +|------------------------------------------------|-------------------|------------------|----------------------------------------------------------------| +| [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) | +| [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) | +| [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) | | [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) | -| [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) | -| [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) | -| 2.22 | May 07, 2024 | Not Released | N/A | +| [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) | +| [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) | +| 2.22 | May 07, 2024 | Not Released | N/A | > [!TIP] From e60c0f55625e51e0b5cb8dbe5fac2da43efa9889 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 24 Apr 2025 07:33:38 +0000 Subject: [PATCH 3/4] fmt --- scripts/update-release-calendar.sh | 246 ++++++++++++++--------------- 1 file changed, 123 insertions(+), 123 deletions(-) diff --git a/scripts/update-release-calendar.sh b/scripts/update-release-calendar.sh index 7241a80374ec3..b3667eda9ded9 100755 --- a/scripts/update-release-calendar.sh +++ b/scripts/update-release-calendar.sh @@ -19,44 +19,44 @@ current_year=$(date +"%Y") # Function to get the first Tuesday of a given month and year get_first_tuesday() { - local year=$1 - local month=$2 - - # Find the first day of the month - local first_day=$(date -d "$year-$month-01" +"%u") - - # Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2) - local days_until_tuesday=$((first_day == 2 ? 0 : (9 - first_day) % 7)) - - # Get the date of the first Tuesday - local first_tuesday=$(date -d "$year-$month-01 +$days_until_tuesday days" +"%Y-%m-%d") - - echo "$first_tuesday" + local year=$1 + local month=$2 + + # Find the first day of the month + local first_day=$(date -d "$year-$month-01" +"%u") + + # Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2) + local days_until_tuesday=$((first_day == 2 ? 0 : (9 - first_day) % 7)) + + # Get the date of the first Tuesday + local first_tuesday=$(date -d "$year-$month-01 +$days_until_tuesday days" +"%Y-%m-%d") + + echo "$first_tuesday" } # Function to format date as "Month DD, YYYY" format_date() { - date -d "$1" +"%B %d, %Y" + date -d "$1" +"%B %d, %Y" } # Function to get the latest patch version for a minor release get_latest_patch() { - local version_major=$1 - local version_minor=$2 - - # Get all tags for this minor version - local tags=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep "^v$version_major\\.$version_minor\\." | sort -V) - - # Get the latest one - local latest=$(echo "$tags" | tail -1) - - if [ -z "$latest" ]; then - # If no tags found, return empty - echo "" - else - # Return without the v prefix - echo "${latest#v}" - fi + local version_major=$1 + local version_minor=$2 + + # Get all tags for this minor version + local tags=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep "^v$version_major\\.$version_minor\\." | sort -V) + + # Get the latest one + local latest=$(echo "$tags" | tail -1) + + if [ -z "$latest" ]; then + # If no tags found, return empty + echo "" + else + # Return without the v prefix + echo "${latest#v}" + fi } # Generate releases table showing: @@ -66,98 +66,98 @@ get_latest_patch() { # - 1 mainline release (n) # - 1 next release (n+1) generate_release_calendar() { - local result="" - local version_major=2 - - # Find the current minor version by looking at the last mainline release tag - local latest_version=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep '^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1) - local version_minor=$(echo "$latest_version" | cut -d. -f2) - - # Start with 3 unsupported releases back - local start_minor=$((version_minor - 5)) - - # Initialize the calendar table with an additional column for latest release - result="| Release name | Release Date | Status | Latest Release |\n" - result+="|-------------|-------------------|------------------|----------------|\n" - - # Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next) - for i in {0..6}; do - # Calculate release minor version - local rel_minor=$((start_minor + i)) - # Format release name without the .x - local version_name="$version_major.$rel_minor" - - # Calculate release month and year based on release pattern - # This is a simplified calculation assuming monthly releases - local rel_month=$(( (current_month - (5 - i) + 12) % 12 )) - [[ $rel_month -eq 0 ]] && rel_month=12 - local rel_year=$current_year - if [[ $rel_month -gt $current_month ]]; then - rel_year=$((rel_year - 1)) - fi - if [[ $rel_month -lt $current_month && $i -gt 5 ]]; then - rel_year=$((rel_year + 1)) - fi - - # Skip January releases starting from 2025 - if [[ $rel_month -eq 1 && $rel_year -ge 2025 ]]; then - rel_month=2 - rel_year=$rel_year - fi - - # Get release date (first Tuesday of the month) - local release_date=$(get_first_tuesday $rel_year $(printf "%02d" $rel_month)) - local formatted_date=$(format_date "$release_date") - - # Get latest patch version - local latest_patch=$(get_latest_patch $version_major $rel_minor) - local patch_link="" - if [ -n "$latest_patch" ]; then - patch_link="[v${latest_patch}](https://github.com/coder/coder/releases/tag/v${latest_patch})" - else - patch_link="N/A" - fi - - # Determine status - local status - if [[ "$release_date" > "$current_date" ]]; then - status="Not Released" - elif [[ $i -eq 6 ]]; then - status="Not Released" - elif [[ $i -eq 5 ]]; then - status="Mainline" - elif [[ $i -eq 4 ]]; then - status="Stable" - elif [[ $i -eq 3 ]]; then - status="Security Support" - else - status="Not Supported" - fi - - # Format version name and patch link based on release status - # No links for unreleased versions - local formatted_version_name - if [[ "$status" == "Not Released" ]]; then - formatted_version_name="$version_name" - patch_link="N/A" - else - formatted_version_name="[$version_name](https://coder.com/changelog/coder-$version_major-$rel_minor)" - fi - - # Add row to table - result+="| $formatted_version_name | $formatted_date | $status | $patch_link |\n" - done - - echo -e "$result" + local result="" + local version_major=2 + + # Find the current minor version by looking at the last mainline release tag + local latest_version=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep '^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1) + local version_minor=$(echo "$latest_version" | cut -d. -f2) + + # Start with 3 unsupported releases back + local start_minor=$((version_minor - 5)) + + # Initialize the calendar table with an additional column for latest release + result="| Release name | Release Date | Status | Latest Release |\n" + result+="|-------------|-------------------|------------------|----------------|\n" + + # Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next) + for i in {0..6}; do + # Calculate release minor version + local rel_minor=$((start_minor + i)) + # Format release name without the .x + local version_name="$version_major.$rel_minor" + + # Calculate release month and year based on release pattern + # This is a simplified calculation assuming monthly releases + local rel_month=$(((current_month - (5 - i) + 12) % 12)) + [[ $rel_month -eq 0 ]] && rel_month=12 + local rel_year=$current_year + if [[ $rel_month -gt $current_month ]]; then + rel_year=$((rel_year - 1)) + fi + if [[ $rel_month -lt $current_month && $i -gt 5 ]]; then + rel_year=$((rel_year + 1)) + fi + + # Skip January releases starting from 2025 + if [[ $rel_month -eq 1 && $rel_year -ge 2025 ]]; then + rel_month=2 + rel_year=$rel_year + fi + + # Get release date (first Tuesday of the month) + local release_date=$(get_first_tuesday $rel_year $(printf "%02d" $rel_month)) + local formatted_date=$(format_date "$release_date") + + # Get latest patch version + local latest_patch=$(get_latest_patch $version_major $rel_minor) + local patch_link="" + if [ -n "$latest_patch" ]; then + patch_link="[v${latest_patch}](https://github.com/coder/coder/releases/tag/v${latest_patch})" + else + patch_link="N/A" + fi + + # Determine status + local status + if [[ "$release_date" > "$current_date" ]]; then + status="Not Released" + elif [[ $i -eq 6 ]]; then + status="Not Released" + elif [[ $i -eq 5 ]]; then + status="Mainline" + elif [[ $i -eq 4 ]]; then + status="Stable" + elif [[ $i -eq 3 ]]; then + status="Security Support" + else + status="Not Supported" + fi + + # Format version name and patch link based on release status + # No links for unreleased versions + local formatted_version_name + if [[ "$status" == "Not Released" ]]; then + formatted_version_name="$version_name" + patch_link="N/A" + else + formatted_version_name="[$version_name](https://coder.com/changelog/coder-$version_major-$rel_minor)" + fi + + # Add row to table + result+="| $formatted_version_name | $formatted_date | $status | $patch_link |\n" + done + + echo -e "$result" } # Check if the markdown comments exist in the file if ! grep -q "$CALENDAR_START_MARKER" "$DOCS_FILE" || ! grep -q "$CALENDAR_END_MARKER" "$DOCS_FILE"; then - echo "Error: Markdown comment anchors not found in $DOCS_FILE" - echo "Please add the following anchors around the release calendar table:" - echo " $CALENDAR_START_MARKER" - echo " $CALENDAR_END_MARKER" - exit 1 + echo "Error: Markdown comment anchors not found in $DOCS_FILE" + echo "Please add the following anchors around the release calendar table:" + echo " $CALENDAR_START_MARKER" + echo " $CALENDAR_END_MARKER" + exit 1 fi # Generate the new calendar table content @@ -165,9 +165,9 @@ NEW_CALENDAR=$(generate_release_calendar) # Update the file while preserving the rest of the content awk -v start_marker="$CALENDAR_START_MARKER" \ - -v end_marker="$CALENDAR_END_MARKER" \ - -v new_calendar="$NEW_CALENDAR" \ - ' + -v end_marker="$CALENDAR_END_MARKER" \ + -v new_calendar="$NEW_CALENDAR" \ + ' BEGIN { found_start = 0; found_end = 0; print_line = 1; } $0 ~ start_marker { print; @@ -183,9 +183,9 @@ awk -v start_marker="$CALENDAR_START_MARKER" \ next; } print_line || !found_start || found_end { print } - ' "$DOCS_FILE" > "${DOCS_FILE}.new" + ' "$DOCS_FILE" >"${DOCS_FILE}.new" # Replace the original file with the updated version mv "${DOCS_FILE}.new" "$DOCS_FILE" -echo "Successfully updated release calendar in $DOCS_FILE" \ No newline at end of file +echo "Successfully updated release calendar in $DOCS_FILE" From 43539a56f9a3b1a46aa033391249a6046a46700b Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 24 Apr 2025 07:51:39 +0000 Subject: [PATCH 4/4] Update release calendar and improve update script --- docs/install/releases/index.md | 4 +-- scripts/update-release-calendar.sh | 58 ++++++++++++++++++------------ 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/docs/install/releases/index.md b/docs/install/releases/index.md index 0f19ded3289d4..09aca9f37cb9b 100644 --- a/docs/install/releases/index.md +++ b/docs/install/releases/index.md @@ -53,7 +53,7 @@ Best practices for installing Coder can be found on our [install](../index.md) pages. ## Release schedule - + | Release name | Release Date | Status | Latest Release | |------------------------------------------------|-------------------|------------------|----------------------------------------------------------------| @@ -62,7 +62,7 @@ pages. | [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) | | [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) | | [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) | -| [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) | +| [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) | | 2.22 | May 07, 2024 | Not Released | N/A | diff --git a/scripts/update-release-calendar.sh b/scripts/update-release-calendar.sh index b3667eda9ded9..a9fe6e54d605d 100755 --- a/scripts/update-release-calendar.sh +++ b/scripts/update-release-calendar.sh @@ -21,15 +21,18 @@ current_year=$(date +"%Y") get_first_tuesday() { local year=$1 local month=$2 + local first_day + local days_until_tuesday + local first_tuesday # Find the first day of the month - local first_day=$(date -d "$year-$month-01" +"%u") + first_day=$(date -d "$year-$month-01" +"%u") # Calculate days until first Tuesday (if day 1 is Tuesday, first_day=2) - local days_until_tuesday=$((first_day == 2 ? 0 : (9 - first_day) % 7)) + days_until_tuesday=$((first_day == 2 ? 0 : (9 - first_day) % 7)) # Get the date of the first Tuesday - local first_tuesday=$(date -d "$year-$month-01 +$days_until_tuesday days" +"%Y-%m-%d") + first_tuesday=$(date -d "$year-$month-01 +$days_until_tuesday days" +"%Y-%m-%d") echo "$first_tuesday" } @@ -43,12 +46,14 @@ format_date() { get_latest_patch() { local version_major=$1 local version_minor=$2 + local tags + local latest # Get all tags for this minor version - local tags=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep "^v$version_major\\.$version_minor\\." | sort -V) + tags=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep "^v$version_major\\.$version_minor\\." | sort -V) # Get the latest one - local latest=$(echo "$tags" | tail -1) + latest=$(echo "$tags" | tail -1) if [ -z "$latest" ]; then # If no tags found, return empty @@ -68,17 +73,20 @@ get_latest_patch() { generate_release_calendar() { local result="" local version_major=2 + local latest_version + local version_minor + local start_minor # Find the current minor version by looking at the last mainline release tag - local latest_version=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep '^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1) - local version_minor=$(echo "$latest_version" | cut -d. -f2) + latest_version=$(cd "$(git rev-parse --show-toplevel)" && git tag | grep '^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1) + version_minor=$(echo "$latest_version" | cut -d. -f2) # Start with 3 unsupported releases back - local start_minor=$((version_minor - 5)) + start_minor=$((version_minor - 5)) # Initialize the calendar table with an additional column for latest release - result="| Release name | Release Date | Status | Latest Release |\n" - result+="|-------------|-------------------|------------------|----------------|\n" + result="| Release name | Release Date | Status | Latest Release |\n" + result+="|--------------|--------------|--------|----------------|\n" # Generate rows for each release (7 total: 3 unsupported, 1 security, 1 stable, 1 mainline, 1 next) for i in {0..6}; do @@ -86,6 +94,12 @@ generate_release_calendar() { local rel_minor=$((start_minor + i)) # Format release name without the .x local version_name="$version_major.$rel_minor" + local release_date + local formatted_date + local latest_patch + local patch_link + local status + local formatted_version_name # Calculate release month and year based on release pattern # This is a simplified calculation assuming monthly releases @@ -102,16 +116,15 @@ generate_release_calendar() { # Skip January releases starting from 2025 if [[ $rel_month -eq 1 && $rel_year -ge 2025 ]]; then rel_month=2 - rel_year=$rel_year + # No need to reassign rel_year to itself fi # Get release date (first Tuesday of the month) - local release_date=$(get_first_tuesday $rel_year $(printf "%02d" $rel_month)) - local formatted_date=$(format_date "$release_date") + release_date=$(get_first_tuesday "$rel_year" "$(printf "%02d" "$rel_month")") + formatted_date=$(format_date "$release_date") # Get latest patch version - local latest_patch=$(get_latest_patch $version_major $rel_minor) - local patch_link="" + latest_patch=$(get_latest_patch "$version_major" "$rel_minor") if [ -n "$latest_patch" ]; then patch_link="[v${latest_patch}](https://github.com/coder/coder/releases/tag/v${latest_patch})" else @@ -119,7 +132,6 @@ generate_release_calendar() { fi # Determine status - local status if [[ "$release_date" > "$current_date" ]]; then status="Not Released" elif [[ $i -eq 6 ]]; then @@ -136,7 +148,6 @@ generate_release_calendar() { # Format version name and patch link based on release status # No links for unreleased versions - local formatted_version_name if [[ "$status" == "Not Released" ]]; then formatted_version_name="$version_name" patch_link="N/A" @@ -169,14 +180,14 @@ awk -v start_marker="$CALENDAR_START_MARKER" \ -v new_calendar="$NEW_CALENDAR" \ ' BEGIN { found_start = 0; found_end = 0; print_line = 1; } - $0 ~ start_marker { - print; - print new_calendar; + $0 ~ start_marker { + print; + print new_calendar; found_start = 1; print_line = 0; - next; + next; } - $0 ~ end_marker { + $0 ~ end_marker { found_end = 1; print_line = 1; print; @@ -188,4 +199,7 @@ awk -v start_marker="$CALENDAR_START_MARKER" \ # Replace the original file with the updated version mv "${DOCS_FILE}.new" "$DOCS_FILE" +# run make fmt/markdown +make fmt/markdown + echo "Successfully updated release calendar in $DOCS_FILE"