Have you ever found yourself in a situation where you need to search through multiple files in your project, find a specific pattern, and then apply a transformation to it? It can be a tedious task, but fear not! In this blog post, I’ll walk you through a GenAIScript that does just that, automating the process and saving you time. 🕒💡
For example, when GenAIScript added the ability to use a string command string in
the exec command, we needed to convert all script using
Bringing a new version of a product into the world is always exciting! But alongside the thrill comes the duty of informing users about what’s changed. That’s where generating crisp, engaging release notes comes into play. ✨
Today, we’re going to explore a script that automates the creation of release notes for GenAI. The script is part of the GenAIScript ecosystem, which harnesses the power of AI to bring efficiency to software development processes. 🚀
If you want to dive straight into the script, it’s available on GitHub right here.
The script is a .genai.mjs file, meaning it’s a JavaScript file designed to be run with the GenAIScript CLI. The code within orchestrates the creation of release notes by leveraging Git commands and GenAI’s capabilities.
Let’s walk through the script, step by step:
Step 1: Initializing the Script
The script starts by initializing with a script function. We’re setting it up to access system commands and specifying the AI model to use. The temperature controls the creativity of the AI, with 0.5 being a balanced choice.
Step 2: Setting the Product Name
Here, we’re using an environment variable to set the product name, defaulting to “GenAIScript” if it’s not provided.
Step 3: Finding the Previous Tag
We are reading the current version from package.json and using Git to find the previous release tag in the repository.
Step 4: Gathering Commits
This block runs a Git command to retrieve the list of commits that will be included in the release notes, excluding any with ‘skip ci’ in the message.
Step 5: Obtaining the Diff
Next, we get the diff of changes since the last release, excluding certain files and directories that aren’t relevant to the user-facing release notes.
Step 6: Defining Placeholders
We define two placeholders, COMMITS and DIFF, which will be used to reference the commits and diff within the prompt.
Step 7: Writing the Prompt
Finally, the script ends with a prompt that instructs GenAI to generate the release notes. It details the task, guidelines for what to include, and the style to adhere to.
How to Run the Script with Genaiscript CLI
Once you’ve crafted your script, running it is a breeze with the Genaiscript CLI. If you haven’t installed the CLI yet, you can find the instructions here.
To execute the script, navigate to your project’s root directory in the terminal and run:
Remember, we use the script filename without the .genai.mjs extension when invoking it with the CLI.
And that’s it! The GenAIScript CLI will take care of the rest, combining the power of AI with your code to generate those sleek release notes for your project’s next big launch. 🌟