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 bb4d497 commit 629451a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 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/sbomex"

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
14 changes: 13 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"path/filepath"

"github.com/Masterminds/semver/v3"
_ "github.com/glebarez/go-sqlite"
"github.com/google/go-github/v52/github"
"github.com/interlynk-io/sbomex/pkg/model"
Expand Down Expand Up @@ -132,7 +133,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 sbomex is available %s.\n\n", rr.GetTagName())
}
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
)

require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
Expand Down

0 comments on commit 629451a

Please sign in to comment.