neoricalex/Makefile.am
2025-11-09 11:09:23 +01:00

97 lines
2.7 KiB
Makefile

SUBDIRS = src
# ===========================
# Configurações de Git
# ===========================
GIT_USER ?= "neo.webmaster.2@gmail.com"
GIT_EMAIL ?= "neo.webmaster.2@gmail.com"
GIT_REMOTE ?= "origin"
GIT_BRANCH ?= "main"
COMMIT_MSG ?= "Auto-commit via make git"
# ===========================
# Caminhos e artefactos
# ===========================
DIST_DIR ?= $(top_builddir)/dist
BUILD_DIR ?= $(top_builddir)/build
SRC_TAR ?= $(DIST_DIR)/neoricalex-src.tar.gz
# ===========================
# Alvos principais
# ===========================
.PHONY: all tarball git release run clean-local
all: $(DIST_DIR)
$(DIST_DIR):
mkdir -p $(DIST_DIR)
# ===========================
# Empacotamento do código-fonte
# ===========================
tarball: $(SRC_TAR)
$(SRC_TAR):
@echo "[TAR] Empacotando código-fonte..."
mkdir -p $(DIST_DIR)
cd $(top_srcdir) && tar \
--exclude="$(notdir $(SRC_TAR))" \
--exclude="$(DIST_DIR)" \
--exclude="$(BUILD_DIR)" \
--exclude='*/__pycache__' \
--exclude='*/.venv' \
--exclude='*/venv' \
--exclude='*.pyc' \
--exclude='*.pyo' \
--exclude='*.o' \
--exclude='*.a' \
--exclude='*.so' \
-czf $(SRC_TAR) .
@echo "[✔] Tarball gerado em $(SRC_TAR)"
# ===========================
# Git (commit + push)
# ===========================
git:
@echo "📦 Commit automático → Gitea"
@git config user.name $(GIT_USER)
@git config user.email $(GIT_EMAIL)
@git rev-parse --abbrev-ref HEAD >/dev/null 2>&1 || true
@git add -A
@git commit -m "$(COMMIT_MSG)" || echo "Nenhuma modificação para commitar."
@git push $(GIT_REMOTE) $(GIT_BRANCH)
# ===========================
# Release (Tarball)
# ===========================
release: tarball
@echo "🚀 Publicando build em dist/releases"
@mkdir -p $(DIST_DIR)/releases
@if ls $(DIST_DIR)/neoricalex-*.tar.gz >/dev/null 2>&1; then \
cp $(DIST_DIR)/neoricalex-*.tar.gz $(DIST_DIR)/releases/; \
else \
echo "⚠️ Nenhum tarball encontrado. Execute 'make tarball' primeiro."; \
fi
@git add $(DIST_DIR)/releases/
@git commit -m "Build automático: release $(shell date +%F_%H-%M)" || echo "Nenhum ficheiro novo para commitar."
@git push origin main
@TAG="v$(shell date +%Y.%m.%d-%H%M)" && \
echo "🏷 Criando tag $$TAG" && \
git tag -a $$TAG -m "Release automática em $$TAG" && \
git push origin $$TAG || echo "⚠️ Tag já existente ou erro ao criar."
# ===========================
# Teste
# ===========================
run:
@python3 src/manager/manager_main.py
# ===========================
# Limpeza
# ===========================
clean-local:
@echo "[CLEAN] Removendo diretórios temporários..."
rm -rf $(BUILD_DIR)
find $(DIST_DIR) -type f ! -path "$(DIST_DIR)/releases/*" -delete
@echo "[✔] Limpeza concluída (releases preservadas)"