# Default target .DEFAULT_GOAL := help # Build configuration VERSION := $(shell cat ../VERSION 2>/dev/null || echo "0.0.0-dev") BUILD_DIR := build DIST_DIR := dist DEB_DIR := debian-package # Git information GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S') EDGE_VERSION := 0.0.0~edge.$(shell date -u '+%Y%m%d%H%M%S').$(GIT_COMMIT) # Source paths API_SOURCE := .. WEB_SOURCE := ../web # Output files ARM64_BINARY := $(BUILD_DIR)/wild-central-arm64 AMD64_BINARY := $(BUILD_DIR)/wild-central-amd64 WEB_DIST_MARKER := $(BUILD_DIR)/.web-built ARM64_DEB := $(DIST_DIR)/packages/wild-central_$(VERSION)_arm64.deb AMD64_DEB := $(DIST_DIR)/packages/wild-central_$(VERSION)_amd64.deb # Gitea release configuration GITEA_URL := https://git.civilsociety.dev GITEA_OWNER := wild-cloud GITEA_REPO := wild-central RELEASE_TAG := v$(VERSION) .PHONY: help clean version build build-all package package-all repo deploy-repo release release-edge help: @echo "Wild Central Package Builder" @echo "" @echo "This directory builds .deb packages for Wild Central." @echo "For development, use the parent directory:" @echo " - make dev (Go daemon)" @echo " - cd web && pnpm dev (React frontend)" @echo "" @echo "Build targets:" @echo " build - Build for current architecture (amd64)" @echo " build-all - Build all architectures" @echo "" @echo "Package targets:" @echo " package - Create .deb package (amd64)" @echo " package-all - Create all .deb packages" @echo "" @echo "Repository targets:" @echo " deploy-repo - Deploy repository to server" @echo "" @echo "Release targets:" @echo " release - Tag HEAD as v$$(cat ../VERSION), publish stable Gitea release + APT" @echo " release-edge - Publish rolling edge Gitea release + APT (no version bump needed)" @echo "" @echo "Utilities:" @echo " clean - Remove all build artifacts" @echo " version - Show build information" @echo "" @echo " Current stable version: $(VERSION) (from ../VERSION)" @echo " Current edge version: $(EDGE_VERSION)" @echo "" @echo "Environment variables:" @echo " GITEA_TOKEN - Gitea API token (required for release)" @echo " APTLY_URL - Aptly instance URL (required for APT deployment)" @echo " APTLY_PASS - Aptly API password" @echo " These must be set in your environment" clean: @echo "Cleaning build artifacts..." @rm -rf $(BUILD_DIR) $(DIST_DIR) $(DEB_DIR)-* $(DEB_DIR) version: @echo "Version: $(VERSION)" @echo "Git Commit: $(GIT_COMMIT)" @echo "Build Time: $(BUILD_TIME)" # Web app build - track with marker file $(WEB_DIST_MARKER): $(shell find $(WEB_SOURCE)/src -type f 2>/dev/null | head -100) $(WEB_SOURCE)/package.json @echo "Building web application..." @ARCH=amd64 VERSION=$(VERSION) ./scripts/build-package.sh @touch $(WEB_DIST_MARKER) # ARM64 binary $(ARM64_BINARY): $(shell find $(API_SOURCE) -name '*.go' -not -path '*/dist/*' -not -path '*/web/*' 2>/dev/null | head -100) @echo "Building arm64 binary..." @mkdir -p $(BUILD_DIR) @cd $(API_SOURCE) && GOOS=linux GOARCH=arm64 go build -ldflags="-X main.Version=$(VERSION)" -o dist/$(ARM64_BINARY) . # AMD64 binary $(AMD64_BINARY): $(shell find $(API_SOURCE) -name '*.go' -not -path '*/dist/*' -not -path '*/web/*' 2>/dev/null | head -100) @echo "Building amd64 binary..." @mkdir -p $(BUILD_DIR) @cd $(API_SOURCE) && GOOS=linux GOARCH=amd64 go build -ldflags="-X main.Version=$(VERSION)" -o dist/$(AMD64_BINARY) . # ARM64 package $(ARM64_DEB): $(ARM64_BINARY) $(WEB_DIST_MARKER) @echo "Creating arm64 .deb package..." @rm -f $(DIST_DIR)/packages/wild-central_*_arm64.deb @./scripts/package-deb.sh arm64 $(ARM64_BINARY) $(VERSION) # AMD64 package $(AMD64_DEB): $(AMD64_BINARY) $(WEB_DIST_MARKER) @echo "Creating amd64 .deb package..." @rm -f $(DIST_DIR)/packages/wild-central_*_amd64.deb @./scripts/package-deb.sh amd64 $(AMD64_BINARY) $(VERSION) # Convenience targets build: $(AMD64_BINARY) $(WEB_DIST_MARKER) build-all: $(ARM64_BINARY) $(AMD64_BINARY) $(WEB_DIST_MARKER) package: $(AMD64_DEB) package-all: $(ARM64_DEB) $(AMD64_DEB) deploy-repo: $(ARM64_DEB) $(AMD64_DEB) @echo "Deploying APT repository..." @if [ -z "$(APTLY_URL)" ] || [ -z "$(APTLY_PASS)" ]; then \ echo "Error: APTLY_URL and APTLY_PASS must be set"; \ echo " These must be set in your environment"; \ exit 1; \ fi @./scripts/deploy-apt-repository.sh release: $(ARM64_DEB) $(AMD64_DEB) @echo "Creating stable release $(RELEASE_TAG)..." @if [ -z "$(GITEA_TOKEN)" ]; then \ echo "Error: GITEA_TOKEN environment variable not set"; \ echo " Get a token from $(GITEA_URL)/user/settings/applications"; \ echo " These must be set in your environment"; \ exit 1; \ fi @if git tag | grep -q "^$(RELEASE_TAG)$$"; then \ echo "Tag $(RELEASE_TAG) already exists — updating release assets only"; \ else \ echo "Tagging HEAD as $(RELEASE_TAG)..."; \ git tag -a $(RELEASE_TAG) -m "Wild Central $(VERSION)"; \ git push origin $(RELEASE_TAG); \ fi @./scripts/create-gitea-release.sh "$(GITEA_URL)" "$(GITEA_OWNER)" "$(GITEA_REPO)" "$(RELEASE_TAG)" "$(VERSION)" "$(GITEA_TOKEN)" stable @if [ -n "$(APTLY_URL)" ] && [ -n "$(APTLY_PASS)" ]; then \ ./scripts/deploy-apt-repository.sh; \ else \ echo "Skipping APT deployment (APTLY_URL/APTLY_PASS not set)"; \ fi release-edge: $(ARM64_DEB) $(AMD64_DEB) @echo "Creating edge release ($(EDGE_VERSION))..." @if [ -z "$(GITEA_TOKEN)" ]; then \ echo "Error: GITEA_TOKEN environment variable not set"; \ echo " These must be set in your environment"; \ exit 1; \ fi @echo "Force-pushing edge tag to HEAD..." @git tag -f edge @git push origin edge --force @./scripts/create-gitea-release.sh "$(GITEA_URL)" "$(GITEA_OWNER)" "$(GITEA_REPO)" "edge" "$(EDGE_VERSION)" "$(GITEA_TOKEN)" edge @if [ -n "$(APTLY_URL)" ] && [ -n "$(APTLY_PASS)" ]; then \ DIST=edge ./scripts/deploy-apt-repository.sh; \ else \ echo "Skipping APT deployment (APTLY_URL/APTLY_PASS not set)"; \ fi