thomaseizinger/keep-a-changelog-new-release

Fails to get version on first release

Closed this issue · 3 comments

Hi, great action!

I noticed that per keep-a-changelog spec, if you have a fresh changelog (1.0.0) then this action will fail.

It is looking for ... separator that doesn't exist on ...release/tag/1.0.0

const split = link.split("...");

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.0] - 2022-02-08

### Added

-   Initial release of this action!

[Unreleased]: https://github.com/me/myapp/compare/1.0.0...HEAD

[1.0.0]: https://github.com/me/myapp/releases/tag/1.0.0

My workaround for now is to change the url to .../compare/1.0.0...1.0.0

Interesting. There is a testcase for this https://github.com/thomaseizinger/keep-a-changelog-new-release/tree/master/__tests__/fixtures/first_release.

Would you mind opening a PR with a failing test case?

I may have a similar issue with the first release. Before the first release I added the following to the CHANGELOG.md:

[Unreleased]: https://github.com/gschwaer/myrepo/compare/22549a94e175db0b8fedd0ffffd3936bfa744769...HEAD

Where 22549a94e175db0b8fedd0ffffd3936bfa744769 was the initial commit.

After the action ran (with version = v0.1.0), the CHANGELOG.md contained:

[Unreleased]: https://github.com/gschwaer/myrepo/compare/v0.1.0...HEAD

[0.1.0]: https://github.com/gschwaer/myrepo/compare/95d5280d0b43f9d6610c680621c85af39a8b7dea...v0.1.0

Where 95d5280d0b43f9d6610c680621c85af39a8b7dea is the same as v0.1.0. Why did it change that? I assumed it would only change the label and the second part of the compare (after ...).

Or maybe, was it incorrect to add the unreleased link in the initial CHANGELOG.md?

The action should handle adding the first link by itself. Can you try without adding the unreleased link?