Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Fix versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Sep 23, 2023
1 parent b43c6ef commit 60833f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project_name: gnopls
builds:
- main: .
ldflags:
- -s -w -X github.com/harry-hov/gnopls/version.Version={{.Tag}}
- -s -w -X github.com/harry-hov/gnopls/internal/version.Version={{.Tag}}
goos:
- linux
- darwin
Expand Down
12 changes: 7 additions & 5 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package version

import (
"context"
"strings"

"github.com/google/go-github/github"
)

const versionUnknown = "v0.0.0-unknown"
const versionLocal = "local"

var Version string = versionUnknown
var Version = versionLocal

func getLatestReleaseTag(ctx context.Context) (string, error) {
latest, _, err := github.
Expand All @@ -27,7 +28,7 @@ func getLatestReleaseTag(ctx context.Context) (string, error) {
}

func GetVersion(ctx context.Context) string {
if Version != versionUnknown {
if Version != versionLocal {
return Version
}

Expand All @@ -36,8 +37,9 @@ func GetVersion(ctx context.Context) string {
return Version
}

if Version == versionUnknown {
return versionUnknown
if Version == versionLocal {
parts := strings.Split(tag, "-")
return parts[0] + "-" + versionLocal
}

return tag
Expand Down

0 comments on commit 60833f9

Please sign in to comment.