feat: add version command (#26)

This commit is contained in:
Hanshal Mehta
2025-05-16 09:41:48 +05:30
committed by GitHub
parent d8d7bda8ca
commit 81d4875b8d
3 changed files with 43 additions and 1 deletions
+7 -1
View File
@@ -1,13 +1,19 @@
GO := go
BIN_DIR := bin
BIN := $(BIN_DIR)/pmg
SHELL := /bin/bash
GITCOMMIT := $(shell git rev-parse HEAD)
VERSION := "$(shell git describe --tags --abbrev=0)-$(shell git rev-parse --short HEAD)"
GO_CFLAGS=-X 'github.com/safedep/pmg/cmd/version.commit=$(GITCOMMIT)' -X 'github.com/safedep/pmg/cmd/version.version=$(VERSION)'
GO_LDFLAGS=-ldflags "-w $(GO_CFLAGS)"
.PHONY: all
all: pmg
pmg: create_bin
$(GO) build -o $(BIN) main.go
$(GO) build ${GO_LDFLAGS} -o $(BIN) main.go
create_bin:
mkdir -p $(BIN_DIR)