Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
38 changes: 29 additions & 9 deletions cmd/build_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
)

var (
version = "dev"
commit = "none"
version = "dev"
commit = "none"
sdkVersion = ""
)

// includes a leading newline to make it easy to read the ascii art here in the source
Expand All @@ -20,17 +21,36 @@ const versionHeader = `
`

func init() {
if info, ok := debug.ReadBuildInfo(); ok && version == "dev" {
if info.Main.Version != "" && info.Main.Version != "(devel)" {
version = strings.TrimPrefix(info.Main.Version, "v")
if info, ok := debug.ReadBuildInfo(); ok {
if version == "dev" {
if info.Main.Version != "" && info.Main.Version != "(devel)" {
version = info.Main.Version
}
for _, s := range info.Settings {
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
commit = s.Value[:7]
break
}
}
}
for _, s := range info.Settings {
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
commit = s.Value[:7]
for _, dep := range info.Deps {
if dep.Path == "github.com/loops-so/loops-go" {
sdkVersion = dep.Version
break
}
}
}
header := strings.TrimPrefix(versionHeader, "\n")
rootCmd.SetVersionTemplate(header + "\n{{with .Name}}{{printf \"%s \" .}}{{end}}{{printf \"version %s\" .Version}}\n")
parts := []string{}
if commit != "" && commit != "none" {
parts = append(parts, "git "+commit)
}
if sdkVersion != "" {
parts = append(parts, "sdk "+sdkVersion)
}
suffix := ""
if len(parts) > 0 {
suffix = " (" + strings.Join(parts, ", ") + ")"
}
rootCmd.SetVersionTemplate(header + "\n{{with .Name}}{{printf \"%s \" .}}{{end}}{{printf \"version %s\" .Version}}" + suffix + "\n")
}
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func Execute() {
context.Background(),
rootCmd,
fang.WithVersion(version),
fang.WithCommit(commit),
fang.WithErrorHandler(jsonAwareErrorHandler),
)

Expand Down
6 changes: 5 additions & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $checksumsName = "${ProjName}_${versionNoV}_checksums.txt"
$downloadUrl = "$GHAssetsUrl/$release/$archiveName"
$checksumsUrl = "$GHAssetsUrl/$release/$checksumsName"

Write-Host "Installing $ProjName $release for windows/$Arch..."
Write-Host "Installing $ProjName $release for windows/$Arch... " -NoNewline

$tmpDir = Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tmpDir | Out-Null
Expand Down Expand Up @@ -80,4 +80,8 @@ try {
}

Write-Host "Done!"
Write-Host "✓ " -ForegroundColor Green -NoNewline
Write-Host "Installed to $InstallDir\$BinName"
& "$InstallDir\$BinName" --version
Write-Host ""
Write-Host 'Try `loops --help` to get started.' -ForegroundColor DarkGray
7 changes: 5 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ execute() {
rm -rf "$TMPDIR"
}

echo "Installing ${PROJ_NAME} $GH_RELEASE for $OS $ARCH... "
printf "Installing %s %s for %s %s... " "$PROJ_NAME" "$GH_RELEASE" "$OS" "$ARCH"
execute
echo "Done!"
echo "Installed to ${INSTALL_DIR}/${SHORT_BIN_NAME}"
printf '\033[32m✓\033[0m Installed to %s\n' "${INSTALL_DIR}/${SHORT_BIN_NAME}"
"${INSTALL_DIR}/${SHORT_BIN_NAME}" --version
echo ""
printf '\033[2mTry `%s --help` to get started.\033[0m\n' "$SHORT_BIN_NAME"