Build V2Ray rules dat files #197
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 V2Ray rules dat files | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 07 * * *" | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- "**/README.md" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set variables | |
run: | | |
echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "AD_DOMAINS_URL=https://bitbucket.org/dotwho/rule/raw/release/category/category-ads-all" >> $GITHUB_ENV | |
echo "COPILOT_URL=https://bitbucket.org/dotwho/rule/raw/release/category/copilot" >> $GITHUB_ENV | |
echo "APPLE_PROXY_URL=https://bitbucket.org/dotwho/rule/raw/release/category/apple-proxy" >> $GITHUB_ENV | |
echo "GAME_DOWNLOAD_URL=https://bitbucket.org/dotwho/rule/raw/release/category/game-download" >> $GITHUB_ENV | |
echo "GLOBAL_PROXY=https://bitbucket.org/dotwho/rule/raw/release/category/geolocation-!cn" >> $GITHUB_ENV | |
shell: bash | |
- name: Checkout Loyalsoldier/domain-list-custom | |
uses: actions/checkout@v4 | |
with: | |
repository: Loyalsoldier/domain-list-custom | |
path: custom | |
- name: Checkout v2fly/domain-list-community | |
uses: actions/checkout@v4 | |
with: | |
repository: v2fly/domain-list-community | |
path: community | |
- name: Checkout cokebar/gfwlist2dnsmasq | |
uses: actions/checkout@v4 | |
with: | |
repository: cokebar/gfwlist2dnsmasq | |
path: gfwlist2dnsmasq | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: ./custom/go.mod | |
cache-dependency-path: ./custom/go.sum | |
- name: Get and add reject domains into temp-reject.txt file | |
run: | | |
curl -sSL $AD_DOMAINS_URL > temp-reject.txt | |
cat temp-reject.txt | sort --ignore-case -u | perl -ne '/^((?=^.{1,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})*)/ && print "$1\n"' > ./community/data/category-ads-all | |
cat temp-reject.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > reject-tld-list.txt | |
- name: Reserve `full`, `regexp` and `keyword` type of rules from custom lists to "reserve" files | |
run: | | |
curl -sSL ${GLOBAL_PROXY} > temp-proxy.txt | |
cat temp-proxy.txt > ./community/data/geolocation-\!cn | |
cat temp-proxy.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > proxy-tld-list.txt | |
- name: Add `full`, `regexp` and `keyword` type of rules back into "cn", "geolocation-!cn" and "category-ads-all" list | |
run: | | |
rm -rf ./community/data/category-ads | |
cp ./community/data/geolocation-\!cn proxy-list.txt | |
cp ./community/data/category-ads-all reject-list.txt | |
- name: Add new category to community lists | |
run: | | |
curl -sSL $COPILOT_URL > ./community/data/copilot | |
curl -sSL $APPLE_PROXY_URL > ./community/data/apple-proxy | |
curl -sSL $GAME_DOWNLOAD_URL > ./community/data/game-download | |
echo "include:copilot" >> ./community/data/bing | |
- name: Build geosite.dat file | |
run: | | |
cd custom || exit 1 | |
go run ./ --datapath=../community/data | |
- name: Move and zip files and generate sha256 hash | |
run: | | |
install -Dp ./custom/publish/geosite.dat ./publish/geosite.dat | |
install -p {proxy,reject}-tld-list.txt ./publish/ | |
install -p {proxy,reject}-list.txt ./publish/ | |
zip rules.zip ./community/data/* | |
cp rules.zip ./publish/ | |
cd ./publish || exit 1 | |
sha256sum geosite.dat > geosite.dat.sha256sum | |
- name: Release and upload assets | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
release_name: ${{ env.RELEASE_NAME }} | |
tag: ${{ env.TAG_NAME }} | |
file_glob: true | |
file: ./publish/* | |
- name: Git push assets to "release" branch | |
run: | | |
cd publish || exit 1 | |
git init | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git checkout -b release | |
git add . | |
git commit -m "${{ env.RELEASE_NAME }}" | |
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
git push -f -u origin release |