Search code examples
githubauto-generatechangelog

GitHub changelog links to commits


Some projects have a CHANGELOG.md file where each version links to the range of commits that were made for that version. For example, this one. It looks like these links are automatically generated somehow, because the markdown only contains [1.0.0] where the rendered document has a link to https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0.

How does that work? I've tried to do something like this on my own project, but the rendered document just said [1.0.0]; no link was generated.

Presumably it has something to do with the tags, which follow a similar pattern (v1.0.0), but when I tried to create similar tags in my project, it still didn't work.

I also could find no reference to this on the GitHub help, or anywhere else for that matter.

Is this indeed an (undocumented?) feature of GitHub? If yes, how does it work? If no, how do these projects do it?

Note, I'm not interested in automatically generating a changelog from commits like this project does. I'm just interested in the mechanics of these hyperlinks.


Solution

  • You need to look beneath the surface of the Markdown, it's a simple trick he done by using the file compare feature to compare tags.

    If you look at the RAW file, you should notice at the bottom he added links to each version number that has a compare link assigned to it.

    ## [1.0.0] - 2017-06-20
    
    [1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
    

    With pretty mode, you would see the link to the compare page.