detached c6247a6

build(makefile): add comprehensive build targets for Go installer with release, static, and TinyGo options

commit
c6247a601638f2a8608d3fbafe6a19b0211bb08f
author
bnema · · 2025-10-26 09:42 UTC
parent
685e268
signature
unsigned
1 file · +115 -0
A Makefile.go +115 -0
@@ -0,0 +1,115 @@
1+# ArchUp Go Installer Makefile
2+# Builds the Go-based installer with proper version injection
3+
4+# Get version from git tag or use dev
5+VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
6+LDFLAGS := -ldflags "-X main.version=$(VERSION)"
7+LDFLAGS_STRIP := -ldflags "-X main.version=$(VERSION) -s -w"
8+
9+# Build settings
10+BINARY_NAME := archup-installer
11+BUILD_DIR := build
12+CMD_DIR := cmd/archup-installer
13+INSTALL_DIR := /usr/local/bin
14+
15+# Go build flags
16+GOFLAGS := -trimpath
17+CGO_ENABLED := 0
18+
19+.PHONY: all build clean install uninstall run test fmt vet lint mod-tidy help
20+
21+all: build
22+
23+## build: Build the installer binary with version injection
24+build:
25+ @echo "Building $(BINARY_NAME) $(VERSION)..."
26+ @mkdir -p $(BUILD_DIR)
27+ CGO_ENABLED=$(CGO_ENABLED) go build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
28+ @echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
29+
30+## build-release: Build optimized release binary (stripped, smaller size)
31+build-release:
32+ @echo "Building release $(BINARY_NAME) $(VERSION)..."
33+ @mkdir -p $(BUILD_DIR)
34+ CGO_ENABLED=0 go build $(GOFLAGS) $(LDFLAGS_STRIP) -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
35+ @echo "Release build complete: $(BUILD_DIR)/$(BINARY_NAME)"
36+ @ls -lh $(BUILD_DIR)/$(BINARY_NAME)
37+
38+## build-static: Build fully static binary (no dependencies)
39+build-static:
40+ @echo "Building static $(BINARY_NAME) $(VERSION)..."
41+ @mkdir -p $(BUILD_DIR)
42+ CGO_ENABLED=0 go build $(GOFLAGS) $(LDFLAGS) -a -installsuffix cgo -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
43+ @echo "Static build complete: $(BUILD_DIR)/$(BINARY_NAME)"
44+
45+## build-tiny: Build with TinyGo for minimal binary size (requires Go 1.19-1.24)
46+build-tiny:
47+ @echo "Building with TinyGo $(BINARY_NAME) $(VERSION)..."
48+ @mkdir -p $(BUILD_DIR)
49+ @which tinygo > /dev/null || (echo "TinyGo not installed. Install from: https://tinygo.org/getting-started/install/" && exit 1)
50+ @echo "NOTE: TinyGo requires system Go version 1.19-1.24. Current: $$(go version | awk '{print $$3}')"
51+ tinygo build -o $(BUILD_DIR)/$(BINARY_NAME)-tiny $(LDFLAGS) ./$(CMD_DIR) || (echo "TinyGo build failed. System Go version incompatible or packages not supported." && exit 1)
52+ @echo "TinyGo build complete: $(BUILD_DIR)/$(BINARY_NAME)-tiny"
53+ @ls -lh $(BUILD_DIR)/$(BINARY_NAME)-tiny
54+
55+## install: Install the binary to system
56+install: build
57+ @echo "Installing $(BINARY_NAME) to $(INSTALL_DIR)..."
58+ @sudo install -m 755 $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_DIR)/$(BINARY_NAME)
59+ @echo "Installed successfully"
60+
61+## uninstall: Remove the binary from system
62+uninstall:
63+ @echo "Uninstalling $(BINARY_NAME)..."
64+ @sudo rm -f $(INSTALL_DIR)/$(BINARY_NAME)
65+ @echo "Uninstalled successfully"
66+
67+## run: Build and run the installer
68+run: build
69+ @echo "Running $(BINARY_NAME)..."
70+ @$(BUILD_DIR)/$(BINARY_NAME)
71+
72+## test: Run tests
73+test:
74+ @echo "Running tests..."
75+ @go test -v -race -coverprofile=coverage.out ./...
76+ @go tool cover -func=coverage.out
77+
78+## fmt: Format all Go code
79+fmt:
80+ @echo "Formatting code..."
81+ @go fmt ./...
82+ @gofmt -s -w .
83+
84+## vet: Run go vet
85+vet:
86+ @echo "Running go vet..."
87+ @go vet ./...
88+
89+## lint: Run golangci-lint (install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
90+lint:
91+ @echo "Running golangci-lint..."
92+ @which golangci-lint > /dev/null || (echo "golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
93+ @golangci-lint run ./...
94+
95+## mod-tidy: Tidy go.mod
96+mod-tidy:
97+ @echo "Tidying go.mod..."
98+ @go mod tidy
99+
100+## clean: Remove build artifacts
101+clean:
102+ @echo "Cleaning build artifacts..."
103+ @rm -rf $(BUILD_DIR)
104+ @rm -f coverage.out
105+ @echo "Clean complete"
106+
107+## version: Show version information
108+version:
109+ @echo "Version: $(VERSION)"
110+
111+## help: Show this help message
112+help:
113+ @echo "ArchUp Go Installer - Makefile Commands"
114+ @echo ""
115+ @sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'
@@ -0,0 +1,115 @@
1+# ArchUp Go Installer Makefile
2+# Builds the Go-based installer with proper version injection
3+
4+# Get version from git tag or use dev
5+VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
6+LDFLAGS := -ldflags "-X main.version=$(VERSION)"
7+LDFLAGS_STRIP := -ldflags "-X main.version=$(VERSION) -s -w"
8+
9+# Build settings
10+BINARY_NAME := archup-installer
11+BUILD_DIR := build
12+CMD_DIR := cmd/archup-installer
13+INSTALL_DIR := /usr/local/bin
14+
15+# Go build flags
16+GOFLAGS := -trimpath
17+CGO_ENABLED := 0
18+
19+.PHONY: all build clean install uninstall run test fmt vet lint mod-tidy help
20+
21+all: build
22+
23+## build: Build the installer binary with version injection
24+build:
25+ @echo "Building $(BINARY_NAME) $(VERSION)..."
26+ @mkdir -p $(BUILD_DIR)
27+ CGO_ENABLED=$(CGO_ENABLED) go build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
28+ @echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
29+
30+## build-release: Build optimized release binary (stripped, smaller size)
31+build-release:
32+ @echo "Building release $(BINARY_NAME) $(VERSION)..."
33+ @mkdir -p $(BUILD_DIR)
34+ CGO_ENABLED=0 go build $(GOFLAGS) $(LDFLAGS_STRIP) -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
35+ @echo "Release build complete: $(BUILD_DIR)/$(BINARY_NAME)"
36+ @ls -lh $(BUILD_DIR)/$(BINARY_NAME)
37+
38+## build-static: Build fully static binary (no dependencies)
39+build-static:
40+ @echo "Building static $(BINARY_NAME) $(VERSION)..."
41+ @mkdir -p $(BUILD_DIR)
42+ CGO_ENABLED=0 go build $(GOFLAGS) $(LDFLAGS) -a -installsuffix cgo -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
43+ @echo "Static build complete: $(BUILD_DIR)/$(BINARY_NAME)"
44+
45+## build-tiny: Build with TinyGo for minimal binary size (requires Go 1.19-1.24)
46+build-tiny:
47+ @echo "Building with TinyGo $(BINARY_NAME) $(VERSION)..."
48+ @mkdir -p $(BUILD_DIR)
49+ @which tinygo > /dev/null || (echo "TinyGo not installed. Install from: https://tinygo.org/getting-started/install/" && exit 1)
50+ @echo "NOTE: TinyGo requires system Go version 1.19-1.24. Current: $$(go version | awk '{print $$3}')"
51+ tinygo build -o $(BUILD_DIR)/$(BINARY_NAME)-tiny $(LDFLAGS) ./$(CMD_DIR) || (echo "TinyGo build failed. System Go version incompatible or packages not supported." && exit 1)
52+ @echo "TinyGo build complete: $(BUILD_DIR)/$(BINARY_NAME)-tiny"
53+ @ls -lh $(BUILD_DIR)/$(BINARY_NAME)-tiny
54+
55+## install: Install the binary to system
56+install: build
57+ @echo "Installing $(BINARY_NAME) to $(INSTALL_DIR)..."
58+ @sudo install -m 755 $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_DIR)/$(BINARY_NAME)
59+ @echo "Installed successfully"
60+
61+## uninstall: Remove the binary from system
62+uninstall:
63+ @echo "Uninstalling $(BINARY_NAME)..."
64+ @sudo rm -f $(INSTALL_DIR)/$(BINARY_NAME)
65+ @echo "Uninstalled successfully"
66+
67+## run: Build and run the installer
68+run: build
69+ @echo "Running $(BINARY_NAME)..."
70+ @$(BUILD_DIR)/$(BINARY_NAME)
71+
72+## test: Run tests
73+test:
74+ @echo "Running tests..."
75+ @go test -v -race -coverprofile=coverage.out ./...
76+ @go tool cover -func=coverage.out
77+
78+## fmt: Format all Go code
79+fmt:
80+ @echo "Formatting code..."
81+ @go fmt ./...
82+ @gofmt -s -w .
83+
84+## vet: Run go vet
85+vet:
86+ @echo "Running go vet..."
87+ @go vet ./...
88+
89+## lint: Run golangci-lint (install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
90+lint:
91+ @echo "Running golangci-lint..."
92+ @which golangci-lint > /dev/null || (echo "golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
93+ @golangci-lint run ./...
94+
95+## mod-tidy: Tidy go.mod
96+mod-tidy:
97+ @echo "Tidying go.mod..."
98+ @go mod tidy
99+
100+## clean: Remove build artifacts
101+clean:
102+ @echo "Cleaning build artifacts..."
103+ @rm -rf $(BUILD_DIR)
104+ @rm -f coverage.out
105+ @echo "Clean complete"
106+
107+## version: Show version information
108+version:
109+ @echo "Version: $(VERSION)"
110+
111+## help: Show this help message
112+help:
113+ @echo "ArchUp Go Installer - Makefile Commands"
114+ @echo ""
115+ @sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close