Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: 2

project_name: smartling-cli
dist: bin

release:
name_template: "Version {{.Version}}"
disable: true
github:
owner: Smartling
name: smartling-cli

builds:
-
binary: smartling-cli

goos:
- linux
- darwin
- windows

goarch:
- amd64
- arm64
- arm

ignore:
- goos: darwin
goarch: arm
- goos: windows
goarch: arm

flags:
- -trimpath

ldflags:
- -s -w
- -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 }}
Comment thread
az-smartling marked this conversation as resolved.
Outdated

archives:
- formats: [binary]
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

checksum:
disable: true
Comment thread
az-smartling marked this conversation as resolved.
Outdated
8 changes: 5 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pipeline {
stages {
stage('Build') {
steps {
sh "docker pull golang"
sh "docker run -t --rm -v ${WORKSPACE}:/go/src/cli -w /go/src/cli golang make"
sh "docker pull goreleaser/goreleaser:v2.15.4"
sh "docker run -t --rm -v ${WORKSPACE}:/go/src/cli -w /go/src/cli goreleaser/goreleaser:v2.15.4 make build_releaser"
}
}

Expand All @@ -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 "smartling-cli*" --recursive
'''
Comment thread
az-smartling marked this conversation as resolved.
}
}

Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ DESCRIPTION = CLI for Smartling Platform
LDFLAGS ?= -s -w
GO_BUILD_FLAGS ?= -mod=mod -trimpath -ldflags="$(LDFLAGS)"

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

.PHONY: all
all: clean get build
@
Expand All @@ -25,10 +30,12 @@ _PKG = pkg/build

_CONTROL = echo >> $(_PKG)/DEBIAN/control

_LINUX_AMD64_BIN = $(shell ls bin/*linux_amd64*/smartling-cli 2>/dev/null | head -1)

.PHONY: deb
deb: _pkg-init
mkdir -p $(_PKG)/usr/bin
cp bin/smartling.linux $(_PKG)/usr/bin/smartling
cp $(_LINUX_AMD64_BIN) $(_PKG)/usr/bin/smartling
mkdir -p $(_PKG)/DEBIAN
$(_CONTROL) "Package: smartling"
$(_CONTROL) "Version: $(VERSION)"
Expand All @@ -53,7 +60,7 @@ rpm: _pkg-init
$(_SPEC) "%description"
$(_SPEC) "%install"
$(_SPEC) "mkdir -p %{buildroot}/%{_bindir}"
$(_SPEC) "cp $(PWD)/bin/smartling.linux %{buildroot}/%{_bindir}/smartling"
$(_SPEC) "cp $(PWD)/$(_LINUX_AMD64_BIN) %{buildroot}/%{_bindir}/smartling"
$(_SPEC) "%files"
$(_SPEC) "%{_bindir}/smartling"
$(_SPEC) "%define _rpmdir $(_PKG)"
Expand Down
21 changes: 21 additions & 0 deletions cmd/build/build.go
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
}
4 changes: 3 additions & 1 deletion cmd/cmd_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"strings"

"github.com/Smartling/smartling-cli/cmd/helpers/build"

"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -30,7 +32,7 @@ func NewRootCmd() *cobra.Command {
rootCmd := &cobra.Command{
Use: "smartling-cli",
Short: "Manage translation files using Smartling CLI.",
Version: "3.2",
Version: build.CliVersion,
Long: `Manage translation files using Smartling CLI.
Complete documentation is available at https://www.smartling.com`,
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
Expand Down
42 changes: 42 additions & 0 deletions cmd/helpers/build/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package build

import (
"fmt"
)

// These variables will be set via ldflags at build time.
var (
// CliVersion is version information
CliVersion = "3.2"
// 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
GitCommit: %s
BuildDate: %s
BuiltBy: %s
GoVersion: %s
Platform: %s
`,
Comment thread
az-smartling marked this conversation as resolved.
CliVersion,
CommitID,
Date,
BuiltBy,
GoVersion,
Platform,
)
}
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"github.com/Smartling/smartling-cli/cmd"
"github.com/Smartling/smartling-cli/cmd/build"
"github.com/Smartling/smartling-cli/cmd/docs"
"github.com/Smartling/smartling-cli/cmd/files"
deletecmd "github.com/Smartling/smartling-cli/cmd/files/delete"
Expand Down Expand Up @@ -32,6 +33,9 @@ func main() {
docsCmd := docs.NewDocsCmd()
rootCmd.AddCommand(docsCmd)

buildCmd := build.NewBuildCmd()
rootCmd.AddCommand(buildCmd)

initSrvInitializer := initialize.NewSrvInitializer()
initCmd := initialize.NewInitCmd(initSrvInitializer)
rootCmd.AddCommand(initCmd)
Expand Down