diff options
| author | mo khan <mo@mokhan.ca> | 2022-04-22 17:47:35 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2022-04-22 17:47:35 -0600 |
| commit | 163118467da7203b61e285814ed280872abb2b3f (patch) | |
| tree | 01b9662386c62af8e28ff68ac10717b6a30faafe | |
| parent | 0b09e735c9733f557e1ec7138e108e8d5bd7a7f5 (diff) | |
chore: add makefile and include git commit
| -rw-r--r-- | Makefile | 30 | ||||
| -rwxr-xr-x | bin/idp | bin | 0 -> 9607792 bytes | |||
| -rw-r--r-- | cmd/server/main.go | 7 |
3 files changed, 37 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..796bc8f --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +NAME ?= $(shell basename "$(CURDIR)") +GIT_COMMIT ?= $(shell git rev-parse --short HEAD) +SOURCE_FILES = $(shell find $(CURDIR) -type f -name '*.go') +PACKAGES = $(shell go list ./...) + +EFFECTIVE_LD_FLAGS ?= "-X main.GitCommit=$(GIT_COMMIT) $(LD_FLAGS)" + +default: help + +bin: bin/$(NAME) ## Build binary + +bin/$(NAME): $(SOURCE_FILES) + go build -o "bin/$(NAME)" -ldflags $(EFFECTIVE_LD_FLAGS) cmd/server/main.go + +.PHONY: clean +clean: + rm -r $(CURDIR)/bin $(CURDIR)/build + +.PHONY: server +server: bin/$(NAME) ## Start server + bin/$(NAME) + +.PHONY: test +test: ## Run tests + go test -race $(PACKAGES) + +.PHONY: help +help: + @echo "Valid targets:" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' Binary files differdiff --git a/cmd/server/main.go b/cmd/server/main.go index 1ef7197..7621d19 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -5,6 +5,7 @@ import ( "log" "net/http" "os" + "runtime" "mokhan.ca/xlgmokha/oauth/pkg/web" ) @@ -12,7 +13,13 @@ import ( //go:embed insecure.pem var privateKey []byte +var ( + // GitCommit is used as the application version string, set by LD flags. + GitCommit string +) + func main() { + log.Printf("Version: %s, Go Version: %s\n", GitCommit, runtime.Version()) log.Println("Starting server, listening on port 8282.") issuer, ok := os.LookupEnv("ISSUER") if !ok { |
