forked from rudrankriyam/App-Store-Connect-CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
226 lines (195 loc) · 6.39 KB
/
Makefile
File metadata and controls
226 lines (195 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# App-Store-Connect-CLI Makefile
# Variables
BINARY_NAME := asc
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
# Go variables
GO := go
GOMOD := go.mod
GOBIN := $(shell $(GO) env GOPATH)/bin
GOLANGCI_LINT_TIMEOUT ?= 5m
INSTALL_PREFIX ?= /usr/local/bin
# Directories
SRC_DIR := .
BUILD_DIR := build
DIST_DIR := dist
# Colors
GREEN := \033[0;32m
YELLOW := \033[0;33m
BLUE := \033[0;34m
NC := \033[0m # No Color
# Default target
.PHONY: all
all: build
# Build the binary
.PHONY: build
build: $(BINARY_NAME)
@echo "$(GREEN)✓ Build complete: $(BINARY_NAME)$(NC)"
$(BINARY_NAME): $(GOMOD)
@echo "$(BLUE)Building $(BINARY_NAME)...$(NC)"
$(GO) build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) .
# Build for multiple platforms
.PHONY: build-all
build-all: clean
@echo "$(BLUE)Building for multiple platforms...$(NC)"
$(GO) run github.com/goreleaser/nfpm/v2@latest --config .nfpm.yaml --packer deb --packer rpm --packer apk --packer tarball
# Build with debug symbols
.PHONY: build-debug
build-debug:
$(GO) build -gcflags="all=-N -l" -o $(BINARY_NAME)-debug .
# Run tests
.PHONY: test
test:
@echo "$(BLUE)Running tests...$(NC)"
ASC_BYPASS_KEYCHAIN=1 $(GO) test -v ./...
# Run tests with coverage
.PHONY: test-coverage
test-coverage:
@echo "$(BLUE)Running tests with coverage...$(NC)"
ASC_BYPASS_KEYCHAIN=1 $(GO) test -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "$(GREEN)Coverage report: coverage.html$(NC)"
# Run integration tests (opt-in)
.PHONY: test-integration
test-integration:
@echo "$(BLUE)Running integration tests (requires ASC_* env vars)...$(NC)"
$(GO) test -tags=integration -v ./internal/asc -run Integration
$(GO) test -tags=integration -v ./internal/update -run Integration
# Lint the code
.PHONY: lint
lint:
@echo "$(BLUE)Linting code...$(NC)"
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run --timeout=$(GOLANGCI_LINT_TIMEOUT) ./...; \
else \
echo "$(YELLOW)golangci-lint not found; falling back to 'go vet ./...'.$(NC)"; \
echo "$(YELLOW)Install with: make tools (or: $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)$(NC)"; \
$(GO) vet ./...; \
fi
# Format code
.PHONY: format
format:
@echo "$(BLUE)Formatting code...$(NC)"
@if ! command -v gofumpt >/dev/null 2>&1; then \
echo "$(YELLOW)gofumpt not found; install with: make tools (or: $(GO) install mvdan.cc/gofumpt@latest)$(NC)"; \
exit 1; \
fi
$(GO) fmt ./...
gofumpt -w .
# Install dev tools
.PHONY: tools
tools:
@echo "$(BLUE)Installing dev tools...$(NC)"
$(GO) install mvdan.cc/gofumpt@latest
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@echo "$(GREEN)✓ Tools installed$(NC)"
@echo "$(YELLOW)Make sure '$(GOBIN)' is on your PATH$(NC)"
# Install local git hooks
.PHONY: install-hooks
install-hooks:
@echo "$(BLUE)Installing git hooks...$(NC)"
git config core.hooksPath .githooks
chmod +x .githooks/pre-commit
@echo "$(GREEN)✓ Hooks installed (core.hooksPath=.githooks)$(NC)"
# Install dependencies
.PHONY: deps
deps:
@echo "$(BLUE)Installing dependencies...$(NC)"
$(GO) mod download
$(GO) mod tidy
# Update dependencies
.PHONY: update-deps
update-deps:
@echo "$(BLUE)Updating dependencies...$(NC)"
$(GO) get -u ./...
$(GO) mod tidy
# Update OpenAPI index
.PHONY: update-openapi
update-openapi:
@echo "$(BLUE)Updating OpenAPI paths index...$(NC)"
python3 scripts/update-openapi-index.py
# Generate app metadata and sync Wall docs
.PHONY: generate
generate:
@true
.PHONY: app
app: generate-app
.PHONY: generate-app
generate-app:
@echo "$(BLUE)Generating Wall app entry...$(NC)"
$(GO) run ./tools/generate-app --app "$(APP)" --link "$(LINK)" --creator "$(CREATOR)" --platform "$(PLATFORM)"
# Update Wall of Apps docs snippet
.PHONY: update-wall-of-apps
update-wall-of-apps:
@echo "$(BLUE)Updating Wall of Apps snippets...$(NC)"
$(GO) run ./tools/update-wall-of-apps
# Clean build artifacts
.PHONY: clean
clean:
@echo "$(BLUE)Cleaning...$(NC)"
rm -f $(BINARY_NAME) $(BINARY_NAME)-debug
rm -rf $(BUILD_DIR) $(DIST_DIR)
rm -f coverage.out coverage.html
# Install the binary
.PHONY: install
install: build
@echo "$(BLUE)Installing to $(INSTALL_PREFIX)...$(NC)"
install -d $(INSTALL_PREFIX)
install -m 755 $(BINARY_NAME) $(INSTALL_PREFIX)/$(BINARY_NAME)
# Uninstall the binary
.PHONY: uninstall
uninstall:
@echo "$(BLUE)Uninstalling...$(NC)"
rm -f $(INSTALL_PREFIX)/$(BINARY_NAME)
# Run the CLI locally
.PHONY: run
run: build
@echo "$(BLUE)Running locally...$(NC)"
./$(BINARY_NAME) --help
# Create a release
.PHONY: release
release: clean
@echo "$(BLUE)Creating release...$(NC)"
@echo "$(YELLOW)Note: Use GitHub Actions for releases$(NC)"
# Show help
.PHONY: help
help:
@echo ""
@echo "$(GREEN)App-Store-Connect-CLI$(NC) - Build System"
@echo ""
@echo "Targets:"
@echo " build Build the binary"
@echo " build-all Build for multiple platforms"
@echo " build-debug Build with debug symbols"
@echo " test Run tests"
@echo " test-coverage Run tests with coverage"
@echo " test-integration Run opt-in integration tests"
@echo " lint Lint the code"
@echo " format Format code"
@echo " tools Install dev tools"
@echo " install-hooks Install local git hooks"
@echo " deps Install dependencies"
@echo " update-deps Update dependencies"
@echo " update-openapi Update OpenAPI paths index"
@echo " generate app Generate/update Wall app entry in JSON + README"
@echo " Usage: make generate app APP=\"Name\" LINK=\"https://...\" CREATOR=\"you\" PLATFORM=\"iOS,macOS\""
@echo " update-wall-of-apps Update Wall of Apps snippets"
@echo " clean Clean build artifacts"
@echo " install Install binary"
@echo " uninstall Uninstall binary"
@echo " run Run CLI locally"
@echo " help Show this help"
@echo ""
# Development shortcuts
.PHONY: dev
dev: format lint test build
@echo "$(GREEN)✓ Ready for development!$(NC)"
# Check for security vulnerabilities
.PHONY: security
security:
@echo "$(BLUE)Checking for security vulnerabilities...$(NC)"
@which gosec > /dev/null 2>&1 && \
gosec ./... || \
echo "$(YELLOW)Install gosec for security checks$(NC)"