-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: 2 | ||
|
||
project_name: smartling-cli | ||
dist: bin | ||
|
||
release: | ||
name_template: "Version {{.Version}}" | ||
disable: true | ||
github: | ||
owner: Smartling | ||
name: smartling-cli | ||
|
||
builds: | ||
- | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
|
||
goarch: | ||
- amd64 | ||
- arm64 | ||
- arm | ||
|
||
ignore: | ||
- goos: darwin | ||
goarch: arm | ||
- goos: windows | ||
goarch: arm | ||
|
||
ldflags: | ||
- -s -w | ||
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.Version={{ .Version }} | ||
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.ReleaseTag={{ .Tag }} | ||
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.CommitID={{ .FullCommit }} | ||
- -X github.com/Smartling/smartling-cli/cmd/helpers/build.Date={{ .Date }} | ||
- -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 }} | ||
|
||
archives: | ||
- format: tar.gz | ||
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" | ||
|
||
checksum: | ||
disable: true | ||
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,9 @@ pipeline { | |
branch env.TARGET_BRANCH | ||
} | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a reason for this change. |
||
''' | ||
Comment on lines
+35
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
The previous version of this command used
|
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
MAINTAINER = Alex Koval <[email protected]> | ||
DESCRIPTION = CLI for Smartling Platform | ||
|
||
build_releaser: | ||
export SMARTLING_CLI_PLATFORM=$$(go env GOOS)/$$(go env GOARCH); \ | ||
export SMARTLING_CLI_GOVERSION=$$(go version | awk '{print $$3}'); \ | ||
goreleaser release --clean --skip=publish --snapshot | ||
|
||
all: clean get build | ||
@ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package build | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Smartling/smartling-cli/cmd/helpers/build" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewBuildCmd creates a new build command. | ||
func NewBuildCmd() *cobra.Command { | ||
buildCmd := &cobra.Command{ | ||
Use: "build", | ||
Short: "Print the build information", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
fmt.Println(build.String()) | ||
}, | ||
} | ||
return buildCmd | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package build | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// These variables will be set via ldflags at build time. | ||
var ( | ||
// CliVersion is version information | ||
CliVersion = "2.1" | ||
// ReleaseTag is the git tag | ||
ReleaseTag = "" | ||
// CommitID is the git commit hash | ||
CommitID = "" | ||
// Date is date of binary built | ||
Date = "" | ||
// BuiltBy is into about builder | ||
BuiltBy = "GoReleaser" | ||
// GoVersion is Go version | ||
GoVersion = "" | ||
// Platform is platform | ||
Platform = "" | ||
) | ||
|
||
// String returns the version information as a formatted string. | ||
func String() string { | ||
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 | ||
`, | ||
Comment on lines
+27
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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\`, |
||
CliVersion, | ||
ReleaseTag, | ||
CommitID, | ||
Date, | ||
BuiltBy, | ||
GoVersion, | ||
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
forGoVersion
andPlatform
are using environment variables set in theMakefile
. 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.