Skip to content

Commit fedcb85

Browse files
committed
feat: Add automated changelog date management
- Add Rake tasks for changelog management: - changelog:update_date - Updates all entries with current date - changelog:new_version - Adds new version entry with current date - release:prepare - Comprehensive release preparation - Add Ruby script for direct changelog date updates - Add optional pre-commit hook for automatic date updates - Update GitHub Actions release workflow to auto-update dates - Add comprehensive documentation for changelog automation Benefits: - Prevents date inconsistencies (like 2024 dates in 2025) - Automates tedious manual date entry - Integrates with CI/CD pipeline - Uses system time for accuracy and consistency Fixes the issue where CHANGELOG.md showed 2024-12-15 for v1.0.0 when current date is 2025-09-15
1 parent e44d57c commit fedcb85

6 files changed

Lines changed: 250 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ jobs:
1919
ruby-version: '3.2'
2020
bundler-cache: true
2121

22+
- name: Extract version from tag
23+
id: version
24+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
25+
26+
- name: Update changelog with current date
27+
run: ruby scripts/update_changelog_date.rb ${{ steps.version.outputs.VERSION }}
28+
2229
- name: Run full test suite
2330
run: bundle exec rake ci
2431
env:

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.0.0] - 2024-12-15
8+
## [1.0.0] - 2025-09-15
99

1010
### Added
1111
- Complete A2A Protocol v0.3.0 implementation

Rakefile

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,97 @@ end
6565
desc "Run all tests for CI"
6666
task ci: %w[rubocop spec:unit spec:integration spec:compliance]
6767

