diff --git a/cmd/dbc/latest.go b/cmd/dbc/latest.go new file mode 100644 index 0000000..11f4d63 --- /dev/null +++ b/cmd/dbc/latest.go @@ -0,0 +1,34 @@ +// Copyright 2026 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !no_notify_latest + +package main + +import ( + "fmt" + + "github.com/Masterminds/semver/v3" + "github.com/columnar-tech/dbc" +) + +func notifyLatest() { + latestVer, err := dbc.GetLatestDbcVersion() + if dbc.Version != "(devel)" && err == nil { + if semver.MustParse(dbc.Version).LessThan(latestVer) { + fmt.Printf(descStyle.Render("dbc version %s is available! You are using version %s. Please upgrade.\n\n"), + latestVer, dbc.Version) + } + } +} diff --git a/cmd/dbc/latest_ignore.go b/cmd/dbc/latest_ignore.go new file mode 100644 index 0000000..7f1c63b --- /dev/null +++ b/cmd/dbc/latest_ignore.go @@ -0,0 +1,19 @@ +// Copyright 2026 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build no_notify_latest + +package main + +func notifyLatest() {} diff --git a/cmd/dbc/main.go b/cmd/dbc/main.go index 27830d6..468cd26 100644 --- a/cmd/dbc/main.go +++ b/cmd/dbc/main.go @@ -268,6 +268,10 @@ func main() { prog = tea.NewProgram(m) } + if !args.Quiet { + notifyLatest() + } + if m, err = prog.Run(); err != nil { fmt.Fprintln(os.Stderr, "Error running program:", err) os.Exit(1) diff --git a/drivers.go b/drivers.go index 231e055..44ca0ba 100644 --- a/drivers.go +++ b/drivers.go @@ -527,3 +527,17 @@ func SignedByColumnar(lib, sig io.Reader) error { return result.SignatureError() } + +func GetLatestDbcVersion() (*semver.Version, error) { + resp, err := makereq("https://dbc.columnar.tech") + if err != nil { + return nil, fmt.Errorf("failed to fetch latest dbc version: %w", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusNoContent { + return nil, fmt.Errorf("failed to fetch latest dbc version: %s", resp.Status) + } + + return semver.NewVersion(resp.Header.Get("x-dbc-latest")) +}