Skip to content

Commit

Permalink
[NO-TKT] Version for containerized app
Browse files Browse the repository at this point in the history
  • Loading branch information
surendrapathak committed Jul 13, 2023
1 parent 3e1406e commit e91ff31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.20-alpine AS builder
LABEL org.opencontainers.image.source="https://github.com/interlynk-io/sbomasm"

RUN apk add --no-cache make
RUN apk add --no-cache make git
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
Expand Down
16 changes: 14 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"os"

"github.com/Masterminds/semver/v3"
"github.com/google/go-github/v52/github"
"github.com/spf13/cobra"
version "sigs.k8s.io/release-utils/version"
Expand All @@ -26,7 +27,7 @@ import (
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "sbomasm",
Short: "sbomasm is your primary tool to assemble SBOMs, for easy management and distribution.",
Short: "sbomasm is your primary tool to assemble SBOMs, for easy management and distribution.",
Long: `sbomasm is your primary tool to assemble SBOMs, for easy management and distribution. The tool
can process both spdx and cyclonedx input sboms, it autotects the file formats for input sboms. The tool
can output both spdx and cyclonedx sboms. Multiple algorithms are supported for assembling component sboms
Expand Down Expand Up @@ -74,7 +75,18 @@ func checkIfLatestRelease() {
return
}

if rr.GetTagName() != version.GetVersionInfo().GitVersion {
verLatest, err := semver.NewVersion(version.GetVersionInfo().GitVersion)
if err != nil {
return
}

verInstalled, err := semver.NewVersion(rr.GetTagName())
if err != nil {
return
}

result := verInstalled.Compare(verLatest)
if result < 0 {
fmt.Printf("\nA new version of sbomasm is available %s.\n\n", rr.GetTagName())
}
}

0 comments on commit e91ff31

Please sign in to comment.