46 lines
1.4 KiB
Makefile
46 lines
1.4 KiB
Makefile
# 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)"
|