diff --git a/Makefile b/Makefile index 9e351cb..88af2f7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ build: mkdir -p functions go get ./... - go build -o functions/phoneserver ./cmd/phoneserver + go build -ldflags "-X main.Version=`git describe --tags`" -o functions/phoneserver ./cmd/phoneserver diff --git a/cmd/phoneserver/main.go b/cmd/phoneserver/main.go index 44e85fd..2af237e 100644 --- a/cmd/phoneserver/main.go +++ b/cmd/phoneserver/main.go @@ -3,14 +3,13 @@ package main import ( "encoding/json" "net/http" - "os" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" "github.com/nyaruka/phonenumbers" ) -var version = "dev" +var Version = "dev" type errorResponse struct { Message string `json:"message"` @@ -66,16 +65,10 @@ func parse(request events.APIGatewayProxyRequest) (events.APIGatewayProxyRespons IsValid: phonenumbers.IsValidNumber(metadata), NationalFormatted: phonenumbers.Format(metadata, phonenumbers.NATIONAL), InternationalFormatted: phonenumbers.Format(metadata, phonenumbers.INTERNATIONAL), - Version: version, + Version: Version, }) } func main() { - // use commit ref as our version if set - commit := os.Getenv("COMMIT_REF") - if commit != "" { - version = commit - } - lambda.Start(parse) }