Skip to content

Generate rule-set .srs fron .json #66

Generate rule-set .srs fron .json

Generate rule-set .srs fron .json #66

Workflow file for this run

name: Generate rule-set .srs fron .json
on:
schedule:
- cron: '0 */72 * * *' # Every three days
workflow_dispatch:
permissions:
contents: write
jobs:
generate_lists:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Pull Changes
run: git pull
- name: Set up Node.js (if required)
uses: actions/setup-node@v4
with:
node-version: '20' # Adjust if needed
- name: Install Dependencies
run: |
sudo apt update
sudo apt install -y curl wget git jq
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
- name: Generate srs
env:
NO_SKIP: true
run: |
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/torrent-clients.srs /home/runner/work/sb-rule-sets/sb-rule-sets/torrent-clients.json
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/ru-app-list.srs /home/runner/work/sb-rule-sets/sb-rule-sets/ru-app-list.json
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/unbanru-app-list.srs /home/runner/work/sb-rule-sets/sb-rule-sets/unbanru-app-list.json
- name: Generate srs discord-voice-ip-list
env:
NO_SKIP: true
run: |
wget -O discord-voice-ip-list.txt https://github.com/GhostRooter0953/discord-voice-ips/raw/master/voice_domains/discord-voice-ip-list
cat discord-voice-ip-list.txt | jq -R -s '{"version": 1,"rules": [{"ip_cidr": split("\n") | map(select(length > 0)) | map(. + "/32")}]}' > discord-voice-ip-list.json
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/discord-voice-ip-list.srs /home/runner/work/sb-rule-sets/sb-rule-sets/discord-voice-ip-list.json
rm discord-voice-ip-list.txt
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/discord-voice-ip-list.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/discord-voice-ip-list.json
- name: Generate srs no-russia-hosts
env:
NO_SKIP: true
run: |
wget -O no-russia-hosts.txt https://github.com/dartraiden/no-russia-hosts/raw/master/hosts.txt
sing-box rule-set convert --type adguard --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs no-russia-hosts.txt
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.json
rm no-russia-hosts.txt
jq '.rules[0] |= with_entries(if .key == "domain" then .key = "domain_suffix" else . end)' no-russia-hosts.json > temp.json && mv temp.json no-russia-hosts.json
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.json
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.json
- name: Download and Extract generate-geoip-geosite
run: |
cd /home/runner/work/sb-rule-sets/sb-rule-sets/
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/Dunamis4tw/generate-geoip-geosite/releases/latest | grep "generate-geoip-geosite.*linux-amd64.tar.gz" | grep "browser_download_url" | cut -d '"' -f 4)
ARCHIVE_NAME=${DOWNLOAD_URL##*/}
wget "$DOWNLOAD_URL"
tar -xf "$ARCHIVE_NAME"
rm "$ARCHIVE_NAME"
chmod +x generate-geoip-geosite
- name: Generate srs itdoginfo-allow-domains-inside-russia without .ua domain_suffix
env:
NO_SKIP: true
run: |
cd /home/runner/work/sb-rule-sets/sb-rule-sets/
cat << EOF > Russia-domains-inside.json
[
{
"url": "https://github.com/itdoginfo/allow-domains/raw/main/Russia/inside-raw.lst",
"contentType": "DefaultList",
"category": "itdoginfo_inside_russia"
}
]
EOF
./generate-geoip-geosite -s Russia-domains-inside.json -i ./ -o ./ --gen-rule-set-srs
mv ruleset-domain-itdoginfo_inside_russia.srs itdoginfo-inside-russia.srs
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.json
jq '.rules[0] |= with_entries(if .key == "domain" then .key = "domain_suffix" else . end)' itdoginfo-inside-russia.json > temp.json && mv temp.json itdoginfo-inside-russia.json
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.srs /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.json
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.json
- name: Download antifilter-community and generate sing-box json
env:
NO_SKIP: true
run: |
wget -O antifilter-community.lst https://community.antifilter.download/list/domains.lst && jq -R -s '{"version": 1, "rules": [{"domain_suffix": split("\n") | map(select(. != "" and . != null))}]}' antifilter-community.lst > antifilter-community.json
- name: Generate ru-bundle itdoginfo-inside-russia+no-russia-hosts+antifilter-community
env:
NO_SKIP: true
run: |
jq -s '{version: .[0].version, rules: [{domain_suffix: (.[0].rules[0].domain_suffix + .[1].rules[0].domain_suffix + .[2].rules[0].domain_suffix) | unique}]}' itdoginfo-inside-russia.json no-russia-hosts.json antifilter-community.json > ru-bundle.json
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.srs /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.json
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.json
jq -r '.rules[].domain_suffix[]' ru-bundle.json > ru-bundle.lst
- name: Delete generate-geoip-geosite tool + antifilter-community
run: |
rm -f /home/runner/work/sb-rule-sets/sb-rule-sets/generate-geoip-geosite
rm -f /home/runner/work/sb-rule-sets/sb-rule-sets/Russia-domains-inside.json
rm -f /home/runner/work/sb-rule-sets/sb-rule-sets/include-domain-itdoginfo_inside_russia.lst
rm antifilter-community.lst | rm antifilter-community.json
- name: Get current date
id: date
run: |
echo "DATE=$(TZ=Europe/Moscow date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Commit and Push Changes
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Action
author_email: [email protected]
message: 'Generating .srs rule-sets ${{ env.DATE }}'
push: true
cwd: .
default_author: github_actor
fetch: --tags --force
pathspec_error_handling: ignore
github_token: ${{ secrets.RULESET_TOKEN }}