diff --git a/Makefile b/Makefile index 5a47e9a..085dcbd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -.PHONY: proto build test lint clean +VERSION := $(shell git describe --tags --abbrev=0 | sed 's/^v//') + +.PHONY: proto build test lint clean version proto: protoc \ @@ -7,8 +9,11 @@ proto: -I proto \ proto/sgard/v1/sgard.proto +version: + @echo $(VERSION) > VERSION + build: - go build ./... + go build -ldflags "-X main.version=$(VERSION)" ./... test: go test ./... diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3ad0595 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +3.1.5 diff --git a/flake.nix b/flake.nix index ea25277..14c78fb 100644 --- a/flake.nix +++ b/flake.nix @@ -11,11 +11,14 @@ let pkgs = import nixpkgs { inherit system; }; in + let + version = builtins.replaceStrings [ "\n" ] [ "" ] (builtins.readFile ./VERSION); + in { packages = { sgard = pkgs.buildGoModule rec { pname = "sgard"; - version = "2.1.0"; + inherit version; src = pkgs.lib.cleanSource ./.; subPackages = [ "cmd/sgard" "cmd/sgardd" ]; @@ -31,7 +34,7 @@ sgard-fido2 = pkgs.buildGoModule rec { pname = "sgard-fido2"; - version = "2.1.0"; + inherit version; src = pkgs.lib.cleanSource ./.; subPackages = [ "cmd/sgard" "cmd/sgardd" ];