68+
# Changelog management
69+
namespace :changelog do
70+
desc "Update changelog with current date for unreleased version"
71+
task :update_date do
72+
changelog_path = "CHANGELOG.md"
73+
current_date = Time.now.strftime("%Y-%m-%d")
74+
75+
unless File.exist?(changelog_path)
76+
puts "CHANGELOG.md not found!"
77+
exit 1
78+
end
79+
80+
content = File.read(changelog_path)
81+
82+
# Replace any unreleased or incorrect dates with current date
83+
# Pattern matches: ## [version] - YYYY-MM-DD or ## [version] - Unreleased
84+
updated_content = content.gsub(/^(## \[[^\]]+\]) - (?:\d{4}-\d{2}-\d{2}|Unreleased)$/) do |match|
85+
version_part = match.split(' - ').first
86+
"#{version_part} - #{current_date}"
87+
end
88+
89+
if content != updated_content
90+
File.write(changelog_path, updated_content)
91+
puts "Updated CHANGELOG.md with current date: #{current_date}"
92+
else
93+
puts "No changelog dates needed updating"
94+
end
95+
end
96+
97+
desc "Add new version entry to changelog"
98+
task :new_version, [:version] do |task, args|
99+
version = args[:version] || ENV['VERSION']
100+
101+
unless version
102+
puts "Please provide a version: rake changelog:new_version[1.0.1] or VERSION=1.0.1 rake changelog:new_version"
103+
exit 1
104+
end
105+
106+
changelog_path = "CHANGELOG.md"
107+
current_date = Time.now.strftime("%Y-%m-%d")
108+
109+
unless File.exist?(changelog_path)
110+
puts "CHANGELOG.md not found!"
111+
exit 1
112+
end
113+
114+
content = File.read(changelog_path)
115+
116+
# Find the first ## heading and insert new version before it
117+
new_entry = <<~ENTRY
118+
## [#{version}] - #{current_date}
119+
120+
### Added
121+
-
122+
123+
### Changed
124+
-
125+
126+
### Fixed
127+
-
128+
129+
ENTRY
130+
131+
# Insert after the header but before the first version entry
132+
updated_content = content.sub(/^(# Changelog.*?\n\n)/m, "\\1#{new_entry}")
133+
134+
File.write(changelog_path, updated_content)
135+
puts "Added new version #{version} to CHANGELOG.md with date #{current_date}"
136+
end
137+
end
138+
139+
# Release tasks
140+
namespace :release do
141+
desc "Prepare release with updated changelog date"
142+
task :prepare, [:version] do |task, args|
143+
version = args[:version] || ENV['VERSION']
144+
145+
if version
146+
Rake::Task["changelog:new_version"].invoke(version)
147+
else
148+
Rake::Task["changelog:update_date"].invoke
149+
end
150+
151+
puts "Release preparation complete!"
152+
puts "Don't forget to:"
153+
puts "1. Update version in lib/a2a/version.rb"
154+
puts "2. Commit changes"
155+
puts "3. Create and push git tag: git tag v#{version || 'X.X.X'} && git push origin v#{version || 'X.X.X'}"
156+
end
157+
end
158+
68159
# Default task
69160
task default: :spec
70161

docs/CHANGELOG_AUTOMATION.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Changelog Automation
2+
3+
This project includes automated tools to manage changelog dates and prevent date inconsistencies.
4+
5+
## Available Tools
6+
7+
### 1. Rake Tasks
8+
9+
Update changelog dates automatically:
10+
11+
```bash
12+
# Update all changelog entries with current date
13+
rake changelog:update_date
14+
15+
# Add a new version entry with current date
16+
rake changelog:new_version[1.0.1]
17+
18+
# Prepare a release (updates changelog and provides next steps)
19+
rake release:prepare[1.0.1]
20+
```
21+
22+
### 2. Ruby Script
23+
24+
Direct script execution:
25+
26+
```bash
27+
# Update all entries
28+
ruby scripts/update_changelog_date.rb
29+
30+
# Update specific version
31+
ruby scripts/update_changelog_date.rb 1.0.1
32+
```
33+
34+
### 3. Pre-commit Hook (Optional)
35+
36+
Automatically update changelog dates when committing:
37+
38+
```bash
39+
# Install the pre-commit hook
40+
ln -s ../../scripts/pre-commit-changelog .git/hooks/pre-commit
41+
```
42+
43+
### 4. GitHub Actions Integration
44+
45+
The release workflow automatically updates changelog dates when creating releases from git tags.
46+
47+
## Usage Examples
48+
49+
### Adding a New Release
50+
51+
1. **Manual approach:**
52+
```bash
53+
rake changelog:new_version[1.2.0]
54+
# Edit CHANGELOG.md to add your changes
55+
git add CHANGELOG.md
56+
git commit -m "Add changelog for v1.2.0"
57+
```
58+
59+
2. **With release preparation:**
60+
```bash
61+
rake release:prepare[1.2.0]
62+
# Follow the printed instructions
63+
```
64+
65+
### Fixing Date Issues
66+
67+
If you notice incorrect dates in the changelog:
68+
69+
```bash
70+
rake changelog:update_date
71+
```
72+
73+
This will update all entries to use the current system date.
74+
75+
## Benefits
76+
77+
- **Consistency**: All dates use the current system time
78+
- **Automation**: No manual date entry required
79+
- **CI/CD Integration**: Automatic updates during releases
80+
- **Developer Friendly**: Optional pre-commit hooks for convenience
81+
82+
## Date Format
83+
84+
All dates use the ISO 8601 format: `YYYY-MM-DD` (e.g., `2025-09-15`)
85+
86+
This format is:
87+
- Sortable
88+
- Unambiguous
89+
- Follows the [Keep a Changelog](https://keepachangelog.com/) standard

scripts/pre-commit-changelog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# Pre-commit hook to automatically update changelog dates
3+
# To install: ln -s ../../scripts/pre-commit-changelog .git/hooks/pre-commit
4+
5+
set -e
6+
7+
# Check if CHANGELOG.md is being committed
8+
if git diff --cached --name-only | grep -q "CHANGELOG.md"; then
9+
echo "Updating CHANGELOG.md dates..."
10+
ruby scripts/update_changelog_date.rb
11+
12+
# Add the updated changelog back to the commit
13+
git add CHANGELOG.md
14+
echo "CHANGELOG.md dates updated automatically"
15+
fi

scripts/update_changelog_date.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
# Script to automatically update changelog dates with current system time
5+
# Usage: ruby scripts/update_changelog_date.rb [version]
6+
7+
require 'time'
8+
9+
def update_changelog_date(version = nil)
10+
changelog_path = 'CHANGELOG.md'
11+
current_date = Time.now.strftime('%Y-%m-%d')
12+
13+
unless File.exist?(changelog_path)
14+
puts "ERROR: CHANGELOG.md not found!"
15+
exit 1
16+
end
17+
18+
content = File.read(changelog_path)
19+
original_content = content.dup
20+
21+
if version
22+
# Update specific version
23+
pattern = /^(## \[#{Regexp.escape(version)}\]) - (?:\d{4}-\d{2}-\d{2}|Unreleased)$/
24+
content.gsub!(pattern, "\\1 - #{current_date}")
25+
puts "Updated version #{version} to date #{current_date}"
26+
else
27+
# Update all versions with incorrect or unreleased dates
28+
content.gsub!(/^(## \[[^\]]+\]) - (?:\d{4}-\d{2}-\d{2}|Unreleased)$/) do |match|
29+
version_part = match.split(' - ').first
30+
"#{version_part} - #{current_date}"
31+
end
32+
puts "Updated all changelog entries to current date: #{current_date}"
33+
end
34+
35+
if content != original_content
36+
File.write(changelog_path, content)
37+
puts "CHANGELOG.md updated successfully"
38+
else
39+
puts "No changes needed in CHANGELOG.md"
40+
end
41+
end
42+
43+
# Main execution
44+
if __FILE__ == $0
45+
version = ARGV[0]
46+
update_changelog_date(version)
47+
end

0 commit comments

Comments
 (0)