EC-21: FEAT: Added Makefile for better publishing

Refers: Evercatch/evercatch-board#21
This commit is contained in:
2026-02-20 10:34:02 +00:00
parent a34cad0a00
commit b9da7561c6
2 changed files with 48 additions and 0 deletions

45
Makefile Normal file
View File

@@ -0,0 +1,45 @@
# Makefile for publishing Go modules to Gitea Package Registry
# --- Configuration ---
# Set this to the exact module path from your go.mod file.
MODULE_PATH := git.psmattas.com/evercatch/evercatch-go
GITEA_OWNER := Evercatch
GITEA_REGISTRY_URL := https://git.psmattas.com/api/packages/$(GITEA_OWNER)/go/upload
# --- Variables (do not edit) ---
# Automatically gets the latest git tag (e.g., v0.0.2)
VERSION := $(shell git describe --tags --abbrev=0)
ZIP_FILENAME := $(VERSION).zip
# Reads the Gitea token from your environment.
# Must be run as: GITEA_TOKEN=... make publish
TOKEN := ${GITEA_TOKEN}
# --- Commands ---
# This is a special directive to tell Make that these are command names, not files.
.PHONY: all publish package clean
all: publish
# packages the module into a correctly structured zip file.
package:
@echo "📦 Packaging module $(MODULE_PATH) version $(VERSION)..."
@git archive --format=zip \
--prefix="$(MODULE_PATH)@$(VERSION)/" \
-o "$(ZIP_FILENAME)" \
"$(VERSION)"
@echo "✅ Successfully created $(ZIP_FILENAME)"
# publishes the packaged zip file to the Gitea registry.
publish: package
@echo "⬆️ Uploading $(ZIP_FILENAME) to Gitea..."
@curl --user "$(GITEA_OWNER):$(TOKEN)" \
--upload-file "$(ZIP_FILENAME)" \
"$(GITEA_REGISTRY_URL)"
@echo "\n✅ Successfully published to Gitea."
@make clean
# removes the generated zip file.
clean:
@echo "🧹 Cleaning up..."
@rm -f "$(ZIP_FILENAME)"