-
Notifications
You must be signed in to change notification settings - Fork 9
goreleaser and build cmd #82
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?
Conversation
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.
Summary of Changes
Hello @az-smartling, 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 significantly enhances the build and release process for the smartling-cli
by adopting GoReleaser for automated, multi-platform binary generation. It also introduces a new command to expose detailed build-time information directly from the CLI, improving traceability and version management.
Highlights
- Automated Build System Integration: Integrated GoReleaser to automate the build process for the
smartling-cli
, enabling multi-platform binary generation (Linux, Darwin, Windows for amd64, arm64, arm). - Dynamic Build Information: Implemented a mechanism to embed detailed build information (version, release tag, Git commit, build date, Go version, platform) directly into the compiled binary using GoReleaser's
ldflags
. - New
build
Command: Introduced a newsmartling-cli build
command that, when executed, displays the embedded build information, providing transparency about the CLI's origin and version. - Version Management Update: Updated the root Cobra command to dynamically retrieve its version from the embedded build information, replacing the previously hardcoded version string.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
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 GoReleaser for building binaries and adds a build
command to display version information. The changes are a good step towards standardizing the build process.
My review has identified a critical issue in the Jenkinsfile
that will likely break the S3 upload stage. I've also highlighted a high-severity security concern regarding disabled checksums in the GoReleaser configuration. Additionally, I've provided a couple of medium-severity suggestions to improve the GoReleaser configuration's maintainability and the output formatting of the new build
command.
Please address these points to ensure the changes are robust and follow best practices.
sh ''' | ||
aws-profile connectors-staging aws s3 cp ${WORKSPACE}/bin s3://smartling-connectors-releases/cli/ --acl public-read --exclude "*" --include "*" | ||
''' |
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.
This aws s3 cp
command appears to be incorrect and will likely fail to copy any files.
- It's missing the
--recursive
flag, which is required to copy the contents of a directory (${WORKSPACE}/bin
). - The
--exclude "*" --include "*"
flags are ineffective without--recursive
and are likely not what's intended. If the goal is to copy all files from the directory, these flags should be removed.
The previous version of this command used --recursive
, which seems correct for this use case.
sh "aws-profile connectors-staging aws s3 cp ${WORKSPACE}/bin s3://smartling-connectors-releases/cli/ --recursive --acl public-read"
checksum: | ||
disable: true |
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.
Disabling checksum generation is not recommended. Checksums are crucial for verifying the integrity of the downloaded artifacts, ensuring they haven't been corrupted or tampered with. Please enable checksum generation unless there is a strong reason not to. You can remove this section to use GoReleaser's default (and recommended) behavior.
checksum:
name_template: 'checksums.txt'
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.GoVersion={{ .Env.SMARTLING_CLI_GOVERSION }} | ||
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.Platform={{ .Env.SMARTLING_CLI_PLATFORM }} |
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 ldflags
for GoVersion
and Platform
are using environment variables set in the Makefile
. GoReleaser provides built-in template variables for these, which would make this configuration more self-contained and less dependent on the calling environment. Using GoReleaser's variables is a best practice and improves maintainability.
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.GoVersion={{ .GoVersion }}
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.Platform={{ .Os }}/{{ .Arch }}
return fmt.Sprintf(` | ||
Smartling-cli is a library and CLI tool for managing Smartling projects. | ||
Version: %s | ||
ReleaseTag: %s | ||
GitCommit: %s | ||
BuildDate: %s | ||
BuiltBy: %s | ||
GoVersion: %s | ||
Platform: %s | ||
`, |
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 multiline string for the build information starts with a newline character. When this is printed with fmt.Println
, it will result in an extra blank line at the beginning of the output, which might not be the intended formatting. Removing the leading newline from the string literal will produce cleaner output.
return fmt.Sprintf(\`Smartling-cli is a library and CLI tool for managing Smartling projects.\n\nVersion: %s\nReleaseTag: %s\nGitCommit: %s\nBuildDate: %s\nBuiltBy: %s\nGoVersion: %s\nPlatform: %s\n\`,
steps { | ||
sh "aws-profile connectors-staging aws s3 cp ${WORKSPACE}/bin s3://smartling-connectors-releases/cli/ --recursive --acl public-read" | ||
sh ''' | ||
aws-profile connectors-staging aws s3 cp ${WORKSPACE}/bin s3://smartling-connectors-releases/cli/ --acl public-read --exclude "*" --include "*" |
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.
I don't see a reason for this change.
Also, don't forget that jenkins does build in a clean env - docker.
goreleaser for builds
build cmd. Example