Gitlab - ReleaseNotes generator
As time goes by we realize that there are too many tasks that we perform manually over and over again, and we do not realize that this can be automated to simplify our tasks and save time, or there are simply people who are afraid to automate (yes, they still exist); but that is what technology is for, to innovate and make our daily tasks simpler.
In most of the companies I have worked for we have used Github as a repository and the truth is that I am surprised how developed it is, but now I have been working on projects where they are hosted in Gitlab and I am excited to develop add-ons that I can’t find for Gitlab, so I took this repository as inspiration to move it to Gitlab and automate my tasks.
So, let’s get to work!
These are the tools I used to create this little project:
- Node.js
- node-fetch: allows us to perform HTTP queries in JS.
- Gitlab REST Api
And this is the result:
Recommendations
First of all, we must take into account the following points in each of our MRs:
- The title of our MRs must be descriptive but short, since this will be the main point for the Notes to be generated.
- (Optional) The titles of the MRs could contain the following format to link the ReleaseNotes to our Project Manager such as Jira:
[TASK-ID]: <Short descriptive title>
- The MRs must be assigned to the creator of the MR.
- You should always have Reviewers assigned to the MRs.
How it works ⚙️
The operation is basic, you get a list of MergeRequests that have been integrated in the Target branch in a date range:
- Initial date: obtained from the last Tag created. Yes, you should use release tags.
- End date: current date.
That’s it, simple as that.
In this diagram we can see that the MRs we will obtain are feature2 and feature3, since they are the ones between our last release (v1.0.0) and the current date of the Code freeze.
How to configure the project
Once the project has been cloned, the only thing you will have to do is to create an .env file where you will integrate some configuration variables so that the project can work:
There, that’s all we need to configure in our project.
Now, we will run the following commands in the Terminal that will allow us to initialize the project.
- Only run it the first time:
// Install the Node.js and others packages
> npm install
- Generate ReleaseNotes 🗒 :
> npm start
The last command will output a text with the ReleaseNotes as follows:
### [<MERGE_REQUEST_TITLE>](<TASK_URL>)
MergeRequest: <MERGE_REQUEST_URL>
Author: <MERGE_REQUEST_AUTHOR>
Reviewer: <MERGE_REQUEST_REVIEWER>
...
Reviewer: <MERGE_REQUEST_REVIEWER>
Next steps
Just that 😆 create a Step for Bitrise to automate the release process.
coming soon… 👊