upload to github
This commit is contained in:
commit
ae9ca74ac6
23 changed files with 2133 additions and 0 deletions
166
Makefile
Normal file
166
Makefile
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
# Makefile for Beat Harvester
|
||||
|
||||
# Variables
|
||||
APP_NAME := beat-harvester
|
||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
||||
|
||||
# Build flags
|
||||
LDFLAGS := -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME) -s -w
|
||||
|
||||
# Default target
|
||||
.PHONY: all
|
||||
all: build
|
||||
|
||||
# Build the application
|
||||
.PHONY: build
|
||||
build: init
|
||||
@echo "🔨 Building $(APP_NAME)..."
|
||||
@mkdir -p bin
|
||||
go build -ldflags "$(LDFLAGS)" -o bin/$(APP_NAME) .
|
||||
|
||||
# Development server
|
||||
.PHONY: dev
|
||||
dev:
|
||||
@echo "🚀 Starting development server..."
|
||||
go run .
|
||||
|
||||
# Initialize Go module and dependencies
|
||||
.PHONY: init
|
||||
init:
|
||||
@if [ ! -f go.mod ]; then \
|
||||
echo "Creating go.mod..."; \
|
||||
go mod init beat-harvester; \
|
||||
fi
|
||||
@echo "📦 Installing dependencies..."
|
||||
go get github.com/gorilla/mux@v1.8.1
|
||||
go get github.com/gorilla/websocket@v1.5.1
|
||||
go mod tidy
|
||||
|
||||
# Install dependencies
|
||||
.PHONY: deps
|
||||
deps:
|
||||
@echo "📦 Installing dependencies..."
|
||||
go mod download
|
||||
go mod verify
|
||||
|
||||
# Clean build artifacts
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo "🧹 Cleaning..."
|
||||
rm -rf bin/ release/
|
||||
go clean
|
||||
|
||||
# Run tests
|
||||
.PHONY: test
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
go test -v ./...
|
||||
|
||||
# Format code
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
@echo "Formatting code..."
|
||||
go fmt ./...
|
||||
|
||||
# Build for multiple platforms
|
||||
.PHONY: build-all
|
||||
build-all:
|
||||
@echo "Building for all platforms..."
|
||||
@mkdir -p bin
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/$(APP_NAME)-linux-amd64 .
|
||||
GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/$(APP_NAME)-darwin-amd64 .
|
||||
GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o bin/$(APP_NAME)-darwin-arm64 .
|
||||
GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/$(APP_NAME)-windows-amd64.exe .
|
||||
|
||||
# Create release packages
|
||||
.PHONY: package
|
||||
package: build-all
|
||||
@echo "📦 Creating release packages..."
|
||||
@mkdir -p release
|
||||
tar -czf release/$(APP_NAME)-$(VERSION)-linux-amd64.tar.gz -C bin $(APP_NAME)-linux-amd64
|
||||
tar -czf release/$(APP_NAME)-$(VERSION)-darwin-amd64.tar.gz -C bin $(APP_NAME)-darwin-amd64
|
||||
tar -czf release/$(APP_NAME)-$(VERSION)-darwin-arm64.tar.gz -C bin $(APP_NAME)-darwin-arm64
|
||||
cd bin && zip ../release/$(APP_NAME)-$(VERSION)-windows-amd64.zip $(APP_NAME)-windows-amd64.exe
|
||||
|
||||
# Docker commands
|
||||
.PHONY: docker-build
|
||||
docker-build:
|
||||
@echo "🐳 Building Docker image..."
|
||||
docker build -t $(APP_NAME):$(VERSION) .
|
||||
|
||||
.PHONY: docker-run
|
||||
docker-run:
|
||||
@echo "🐳 Running Docker container..."
|
||||
docker-compose up -d
|
||||
|
||||
.PHONY: docker-stop
|
||||
docker-stop:
|
||||
@echo "Stopping Docker container..."
|
||||
docker-compose down
|
||||
|
||||
.PHONY: docker-logs
|
||||
docker-logs:
|
||||
docker-compose logs -f
|
||||
|
||||
# Install system dependencies
|
||||
.PHONY: install-deps-ubuntu
|
||||
install-deps-ubuntu:
|
||||
@echo "Installing system dependencies for Ubuntu/Debian..."
|
||||
sudo apt update
|
||||
sudo apt install -y python3 python3-pip ffmpeg webp
|
||||
pip3 install --user yt-dlp
|
||||
|
||||
.PHONY: install-deps-macos
|
||||
install-deps-macos:
|
||||
@echo "Installing system dependencies for macOS..."
|
||||
brew install python3 ffmpeg webp
|
||||
pip3 install yt-dlp
|
||||
|
||||
# Check dependencies
|
||||
.PHONY: check-deps
|
||||
check-deps:
|
||||
@echo "Checking system dependencies..."
|
||||
@command -v yt-dlp >/dev/null 2>&1 || { echo "❌ yt-dlp not found"; exit 1; }
|
||||
@command -v ffmpeg >/dev/null 2>&1 || { echo "❌ ffmpeg not found"; exit 1; }
|
||||
@command -v ffprobe >/dev/null 2>&1 || { echo "❌ ffprobe not found"; exit 1; }
|
||||
@command -v dwebp >/dev/null 2>&1 || echo "⚠️ dwebp not found (thumbnail cropping disabled)"
|
||||
@echo "✅ All required dependencies found"
|
||||
|
||||
# Run the application
|
||||
.PHONY: run
|
||||
run: build check-deps
|
||||
@echo "🎵 Starting Beat Harvester..."
|
||||
./bin/$(APP_NAME)
|
||||
|
||||
# Show help
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "Beat Harvester Build System"
|
||||
@echo "=========================="
|
||||
@echo ""
|
||||
@echo "Available targets:"
|
||||
@echo " build - Build the application"
|
||||
@echo " build-all - Build for all platforms"
|
||||
@echo " package - Create release packages"
|
||||
@echo " dev - Start development server"
|
||||
@echo " run - Build and run the application"
|
||||
@echo " test - Run tests"
|
||||
@echo " fmt - Format code"
|
||||
@echo " clean - Clean build artifacts"
|
||||
@echo ""
|
||||
@echo "Docker commands:"
|
||||
@echo " docker-build - Build Docker image"
|
||||
@echo " docker-run - Run with docker-compose"
|
||||
@echo " docker-stop - Stop docker-compose"
|
||||
@echo " docker-logs - View container logs"
|
||||
@echo ""
|
||||
@echo "Dependencies:"
|
||||
@echo " init - Initialize Go module"
|
||||
@echo " deps - Install Go dependencies"
|
||||
@echo " install-deps-* - Install system dependencies"
|
||||
@echo " check-deps - Check system dependencies"
|
||||
@echo ""
|
||||
@echo "Environment variables:"
|
||||
@echo " PORT - Server port (default: 3000)"
|
||||
@echo " OUTPUT_PATH - Default music output path"
|
||||
Loading…
Add table
Add a link
Reference in a new issue