Skip to content

Commit

Permalink
include version when building phoneserver for netlify
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Apr 30, 2019
1 parent f0fc96b commit 5f56e75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 2 additions & 9 deletions cmd/phoneserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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)
}

0 comments on commit 5f56e75

Please sign in to comment.