Skip to content
Open
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
34 changes: 34 additions & 0 deletions cmd/dbc/latest.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
19 changes: 19 additions & 0 deletions cmd/dbc/latest_ignore.go
Original file line number Diff line number Diff line change
@@ -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() {}
4 changes: 4 additions & 0 deletions cmd/dbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Loading