Skip to content

Instantly share code, notes, and snippets.

@JanMalch
Last active November 7, 2025 11:47
Show Gist options
  • Select an option

  • Save JanMalch/4001855cdf78a691a10fbb7169a6d7aa to your computer and use it in GitHub Desktop.

Select an option

Save JanMalch/4001855cdf78a691a10fbb7169a6d7aa to your computer and use it in GitHub Desktop.
GoLang function to check for a new GitHub release and show a banner if so
package main
import (
"context"
"fmt"
"github.com/charmbracelet/lipgloss"
"github.com/google/go-github/v77/github"
)
const VERSION = "0.1.0"
func checkForUpdate() error {
client := github.NewClient(nil)
ctx := context.Background()
release, _, err := client.Repositories.GetLatestRelease(ctx, "JanMalch", "roar")
if err != nil {
return err
}
latestTag := "v" + VERSION
if latestTag == release.GetTagName() {
return nil
}
url := release.GetHTMLURL()
style := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
Padding(0, 1).
Align(lipgloss.Left)
fmt.Println(style.Render(
lipgloss.JoinVertical(
lipgloss.Left,
lipgloss.NewStyle().Inline(true).Bold(true).Render("A new roar version is available!\n"),
fmt.Sprintf("%s -> %s", latestTag, release.GetTagName()),
lipgloss.NewStyle().Inline(true).Foreground(lipgloss.Color("12")).Render(url),
),
))
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment