Skip to content

Commit

Permalink
adds "version" command to print build-time embedded git version tag i…
Browse files Browse the repository at this point in the history
…nto console
  • Loading branch information
ufukty committed May 3, 2024
1 parent 289aedd commit b2f9719
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
VERSION := $(shell git describe --tags --always --dirty)
LDFLAGS := -ldflags "-X 'main.Version=$(VERSION)'"

.PHONY: build

build:
mkdir -p build/$(VERSION)
GOOS=darwin GOARCH=amd64 go build -o build/$(VERSION)/ovpn-auth-darwin-x64 ./cmd/ovpn-auth
GOOS=darwin GOARCH=arm64 go build -o build/$(VERSION)/ovpn-auth-darwin-arm ./cmd/ovpn-auth
GOOS=linux GOARCH=amd64 go build -o build/$(VERSION)/ovpn-auth-linux-x64 ./cmd/ovpn-auth
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o build/$(VERSION)/ovpn-auth-darwin-x64 ./cmd/ovpn-auth
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o build/$(VERSION)/ovpn-auth-darwin-arm ./cmd/ovpn-auth
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o build/$(VERSION)/ovpn-auth-linux-x64 ./cmd/ovpn-auth
4 changes: 4 additions & 0 deletions cmd/ovpn-auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/ufukty/ovpn-auth/internal/register"
)

var Version = ""

func dispatch() error {
if len(os.Args) < 2 {
return fmt.Errorf("not enough argument")
Expand All @@ -31,6 +33,8 @@ func dispatch() error {
if err := register.WithInteraction(); err != nil {
return fmt.Errorf("performing registration interaction: %w", err)
}
case "version":
fmt.Println(Version)
default:
if err := login.WithFile(arg); err != nil {
return fmt.Errorf("checking login: %w", err)
Expand Down

0 comments on commit b2f9719

Please sign in to comment.