Skip to content

Commit

Permalink
update version string to 0.6.0 (#325)
Browse files Browse the repository at this point in the history
* update version string to 0.6.0

Also:

 - Set the full version string to 0.6.0-rc.1, specifying prerelease.
   The release should have the format 0.6.0+release.
 - Add logic to the init function in the internal/pkg/version package
   so that it will use any compile-time set KwilVersion without
   decorating it with VCS info to prevent it from looking like kwild
   version 0.6.0-rc.1+d74a0af8d.dirty. This is desirable for local
   and/or dev builds, but we want the binaries we ship to just say
   kwild version 0.6.0+release or kwil-cli version 0.6.0-rc.1 etc.

* kwil-cli: update to use internal/pkg/version

This updates kwil-cli to use the new internal/pkg/version, which uses
the version controls system info available in the runtime/debug standard
library package.

* build all three binaries

* 0.6.0-beta
  • Loading branch information
jchappelow authored and brennanjl committed Feb 26, 2024
1 parent b18abf2 commit 55cb29f
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 48 deletions.
73 changes: 53 additions & 20 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
project_name: kwil-cli
before:
hooks:
- go mod tidy
project_name: kwil-db

changelog:
skip: true
Expand All @@ -15,10 +12,9 @@ changelog:
builds:
- id: kwil-cli
binary: kwil-cli
main: ./cmd/kwil-cli/main.go
main: ./cmd/kwil-cli
goos:
- linux
- windows
- darwin
goarch:
- amd64
Expand All @@ -27,23 +23,58 @@ builds:
- 6
- 7
ignore:
- goos: windows
goarch: arm64
ldflags:
- -s -w
- -X 'kwil/internal/pkg/build.Version={{.Version}}'
- -X 'kwil/internal/pkg/build.GitCommit={{.Commit}}'
- -X 'kwil/internal/pkg/build.BuildTime={{.Date}}'
- -X 'github.com/kwilteam/kwil-db/internal/pkg/version.KwilVersion={{ index .Env "KWIL_VERSION" }}'
tags:
- osusergo
- netgo
env:
- CGO_ENABLED=0

- id: kwild
binary: kwild
main: ./cmd/kwild
goos:
- linux
- darwin
goarch:
- amd64
- arm64
goarm:
- 6
- 7
ignore:
ldflags:
- -s -w
- -X 'github.com/kwilteam/kwil-db/internal/pkg/version.KwilVersion={{ index .Env "KWIL_VERSION" }}'
tags:
- osusergo
- netgo
env:
- CGO_ENABLED=0

- id: kwil-admin
binary: kwil-admin
main: ./cmd/kwil-admin
goos:
- linux
- darwin
goarch:
- amd64
- arm64
goarm:
- 6
- 7
ignore:
ldflags:
- -s -w
- -X 'github.com/kwilteam/kwil-db/internal/pkg/version.KwilVersion={{ index .Env "KWIL_VERSION" }}'
tags:
- osusergo
- netgo
env:
- CGO_ENABLED=0
- CC_darwin_amd64=o64-clang
- CCX_darwin_amd64=o64-clang+
- CC_darwin_arm64=aarch64-apple-darwin20.2-clang
- CCX_darwin_arm64=aarch64-apple-darwin20.2-clang++
- CC_windows_amd64=x86_64-w64-mingw32-gc
- CCX_windows_amd64=x86_64-w64-mingw32-g++
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
- 'CCX={{ index .Env (print "CCX_" .Os "_" .Arch) }}'

checksum:
name_template: 'checksums.txt'
Expand All @@ -56,6 +87,8 @@ release:
replace_existing_draft: true
ids:
- kwil-cli
- kwild
- kwil-admin

universal_binaries:
- replace: true
- replace: true
13 changes: 7 additions & 6 deletions cmd/kwil-cli/cmds/system/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ import (
"bytes"
"encoding/json"
"fmt"
"html/template"
"io"
"runtime"
"text/template"
"time"

"github.com/kwilteam/kwil-db/cmd/internal/display"
"github.com/kwilteam/kwil-db/cmd/kwil-cli/config"
"github.com/kwilteam/kwil-db/internal/pkg/build"
"github.com/kwilteam/kwil-db/internal/pkg/version"
"github.com/spf13/cobra"
"github.com/tonistiigi/go-rosetta"
)

var versionTemplate = `
Version: {{.Version}}
Git commit: {{.GitCommit}}
Built: {{.BuildTime}}
Built: {{.BuildTime}}
API version: {{.APIVersion}}
Go version: {{.GoVersion}}
OS/Arch: {{.Os}}/{{.Arch}}`
Expand Down Expand Up @@ -74,13 +75,13 @@ func NewVersionCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
resp := &respVersionInfo{
Info: &versionInfo{
Version: build.Version,
Version: version.KwilVersion,
APIVersion: "",
GitCommit: build.GitCommit,
GitCommit: version.Build.Revision,
GoVersion: runtime.Version(),
Os: runtime.GOOS,
Arch: arch(),
BuildTime: build.BuildTime,
BuildTime: version.Build.RevTime.Format(time.RFC3339),
},
}

Expand Down
9 changes: 0 additions & 9 deletions internal/pkg/build/build.go

This file was deleted.

47 changes: 34 additions & 13 deletions internal/pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,59 @@ package version
import (
"fmt"
"runtime/debug"
"strings"
"time"
)

// The kwilVersion should adhere to the semantic versioning (SemVer) spec 2.0.0.
// The general format is MAJOR.MINOR.PATCH-PRERELEASE+BUILD_META where both the
// prerelease label and build metadata are optional. For example:
//
// - 0.6.0-rc.1
// - 0.6.0+release
// - 0.6.1
// - 0.6.2-alpha0+go1.21.nocgo
const kwilVersion = "0.6.0-beta" // precursor to 0.6.0+release

// KwildVersion may be set at compile time by:
//
// go build -ldflags "-s -w -X github.com/kwilteam/kwil-db/internal/pkg/version.KwilVersion=0.6.0+release"
var (
KwilVersion = "0.5.1-pre" // precursor to 0.5.1+release
KwilVersion string
Build = vcsInfo()
)

func init() {
if Build != nil {
KwilVersion += "+" + Build.Revision
if Build.Dirty {
KwilVersion += ".dirty"
if KwilVersion == "" { // not set via ldflags
KwilVersion = kwilVersion
if Build != nil {
// Append VCS revision and workspace dirty flag.
sep := "+" // start build metadata
if strings.Contains(KwilVersion, "+") {
sep = "." // append to existing build metadata
}
KwilVersion += sep + Build.RevisionShort
if Build.Dirty {
KwilVersion += ".dirty"
}
}
}
}

type BuildInfo struct {
GoVersion string
Revision string
RevTime time.Time
Dirty bool
GoVersion string
Revision string
RevisionShort string
RevTime time.Time
Dirty bool
}

func vcsInfo() *BuildInfo {
bi, ok := debug.ReadBuildInfo()
if !ok {
return nil
}
buildInfo := new(BuildInfo)
buildInfo := &BuildInfo{GoVersion: bi.GoVersion}
for _, bs := range bi.Settings {
switch bs.Key {
case "vcs.revision":
Expand All @@ -49,8 +72,6 @@ func vcsInfo() *BuildInfo {
}
}
const revLen = 9
if len(buildInfo.Revision) > revLen {
buildInfo.Revision = buildInfo.Revision[:revLen]
}
buildInfo.RevisionShort = buildInfo.Revision[:min(revLen, len(buildInfo.Revision))]
return buildInfo
}

0 comments on commit 55cb29f

Please sign in to comment.