From b9da7561c696f0c509a7228888d44d61cef34689 Mon Sep 17 00:00:00 2001 From: default Date: Fri, 20 Feb 2026 10:34:02 +0000 Subject: [PATCH] EC-21: FEAT: Added Makefile for better publishing Refers: Evercatch/evercatch-board#21 --- .gitignore | 3 +++ Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 0be5d15..026481a 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ coverage/ *.p12 *.pfx secrets/ + +# Build +*.zip diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e139d7 --- /dev/null +++ b/Makefile @@ -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)"