From 677210773377d0c7a14cedf84b424869b68e4447 Mon Sep 17 00:00:00 2001 From: Oleg Samarin Date: Thu, 16 Apr 2026 21:23:18 +0300 Subject: [PATCH] Added auto-insert of release date in CHANGELOG when date is omitted CI now extracts the date from the CHANGELOG heading if present, or defaults to today's date. The first line is rewritten wholesale instead of using a prefix-replacement pattern, so `# MAJOR.MINOR` (without a date) is now a valid release signal. Co-Authored-By: Claude Sonnet 4.6 --- CLAUDE.md | 10 +++++----- build-scripts/autotag.sh | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index be13e82c..212f4bb5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,7 +33,7 @@ A release has an explicit **start** and **finish**: **During development** — add user-visible changes to `CHANGELOG.md` (see rules below). **Finishing a release** (only this, nothing else): -- Update `CHANGELOG.md` heading to `# MAJOR.MINOR` (matching current `pom.xml`) → CI sees this as the release signal, creates release tag `MAJOR.MINOR.N`, and publishes a GitHub Release +- Update `CHANGELOG.md` heading to `# MAJOR.MINOR` or `# MAJOR.MINOR (YYYY-MM-DD)` (matching current `pom.xml`) → CI sees this as the release signal, creates release tag `MAJOR.MINOR.N`, and publishes a GitHub Release. If the date is omitted, CI inserts today's date automatically. **After a published release** — CI auto-edits `CHANGELOG.md`: the release heading `# MAJOR.MINOR (date)` is replaced with `# MAJOR.MINOR.N (date)`. Development can continue immediately; patch versions increment from the last released N. @@ -54,18 +54,18 @@ git push origin release/0.17 Version numbers continue from the last released patch: if `0.17.3` was the last release, the next builds are `0.17.4`, `0.17.5`, etc. **Releasing a patch:** -- Add `# 0.17 (YYYY-MM-DD)` at the top of `CHANGELOG.md` (together with the fix's bullet) +- Add `# 0.17` or `# 0.17 (YYYY-MM-DD)` at the top of `CHANGELOG.md` (together with the fix's bullet). If the date is omitted, CI inserts today's date automatically. - Push → CI creates tag `0.17.N`, publishes GitHub Release, and auto-edits `CHANGELOG.md` to `# 0.17.N (YYYY-MM-DD)` -**Next patch:** add `# 0.17 (YYYY-MM-DD)` again and repeat. +**Next patch:** add `# 0.17` or `# 0.17 (YYYY-MM-DD)` again and repeat. `main` is fully unaffected throughout. ### CHANGELOG.md rules -The heading `# MAJOR.MINOR (YYYY-MM-DD)` is the CI release signal — **only add it when finishing a release**. Always include the release date in parentheses (e.g. `# 0.18 (2026-04-04)`). +The heading `# MAJOR.MINOR` or `# MAJOR.MINOR (YYYY-MM-DD)` is the CI release signal — **only add it when finishing a release**. The date is optional; if omitted, CI inserts today's date automatically (e.g. `# 0.18` or `# 0.18 (2026-04-04)`). -During development, add bullet lines at the **very top** of `CHANGELOG.md` (above any existing heading), with no section heading. When finishing a release, add the `# MAJOR.MINOR (YYYY-MM-DD)` heading above those bullets. +During development, add bullet lines at the **very top** of `CHANGELOG.md` (above any existing heading), with no section heading. When finishing a release, add the `# MAJOR.MINOR` or `# MAJOR.MINOR (YYYY-MM-DD)` heading above those bullets. The changelog within a release is **cumulative**: if a feature was added and later refined or fixed within the same release cycle, **update the existing bullet** rather than adding a new one. Do not add separate "Fixed" entries for bugs in functionality that was introduced in the current (unreleased) version — only the final user-visible state matters. diff --git a/build-scripts/autotag.sh b/build-scripts/autotag.sh index 41ffeb83..ed37d2ea 100755 --- a/build-scripts/autotag.sh +++ b/build-scripts/autotag.sh @@ -58,13 +58,16 @@ FIRST_LINE=$(head -n 1 "$CHANGELOG" 2>/dev/null || echo "") if [[ "$(echo "$FIRST_LINE" | cut -d' ' -f1)" == "#" ]]; then CHANGELOG_MM=$(echo "$FIRST_LINE" | cut -d' ' -f2) fi +# Extract date from heading (e.g. "# 0.21 (2026-04-16)"), or default to today +HEADING_DATE=$(echo "$FIRST_LINE" | sed -n 's/^# [^ ]* (\(.*\))$/\1/p') +RELEASE_DATE="${HEADING_DATE:-$(date +%Y-%m-%d)}" if [[ "$CHANGELOG_MM" == "$MM" ]]; then if [[ -n "$RELEASE_TAG" ]] && ! grep -qE "^# ${MM_ESCAPED}\.[0-9]+" "$CHANGELOG"; then # Stale release signal: published release exists but CHANGELOG was never auto-edited # (e.g. branch created from old release commit). Rename heading, don't create new release. echo "Stale release signal: renaming to $RELEASE_TAG" - sed -i "s|^# ${MM_ESCAPED} |# ${RELEASE_TAG} |" "$CHANGELOG" + sed -i "1s|^.*$|# ${RELEASE_TAG} (${RELEASE_DATE})|" "$CHANGELOG" git add "$CHANGELOG" git commit -m "Released ${RELEASE_TAG}" git push origin HEAD @@ -84,7 +87,7 @@ if [[ "$CHANGELOG_MM" == "$MM" ]]; then sed '0,/^#/d;/^#/Q' "$CHANGELOG" > "$RELEASE_NOTES" || echo "Release $FULL_VER" > "$RELEASE_NOTES" # Auto-edit CHANGELOG: replace "# MM (date)" with "# FULL_VER (date)" to clear the release signal - sed -i "s|^# ${MM_ESCAPED} |# ${FULL_VER} |" "$CHANGELOG" + sed -i "1s|^.*$|# ${FULL_VER} (${RELEASE_DATE})|" "$CHANGELOG" git add "$CHANGELOG" git commit -m "Released ${FULL_VER}" # Tag the CHANGELOG commit so "git tag --points-at HEAD" finds it in Calculate version