-
Notifications
You must be signed in to change notification settings - Fork 123
Makefile: add release-tag target with SemVer validation
#1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Makefile: add release-tag target with SemVer validation
#1052
Conversation
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.
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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.
| 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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a
release-tagtarget to the Makefile, mirroring the approach used in taproot-assets. This target creates a signed Git tag derived fromversion.go, and validates that it conforms to Semantic Versioning. This prevents tagging with an invalid or non-compliant version.