Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ BINARY_NAME=gitx
CMD_PATH=./cmd/gitx
BUILD_DIR=./build

# Versioning -- NEW SECTION
# Get the latest git tag, or fallback to "dev" if no tags are found.
VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev")
LDFLAGS := -ldflags="-X 'main.version=$(VERSION)'"

# Default target executed when you run `make`
all: build

Expand All @@ -16,7 +21,7 @@ sync:
build: sync
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@go build -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_PATH)
@go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_PATH)
@echo "Binary available at $(BUILD_DIR)/$(BINARY_NAME)"

# Runs the application
Expand All @@ -37,7 +42,7 @@ ci:
# Installs the binary to /usr/local/bin
install: build
@echo "Installing $(BINARY_NAME)..."
@go install $(CMD_PATH)
@go install $(LDFLAGS) $(CMD_PATH)
@echo "$(BINARY_NAME) installed successfully"

# Cleans the build artifacts
Expand Down
8 changes: 8 additions & 0 deletions cmd/gitx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ import (
"errors"
"fmt"
"log"
"os"

tea "github.com/charmbracelet/bubbletea"
"github.com/gitxtui/gitx/internal/tui"
zone "github.com/lrstanley/bubblezone"
)

var version = "dev"

func main() {
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
fmt.Printf("gitx version: %s\n", version)
return
}

zone.NewGlobal()
defer zone.Close()

Expand Down