meta-rules-dat/.github/workflows/build.yml
2019-12-15 13:09:49 +08:00

135 lines
4.6 KiB
YAML

name: Build v2ray rules dat files
on:
schedule:
- cron: "0 19 * * *"
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Set GOPATH
run: |
echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)"
echo "::set-env name=GREEN::\033[0;32m"
echo "::set-env name=NC::\033[0m"
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=GFWLIST_URL::https://cokebar.github.io/gfwlist2dnsmasq/gfwlist_domain.txt"
echo "::set-env name=Profiles_URL::https://raw.githubusercontent.com/ConnersHua/Profiles/master/Shadow/Pro.conf"
echo "::set-env name=CHINA_DOMAINS_URL::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf"
echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin"
shell: bash
- name: Get GeoLite2
run: |
curl -sSL -O https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.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 gfwlist into geolocation-!cn
run: |
cd $GOPATH/src/$GEOSITE_REPO/data
curl -sSL $GFWLIST_URL > gfwlist
echo "include:gfwlist" >> geolocation-\!cn
- name: Get and add proxy domains from @ConnersHua/Profiles into geolocation-!cn
run: |
cd $GOPATH/src/$GEOSITE_REPO/data
curl -sSL $Profiles_URL | awk '/^DOMAIN.+PROXY/' | cut -d ',' -f 2 > profileproxy
echo "include:profileproxy" >> geolocation-\!cn
- name: Get and add direct domains from @ConnersHua/Profiles into cn
run: |
cd $GOPATH/src/$GEOSITE_REPO/data
curl -sSL $Profiles_URL | awk '/^DOMAIN.+DIRECT/' | cut -d ',' -f 2 > profiledirect
echo "include:profiledirect" >> cn
- name: Get and add chinalist into cn
run: |
cd $GOPATH/src/$GEOSITE_REPO/data
curl -sSL $CHINA_DOMAINS_URL | awk -F '/' '{print $2}' > chinalist
echo "include:chinalist" >> cn
- name: Get and add reject domains from @ConnersHua/Profiles into category-ads-all
run: |
cd $GOPATH/src/$GEOSITE_REPO/data
curl -sSL $Profiles_URL | awk '/^DOMAIN.+REJECT/' | cut -d ',' -f 2 > profilereject
echo "include:profilereject" >> category-ads-all
- name: Build geosite.dat file
run: |
domain-list-community
mv ./dlc.dat ./publish/geosite.dat
- name: List above process results
run: |
echo ">>>>>>>>>>>>>>>>>>>>>>>>"
echo "list files in data folder"
ls -lah $GOPATH/src/$GEOSITE_REPO/data
echo ">>>>>>>>>>>>>>>>>>>>>>>>"
echo "list last 10 lines of cn file"
tail -n 10 $GOPATH/src/$GEOSITE_REPO/data/cn
echo ">>>>>>>>>>>>>>>>>>>>>>>>"
echo "list last 10 lines of geolocation-!cn file"
tail -n 10 $GOPATH/src/$GEOSITE_REPO/data/geolocation-\!cn
echo ">>>>>>>>>>>>>>>>>>>>>>>>"
echo "list last 10 lines of category-ads-all file"
tail -n 10 $GOPATH/src/$GEOSITE_REPO/data/category-ads-all
echo ">>>>>>>>>>>>>>>>>>>>>>>>"
echo "list files in publish folder"
ls -lah ./publish
echo ">>>>>>>>>>>>>>>>>>>>>>>>"
echo -e "${GREEN}完成啦!🌈${NC}"
- name: Set release 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)"
- name: Release dat files
uses: Ricky-Hao/action-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET_PATH: publish
- name: Upload dat files
uses: actions/upload-artifact@master
if: success()
with:
name: dat_files
path: publish