Skip to content

Commit

Permalink
Add publish date of versions to changelog (#65)
Browse files Browse the repository at this point in the history
Add the publish date to the changelog for each version so it's easier to
tell when looking at the changelog when a version of a package was
released.

Closes #35
  • Loading branch information
tombruijn authored Jan 18, 2024
1 parent d444513 commit ad5a451
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changesets/add-published-on-date-to-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "change"
---

Add the publish date for each version to the changelog. This allows people to see at a glance when a version was released.
3 changes: 3 additions & 0 deletions lib/mono/changeset_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ def write_changesets_to_changelog
contents = File.read(changelog_path)
lines = contents.lines # Keep original contents to add to the bottom
heading = lines.shift # Keep original heading
date = Time.now.utc.strftime("%Y-%m-%d")
File.write(changelog_path, <<~CHANGELOG)
#{heading}
## #{package.next_version}
_Published on #{date}._
#{content.join.strip}
#{lines.join.strip}
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/mono/changeset_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def map_changesets(changesets)
expect(changelog).to include(<<~CHANGELOG)
## 2.0.0
_Published on #{date_label}._
### Added
- [LINK] major - This is a major changeset bump.
Expand Down Expand Up @@ -276,6 +278,8 @@ def map_changesets(changesets)
expect(changelog).to include(<<~CHANGELOG)
## 2.0.0
_Published on #{date_label}._
### Deprecated
- [LINK] patch - This is a patch changeset bump.
Expand All @@ -293,4 +297,8 @@ def normalize_changelog(content)
# Remove links so we don't have to try and match against every instance
content.gsub(/\[[a-z0-9]{7}\]\(.+\)/, "[LINK]")
end

def date_label
Time.now.utc.strftime("%Y-%m-%d")
end
end

0 comments on commit ad5a451

Please sign in to comment.