Skip to content

Conversation

@ffranr
Copy link
Contributor

@ffranr ffranr commented Nov 27, 2025

Add a release-tag target to the Makefile, mirroring the approach used in taproot-assets. This target creates a signed Git tag derived from version.go, and validates that it conforms to Semantic Versioning. This prevents tagging with an invalid or non-compliant version.

Add a `release-tag` target to the Makefile, mirroring the approach used
in taproot-assets. This target creates a signed Git tag derived from
`version.go`, and validates that it conforms to Semantic Versioning.
This prevents tagging with an invalid or non-compliant version.
@gemini-code-assist
Copy link

Summary of Changes

Hello @ffranr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the release process by introducing a new release-tag target in the Makefile. This target automates the generation of signed Git tags directly from the project's version.go file. A key feature is the integrated Semantic Versioning validation, which ensures that all generated tags adhere to established versioning standards, thereby preventing the creation of invalid or non-compliant release tags and promoting consistency in release management.

Highlights

  • New release-tag Makefile Target: A new release-tag target has been added to the Makefile to automate the creation of signed Git tags for releases.
  • Automated Version Extraction: The new target automatically derives the tag name by extracting version components (major, minor, patch, pre-release) from the version.go file.
  • Semantic Versioning (SemVer) Validation: The derived tag name is rigorously validated against Semantic Versioning rules, ensuring that only compliant tags can be created, preventing accidental or incorrect releases.
  • New Helper Script: A new bash script, scripts/get-git-tag-name.sh, was introduced to handle the logic of parsing the version.go file and performing the SemVer validation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a release-tag target in the Makefile to automate the creation of signed Git tags based on the version specified in version.go. This is a valuable addition for release management. My review includes suggestions to enhance the robustness and maintainability of the new Makefile target and its associated shell script. Specifically, I've pointed out ways to improve error handling, make the script more resilient, and align with common conventions.

Comment on lines +98 to +104
tag=$$(./scripts/get-git-tag-name.sh ${VERSION_GO_FILE}); \
exit_status=$$?; \
if [ $$exit_status -ne 0 ]; then \
echo "Script encountered an error with exit status $$exit_status."; \
fi; \
echo "Adding git tag: $$tag"; \
git tag -as -m "Tag generated using command \`make release-tag\`." "$$tag";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The error handling in this recipe can be simplified and made more robust. The current implementation checks the exit status of the script but doesn't stop execution on failure. This leads to subsequent commands like git tag being run with an empty tag, causing a confusing failure message.

By using set -e, the recipe will exit immediately if any command fails, which is the desired behavior here. The get-git-tag-name.sh script already prints descriptive error messages to stderr, so no extra error handling is needed in the Makefile.

	set -e; \
	tag=$$(./scripts/get-git-tag-name.sh ${VERSION_GO_FILE}); \
	echo "Adding git tag: $$tag"; \
	git tag -as -m "Tag generated using command \`make release-tag\`." "$$tag"

app_patch=$(grep -oP 'appPatch\s*uint\s*=\s*\K\d+' "$file_path")

local app_pre_release
app_pre_release=$(grep -oP 'appPreRelease\s*=\s*"\K([A-Za-z0-9.-]*)' "$file_path")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The script will fail if appPreRelease is not defined in the version file because grep will exit with a non-zero status, and set -e is active. Since a pre-release version is optional for a release, it's better to handle its absence gracefully. You can append || true to the grep command to ensure the script doesn't exit if appPreRelease is not found. In that case, $app_pre_release will be empty, which is handled correctly later in the script.

Suggested change
app_pre_release=$(grep -oP 'appPreRelease\s*=\s*"\K([A-Za-z0-9.-]*)' "$file_path")
app_pre_release=$(grep -oP 'appPreRelease\s*=\s*"\K([A-Za-z0-9.-]*)' "$file_path" || true)


GO_BIN := ${GOPATH}/bin
GOIMPORTS_BIN := $(GO_BIN)/gosimports
VERSION_GO_FILE := "version.go"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with standard Makefile practices, it's better to define VERSION_GO_FILE without quotes. The quotes are not necessary here as the value doesn't contain spaces or special characters. The variable will be correctly expanded by make in the release-tag target without them.

VERSION_GO_FILE := version.go

echo "$tag_name"
}

file_path="$1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's good practice to validate the number of script arguments. This provides a clearer error message to the user if the script is called incorrectly, improving its usability.

Suggested change
file_path="$1"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path-to-version-file>" >&2
exit 1
fi
file_path="$1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant