name: Build v2ray rules dat files on: schedule: - cron: "0 22 * * *" push: branches: - master jobs: build: name: Build runs-on: ubuntu-latest steps: - name: Setup Go 1.13 uses: actions/setup-go@v1 with: go-version: 1.13 id: go - name: Set $GOPATH and more variables run: | echo "::set-env name=NAME::Released on $(date +%Y%m%d%H%M)" echo "::set-env name=TAG_NAME::$(date +%Y%m%d%H%M)" echo "::set-env name=GEOIP_REPO::github.com/v2ray/geoip" echo "::set-env name=GEOSITE_REPO::github.com/v2ray/domain-list-community" echo "::set-env name=CHINA_DOMAINS_URL::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf" echo "::set-env name=GOOGLE_DOMAINS_URL::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf" echo "::set-env name=APPLE_DOMAINS_URL::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf" echo "::set-env name=GFWLIST_DOMAINS_URL::https://cokebar.github.io/gfwlist2dnsmasq/gfwlist_domain.txt" echo "::set-env name=GREATFIRE_DOMAINS_URL::https://raw.githubusercontent.com/wongsyrone/domain-block-list/master/domains.txt" echo "::set-env name=PROFILES_URL::https://raw.githubusercontent.com/ConnersHua/Profiles/master/Shadow/Pro.conf" echo "::set-env name=GEQ1AN_RULES_APPLE_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/Apple.list" echo "::set-env name=GEQ1AN_RULES_MICROSOFT_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/Microsoft.list" echo "::set-env name=GEQ1AN_RULES_GLOBAL_MEDIA_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/GMedia.list" echo "::set-env name=GEQ1AN_RULES_OUTSIDE_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/Outside.list" echo "::set-env name=GEQ1AN_RULES_REJECT_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/AdBlock.list" echo "::set-env name=LHIE1_RULES_REJECT_URL::https://raw.githubusercontent.com/lhie1/Rules/master/Auto/REJECT.conf" echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)" echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin" shell: bash - name: Checkout branch named hidden of this repo uses: actions/checkout@v2 with: ref: hidden - name: Get GeoLite2 file run: | curl -L -o GeoLite2-Country-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=JvbzLLx7qBZT&suffix=zip" unzip GeoLite2-Country-CSV.zip rm -f GeoLite2-Country-CSV.zip mv GeoLite2* geoip - name: Generate geoip.dat file run: | go get -u -v -insecure $GEOIP_REPO geoip --country=./geoip/GeoLite2-Country-Locations-en.csv --ipv4=./geoip/GeoLite2-Country-Blocks-IPv4.csv --ipv6=./geoip/GeoLite2-Country-Blocks-IPv6.csv mkdir -p ./publish mv ./geoip.dat ./publish/ - name: Download geosite project run: | go get -u -v -insecure $GEOSITE_REPO - name: Get and add direct domains into temp-direct.txt file run: | curl -sSL $CHINA_DOMAINS_URL | awk -F '/' '{print $2}' > temp-direct.txt - name: Get and add proxy domains into temp-proxy.txt file run: | curl -sSL $GFWLIST_DOMAINS_URL > temp-proxy.txt curl -sSL $GREATFIRE_DOMAINS_URL >> temp-proxy.txt curl -sSL $GOOGLE_DOMAINS_URL | awk -F '/' '{print $2}' >> temp-proxy.txt curl -sSL $APPLE_DOMAINS_URL | awk -F '/' '{print $2}' >> temp-proxy.txt curl -sSL $PROFILES_URL | awk -F ',' '/^DOMAIN(,|\-SUFFIX,).+PROXY/ {print $2}' >> temp-proxy.txt curl -sSL $GEQ1AN_RULES_APPLE_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+Apple/ {print $2}' >> temp-proxy.txt curl -sSL $GEQ1AN_RULES_MICROSOFT_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+Microsoft/ {print $2}' >> temp-proxy.txt curl -sSL $GEQ1AN_RULES_GLOBAL_MEDIA_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+GMedia/ {print $2}' >> temp-proxy.txt curl -sSL $GEQ1AN_RULES_OUTSIDE_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+Outside/ {print $2}' >> temp-proxy.txt - name: Get and add reject domains into temp-reject.txt file run: | curl -sSL $PROFILES_URL | awk -F ',' '/^DOMAIN(,|\-SUFFIX,).+REJECT/ {print $2}' > temp-reject.txt curl -sSL $GEQ1AN_RULES_REJECT_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+AdBlock/ {print $2}' >> temp-reject.txt curl -sSL $LHIE1_RULES_REJECT_URL | awk -F ',' '/^DOMAIN(,|\-SUFFIX,).+REJECT/ {print $2}' >> temp-reject.txt - name: Add proxy and direct domains from "hidden" branch to appropriate temp files run: | cat proxy.txt >> temp-proxy.txt cat direct.txt >> temp-direct.txt - name: Remove repeated domains, sort domains and write domains to appropriate list run: | cat temp-proxy.txt | sort --ignore-case -u > proxy-sort.txt cat temp-direct.txt | sort --ignore-case -u > direct-sort.txt cat temp-reject.txt | sort --ignore-case -u > reject-sort.txt - name: Filter valid domains run: | cat proxy-sort.txt | awk '/^([a-zA-Z0-9-\_]+\.)+[a-zA-Z0-9-]+$/{print $0}' > $GOPATH/src/$GEOSITE_REPO/data/proxylist cat proxy-sort.txt | awk '!/^([a-zA-Z0-9-\_]+\.)+[a-zA-Z0-9-]+$/{print $0}' > proxy-filter.txt cat direct-sort.txt | awk '/^([a-zA-Z0-9-\_]+\.)+[a-zA-Z0-9-]+$/{print $0}' > $GOPATH/src/$GEOSITE_REPO/data/directlist cat direct-sort.txt | awk '!/^([a-zA-Z0-9-\_]+\.)+[a-zA-Z0-9-]+$/{print $0}' > direct-filter.txt cat reject-sort.txt | awk '/^([a-zA-Z0-9-\_]+\.)+[a-zA-Z0-9-]+$/{print $0}' > $GOPATH/src/$GEOSITE_REPO/data/rejectlist cat reject-sort.txt | awk '!/^([a-zA-Z0-9-\_]+\.)+[a-zA-Z0-9-]+$/{print $0}' > reject-filter.txt - name: Add list into appropriate category file run: | cd $GOPATH/src/$GEOSITE_REPO/data echo "include:proxylist" >> geolocation-\!cn echo "include:directlist" >> cn echo "include:rejectlist" >> category-ads-all - name: Build geosite.dat file run: | domain-list-community mv ./dlc.dat ./publish/geosite.dat mv ./*-filter.txt ./publish/ - name: Release dat files uses: Ricky-Hao/action-release@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ASSET_PATH: publish