use Makefile
This commit is contained in:
parent
ef10f37224
commit
d8e8e891dc
@ -6,16 +6,16 @@ steps:
|
|||||||
- name: generate
|
- name: generate
|
||||||
image: golang:1.19-alpine
|
image: golang:1.19-alpine
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache curl grep libidn sipcalc gawk git patch bash python3
|
- apk add --no-cache make curl grep libidn sipcalc gawk git patch bash python3
|
||||||
- bash generate.sh
|
- make all
|
||||||
- name: create release tag
|
- name: create release tag
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
environment:
|
environment:
|
||||||
GITEA_API_KEY:
|
GITEA_API_KEY:
|
||||||
from_secret: gitea_api_key
|
from_secret: gitea_api_key
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache curl
|
- apk add --no-cache make curl
|
||||||
- sh tag.sh
|
- make release
|
||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
|
54
Makefile
Normal file
54
Makefile
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
SHELL = /bin/bash -o pipefail
|
||||||
|
export PATH := $(shell go env GOPATH)/bin:$(PATH)
|
||||||
|
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
|
BUILD_DIR=$(ROOT_DIR)/.build
|
||||||
|
AZ_DIR=$(ROOT_DIR)/antizapret-pac-generator-light
|
||||||
|
GEOIP_DIR=$(ROOT_DIR)/geoip
|
||||||
|
GEOSITE_DIR=$(ROOT_DIR)/domain-list-community
|
||||||
|
DATA_DIR=$(ROOT_DIR)/data
|
||||||
|
|
||||||
|
.PHONY: all submodules az geoip geosite release
|
||||||
|
|
||||||
|
all: submodules az geoip geosite
|
||||||
|
@echo Done.
|
||||||
|
|
||||||
|
submodules:
|
||||||
|
@git submodule update --init --recursive
|
||||||
|
|
||||||
|
builddir:
|
||||||
|
ifeq (,$(wildcard $(BUILD_DIR)))
|
||||||
|
@mkdir -p $(BUILD_DIR)
|
||||||
|
endif
|
||||||
|
|
||||||
|
az: builddir
|
||||||
|
@bash -c 'set -euo pipefail; \
|
||||||
|
cd $(AZ_DIR) && \
|
||||||
|
patch --forward < $(DATA_DIR)/az-cyrillic-idn-fix.patch || true && \
|
||||||
|
./update.sh && \
|
||||||
|
./parse.sh'
|
||||||
|
|
||||||
|
geoip: builddir
|
||||||
|
@cat $(DATA_DIR)/geoip-generator-config.json > $(GEOIP_DIR)/config.json
|
||||||
|
@mkdir -p $(GEOIP_DIR)/data
|
||||||
|
@cp $(AZ_DIR)/result/iplist_all.txt $(GEOIP_DIR)/data/ru-blocked-ips-all
|
||||||
|
@cp $(AZ_DIR)/result/iplist_blockedbyip.txt $(GEOIP_DIR)/data/ru-blocked-ips-directblock
|
||||||
|
@cp $(AZ_DIR)/result/iplist_blockedbyip_noid2971.txt $(GEOIP_DIR)/data/ru-blocked-ips-noid2971
|
||||||
|
ifeq (,$(wildcard $(GEOIP_DIR)/geoip-src.dat))
|
||||||
|
@curl -fsSL https://github.com/v2fly/geoip/releases/latest/download/geoip.dat -o $(GEOIP_DIR)/geoip-src.dat
|
||||||
|
endif
|
||||||
|
@cd $(GEOIP_DIR) && go run ./
|
||||||
|
@mv $(GEOIP_DIR)/output/dat/geoip.dat $(BUILD_DIR)/geoip.dat
|
||||||
|
|
||||||
|
geosite: builddir
|
||||||
|
@cp $(AZ_DIR)/result/hostlist_zones.txt $(GEOSITE_DIR)/data/category-ru-blocked-zones
|
||||||
|
@cp $(AZ_DIR)/result/hostlist_original.txt $(GEOSITE_DIR)/data/category-ru-blocked-domains
|
||||||
|
@cd $(GEOSITE_DIR) && go run ./ --outputdir=$(BUILD_DIR) --outputname=geosite.dat
|
||||||
|
|
||||||
|
VERSION := $(shell date +%Y%m%d%H%M%S)
|
||||||
|
release:
|
||||||
|
@echo Tagging as $(VERSION)
|
||||||
|
@curl -X POST \
|
||||||
|
https://gitea.neur0tx.site/api/v1/repos/xray-addons/geoip-geosite-with-ru-blocklist/tags?token=${GITEA_API_KEY} \
|
||||||
|
-H "Accept: application/json" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"message": "$(VERSION)": daily release from ci","tag_name": "$(VERSION)","target": "master"}'
|
35
generate.sh
35
generate.sh
@ -1,35 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euxo pipefail
|
|
||||||
git submodule update --init --recursive
|
|
||||||
|
|
||||||
workdir=$(dirname "$0")
|
|
||||||
build_dir="$workdir/.build"
|
|
||||||
path_az=$(realpath antizapret-pac-generator-light)
|
|
||||||
path_geoip=$(realpath geoip)
|
|
||||||
path_geosite=$(realpath domain-list-community)
|
|
||||||
path_data=$(realpath data)
|
|
||||||
|
|
||||||
# Initialize build dir
|
|
||||||
mkdir -p "$build_dir"
|
|
||||||
|
|
||||||
# Initialize antizapret data
|
|
||||||
cd "$path_az"
|
|
||||||
patch --forward < "$path_data/az-cyrillic-idn-fix.patch" || true
|
|
||||||
bash update.sh
|
|
||||||
bash parse.sh
|
|
||||||
cd "$workdir"
|
|
||||||
|
|
||||||
# Generate geoip.dat
|
|
||||||
cat "$path_data/geoip-generator-config.json" > "$path_geoip/config.json"
|
|
||||||
mkdir -p "$path_geoip/data"
|
|
||||||
cp "$path_az/result/iplist_all.txt" "$path_geoip/data/ru-blocked-ips-all"
|
|
||||||
cp "$path_az/result/iplist_blockedbyip.txt" "$path_geoip/data/ru-blocked-ips-directblock"
|
|
||||||
cp "$path_az/result/iplist_blockedbyip_noid2971.txt" "$path_geoip/data/ru-blocked-ips-noid2971"
|
|
||||||
([ ! -f "$path_geoip/geoip-src.dat" ] && curl -fsSL https://github.com/v2fly/geoip/releases/latest/download/geoip.dat -o "$path_geoip/geoip-src.dat")
|
|
||||||
cd "$path_geoip" && go run ./ && cd "$workdir"
|
|
||||||
mv "$path_geoip/output/dat/geoip.dat" "$build_dir/geoip.dat"
|
|
||||||
|
|
||||||
# Generate geosite.dat
|
|
||||||
cp "$path_az/result/hostlist_zones.txt" "$path_geosite/data/category-ru-blocked-zones"
|
|
||||||
cp "$path_az/result/hostlist_original.txt" "$path_geosite/data/category-ru-blocked-domains"
|
|
||||||
cd "$path_geosite" && go run ./ --outputdir="$build_dir" --outputname=geosite.dat && cd "$workdir"
|
|
12
tag.sh
12
tag.sh
@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -eux
|
|
||||||
export VERSION=`date +%Y%m%d%H%M%S`
|
|
||||||
curl -X 'POST' \
|
|
||||||
'https://gitea.neur0tx.site/api/v1/repos/xray-addons/geoip-geosite-with-ru-blocklist/tags?token='"$GITEA_API_KEY"'' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"message": "'"$VERSION"': daily release from ci",
|
|
||||||
"tag_name": "'"$VERSION"'",
|
|
||||||
"target": "master"
|
|
||||||
}'
|
|
Loading…
Reference in New Issue
Block a user