Changelogs are awesome.
While we've become pretty dependent on them in our app stores to tell us what's new and fixed, it can be difficult to manage them in both private and open source projects. Thanks to projects like the GitHub Changelog Generator and Keep a Changelog, automatically building a standards-based changelog based on closed tickets and merged branches is easier than ever, but it still requires a bit of a manual touch. To better automate this in my own projects, I decided to go looking in the Wercker Steps Marketplace for a solution.
Lucky for me, I found one.
The generate-changelog step, by Wercker user dlanileonardo, takes the GitHub Changelog Generator project and wraps it in a Wercker step. This allows us to automatically generate an up-to-date changelog during every build process without any manual intervention. To illustrate how to integrate this step into a Wercker build process, I went ahead and spun up a (really) simple hello world application (which you can find here on GitHub). I should note that, before I go through how to add this step to your Wercker build process, I'm going to make the bold assumption that your own project already has a wercker.yml file set up.
With your wercker.yml file in hand, the first step we must take is to generate a new personal access token on GitHub. This token is crucial for the generate-changelog step to commit changelog updates directly to your project's GitHub repository.
Next, it's time to open up your wercker.yml file and actually add the generate-changelog step. In addition to your new token, you'll also need to include your GitHub username, the name of the repository on GitHub, the name and email to associate with the commit, and the branch to commit generated changelogs to.
Keep in mind that, because generate-changelog uses the GitHub Changelog Generator gem mentioned above, you will also need to have Ruby installed within your Wercker container. For the purposes of this demo, I simply used Wercker's Ruby base box, but for other boxes you will also have to install and configure Ruby manually.
It is important to note that the branch name is validated against the current build branch, which means that if you set the github_branch to master, than changelogs will only be generated and committed during builds for the master branch. Also, it is considered best practice to keep sensitive information out of your repositories, which means that the $CHANGELOG_GITHUB_ variables above are defined within the environment config of your Wercker application settings, like so:
After everything is configured and you make your first push, this new step in your Wercker build process will automatically generate a changelog based on any changes made to your GitHub project. Any merged pull requests, pushed git tags, and closed issues will be included within this changelog. For a better idea of what this looks like, feel free to take a look at the generated changelog within this sample project.
I've said this before, but I think it's worth reiterating that I am a huge fan of the Wercker Steps Marketplace. While this is a great example of one thing that can be accomplished with a Wercker step, I highly suggest you peruse the Marketplace to find steps that can more effectively enhance your current CI/CD process. With a little bit of digging, you can find a handful of awesome steps that can be plugged right into your workflow with minimal effort, but maximum impact.
About the Author
Zachary Flower is a freelance web developer, writer, and polymath. He has an eye for simplicity and usability, and strives to build products with both the end user and business goals in mind. From building projects for the NSA to creating features for companies like Name.com and Buffer, Zach has always taken a strong stand against needlessly reinventing the wheel, often advocating for the use of well established third-party and open source services and solutions to improve the efficiency and reliability of a development project.
We’re hiring! Check out the careers page for open positions in Amsterdam, London and San Francisco.
As usual, if you want to stay in the loop follow us on twitter @wercker or hop on our public slack channel. If it’s your first time using Wercker, be sure to tweet out your #greenbuilds, and we’ll send you some swag!