diff --git a/v2ray/Makefile b/v2ray/Makefile index d113b05..825f624 100644 --- a/v2ray/Makefile +++ b/v2ray/Makefile @@ -1,6 +1,46 @@ -PORTNAME= v2ray -VERSION!= cat VERSION -DISTFILE= v2ray-linux-64.zip -MASTER_SITE= https://github.com/v2fly/v2ray-core/releases/download/v$(VERSION) +PORTNAME=v2ray +VERSION=$(shell cat VERSION) +DISTFILE=v2ray-linux-64.zip +MASTER_SITE=https://github.com/v2fly/v2ray-core/releases/download/v$(VERSION) +DISTDIR=dist -.include "../Makefile" +GITEA_USER?=andrew +GITEA_URL?=https://git.nakolenke.org +GITEA_ORG?=nakolenke-pub +SUITE?=trixie + +all: fetch build + +fetch: + @echo ">>> Fetching $(DISTFILE)" + @wget -q "$(MASTER_SITE)/$(DISTFILE)" -O /tmp/$(DISTFILE) + @mkdir -p $(DISTDIR) + @unzip -q /tmp/$(DISTFILE) -d $(DISTDIR)/ + @chmod +x $(DISTDIR)/$(PORTNAME) + @rm /tmp/$(DISTFILE) + +build: + @echo ">>> Building $(PORTNAME)-$(VERSION).deb" + @docker run --rm \ + -v $(CURDIR):/work \ + -w /work \ + -e VERSION=$(VERSION) \ + goreleaser/nfpm package \ + --config nfpm.yaml \ + --target /work \ + --packager deb + +publish: + @echo ">>> Publishing $(PORTNAME)-$(VERSION)" + @DEB=$$(ls *.deb | head -1) && \ + HTTP_CODE=$$(curl -s -o /tmp/resp.txt -w "%{http_code}" \ + --user "$(GITEA_USER):$(GITEA_TOKEN)" \ + --upload-file "$$DEB" \ + "$(GITEA_URL)/api/packages/$(GITEA_ORG)/debian/pool/$(SUITE)/main/upload") && \ + cat /tmp/resp.txt && \ + [ "$$HTTP_CODE" = "201" ] || exit 1 + +clean: + @rm -rf $(DISTDIR) *.deb + +.PHONY: all fetch build publish clean \ No newline at end of file