Establish a Changelog driven version publishing process

Establish a Changelog driven version publishing process

The power of using gnu make with javascript for CD automations

Keeping a consistent changelog is not the easiest thing. I found, that turning the CHANGELOG.md file to the trigger of creating new versions helps a lot. Here's what I've done for the RoyalZSoftware package royal-data-ts.

1/ What I wanted to achieve

I want a workflow, where I can add the changes of the current commit to the CHANGELOG.md file.

Later any maintainer can group those changes under a specific version and release the version to:

  • GitHub tags
  • GitHub releases

  • npm

The actual release process should be bound to the CHANGELOG.md file. There should be no other easy way to release.

2/ The result

Ladies and gentlemen, that's what you've been waiting for. (At least that's what I am proud of)

In the first few seconds, the video shows the current repository state. Latest version is 0.2.2.

I append the line 2023-11-14 - 0.2.3 to the CHANGELOG.md and then I run make.

In the background make will take this written version and apply it to the package.json. Later it will also run git tag and npm publish on it.

3/ The Implementation

  1. Run npm run test and build with tsc

  2. I need to find the latest version of the CHANGELOG.md file and apply it to the package.json

    1. If the latest changelog version matches the current version, abort.
  3. Furthermore, I need to tag (git tag) the commit with the found version

  4. Then run gh release create $TAG --changelog-file CHANGELOG.md

  5. The last command is npm publish to make it visible for all users.

Full implementation

You can take a look at the actual repository at https://github.com/royalzsoftware/royal-data-ts.

I fell in love with make

GNU Make is a great tool, It's known for C/C++, but can be used for really anything. I have used it to create book PDFs and epubs.

make > npm run

It might sound weird at first, but GNU make for javascript is a ridiculously good pair too. This tool especially helps with node, since the way of defining build steps in npm is really dumb and way too simple for complex build operations, like the above mentioned.

Conclusion

Automating the version process and especially the process of keeping a clean changelog has been a hustle. With this tool, I just stole all of your excuses.

Subscribe to the RoyalZSoftware newsletter

I am putting my ❤️ into these posts and I would love to deliver those handwritten pieces directly to your inbox. Subscribe below, to never miss an article.