diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 0d70dfa..ea1f56e 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -10,37 +10,16 @@ on: jobs: build: runs-on: ubuntu-latest - env: - PKG: ${{ github.event.inputs.package }} steps: - uses: actions/checkout@v4 - - name: Read version + - name: Build and publish + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | - echo "VERSION=$(cat ${PKG}/VERSION | tr -d '[:space:]')" >> $GITHUB_ENV - - - name: Download upstream - run: | - cd ${PKG} - bash scripts/download.sh "$VERSION" - - - name: Build deb - run: | - docker run --rm \ - -v "$PWD/${PKG}:/work" \ - -w /work \ - -e VERSION="$VERSION" \ - goreleaser/nfpm package \ - --config nfpm.yaml \ - --target /work \ - --packager deb - - - name: Publish - run: | - DEB=$(ls ${PKG}/*.deb | head -1) - HTTP_CODE=$(curl -s -o /tmp/resp.txt -w "%{http_code}" \ - --user "andrew:${{ secrets.GITEA_TOKEN }}" \ - --upload-file "$DEB" \ - "https://git.nakolenke.org/api/packages/nakolenke-pub/debian/pool/trixie/main/upload") - cat /tmp/resp.txt - [ "$HTTP_CODE" = "201" ] || exit 1 + make -C ${{ github.event.inputs.package }} \ + GITEA_USER=andrew \ + GITEA_URL=https://git.nakolenke.org \ + GITEA_ORG=nakolenke-pub \ + SUITE=trixie \ + package publish diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..617c7d1 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +NFPM= docker run --rm -v $(PWD)/$(PORTNAME):/work -w /work -e VERSION=$(VERSION) goreleaser/nfpm +DISTDIR= $(PORTNAME)/dist +FETCH= wget -q + +all: fetch build package + +fetch: + @echo ">>> Fetching $(DISTFILE)" + @$(FETCH) "$(MASTER_SITE)/$(DISTFILE)" -O /tmp/$(DISTFILE) + @mkdir -p $(DISTDIR) + @unzip -q /tmp/$(DISTFILE) -d $(DISTDIR)/ + @chmod +x $(DISTDIR)/v2ray + @rm /tmp/$(DISTFILE) + +build: + @echo ">>> Building $(PORTNAME)-$(VERSION).deb" + @$(NFPM) package --config nfpm.yaml --target /work --packager deb + +package: fetch build + +publish: + @echo ">>> Publishing $(PORTNAME)-$(VERSION)_amd64.deb" + @DEB=$$(ls $(PORTNAME)/*.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 $(PORTNAME)/dist $(PORTNAME)/*.deb + +.PHONY: all fetch build package publish clean diff --git a/v2ray/Makefile b/v2ray/Makefile new file mode 100644 index 0000000..f50028f --- /dev/null +++ b/v2ray/Makefile @@ -0,0 +1,7 @@ +PORTNAME= v2ray +VERSION!= cat VERSION +DISTNAME= v2ray-linux-64 +DISTFILE= $(DISTNAME).zip +MASTER_SITE= https://github.com/v2fly/v2ray-core/releases/download/v$(VERSION) + +.include "../Makefile"