Build #24269
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "*/60 * * * *" | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "**/README.md" | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Prepare Workstation | |
shell: bash | |
run: | | |
git config --global init.defaultBranch main | |
curl -L https://github.com/zhanhb/cidr-merger/releases/download/v1.1.3/cidr-merger-linux-amd64 -o cidr-merger | |
chmod +x ./cidr-merger | |
mkdir -p ./publish | |
- name: Get Upstream | |
run: | | |
curl -L https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt | sed '/^\#/d' > ipv4-chnroutes.txt | |
curl -L https://raw.githubusercontent.com/metowolf/iplist/master/data/special/china.txt -o ipv4-metowolf.txt | |
curl -L https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china.txt -o ipv4-china.txt | |
curl -L https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt -o ipv4-china_ip_list.txt | |
curl -L https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/googlecn.txt -o ipv4-googlecn.txt | |
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > ipv4-apnic.txt | |
# get ipv4 data | |
cat ./ipv4*.txt | ./cidr-merger -s > ./ipv4.txt | |
curl -L https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china6.txt -o ipv6-china6.txt | |
curl -L https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/googlecn6.txt -o ipv6-googlecn6.txt | |
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep '|CN|ipv6|' | cut -d'|' -f'4,5' | tr '|' '/' > ipv6-apnic.txt | |
# get ipv6 data | |
cat ./ipv6*.txt | ./cidr-merger -s > ./ipv6.txt | |
# get maxmind data | |
curl -L https://raw.githubusercontent.com/v2fly/geoip/release/text/cn.txt -o maxmind-cn.txt | |
# get db-ip data | |
export curdate=$(date +%Y-%m) | |
curl -L "https://download.db-ip.com/free/dbip-country-lite-$curdate.csv.gz" -o dbip.gz | |
gzip -d dbip.gz | |
cat dbip | grep "CN" | sed 's/...$//' | sed 's/\,/\-/g' | ./cidr-merger -s > dbip.txt | |
- name: Create Basefile | |
run: | | |
# create base file | |
cat ipv4.txt ipv6.txt maxmind-cn.txt dbip.txt | ./cidr-merger -s > publish/ip.txt | |
- name: Split to IPv4 and IPv6 | |
run: | | |
# create ipv4 file | |
cat publish/ip.txt | perl -ne '/^(\d{1,3}(\.\d{1,3}){3}\/\d{1,2})/ && print "$1\n"' > publish/ipv4.txt | |
# create ipv6 file | |
cat publish/ip.txt | grep ":" | perl -ne '/(.+\/\d+)/ && print "$1\n"' > publish/ipv6.txt | |
- name: Git push assets to "release" branch | |
run: | | |
cd publish || exit 1 | |
git init | |
git config --local user.name "carrnot" | |
git config --local user.email "85714711+carrnot@users.noreply.github.com" | |
git checkout -b release | |
git add --all | |
git commit -m "sync" | |
git remote add china-ip-list "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
git push -f china-ip-list release |