Skip to content

Release

Release #110

Workflow file for this run

name: Release
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
# inputs:
# force_update:
# description: 'Force update'
# required: false
# default: 'false'
jobs:
crawl:
name: Crawl Domains
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.6'
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.19
cache: false
- name: Env
run: |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo apt update
sudo apt install libxml2-dev libxslt-dev -y
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run python program
run: |
python src/main.py
- name: Check result files
run: |
total=$(wc -l output/domains.txt | awk 'END {print $1}')
# old=$(curl -sSL --connect-timeout 5 -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/MasterKia/iran-hosted-domains/releases/latest | grep "body" | cut -d\" -f4 | cut -d " " -f1)
# echo "total $total"
# echo "old $old"
# if [[ ${{ github.event.inputs.force_update || 'false' }} == 'true' || $total -ne $old ]]; then
# echo "SHOULD_UPDATE=true" >> $GITHUB_ENV
# echo "Should Update"
# fi
echo "TOTAL_DOMAINS=$total" >> $GITHUB_ENV
- name: Get active domains
run: |
curl -sSL https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/redundant/redundant-domains.txt > redundant-domains.txt
comm -23 output/other_domains.txt redundant-domains.txt > output/active-domains.txt
- name: Build .dat file
# if: ${{ env.SHOULD_UPDATE }}
run: |
git clone https://github.com/v2fly/domain-list-community
rm -rf domain-list-community/data/*
mv output/ir_domains.txt domain-list-community/data/ir
mv output/other_domains.txt domain-list-community/data/other
cp src/data/tld_ir.txt domain-list-community/data/tld-ir
cp src/data/all.txt domain-list-community/data/all
mv output/ads.txt domain-list-community/data/ads
cd domain-list-community
go run ./ --outputdir=../output
cd ../output
mv dlc.dat iran.dat
- name: Build lite .dat file
# if: ${{ env.SHOULD_UPDATE }}
run: |
mv output/active-domains.txt domain-list-community/data/other
cd domain-list-community
go run ./ --outputdir=../output
cd ../output
mv dlc.dat iran-lite.dat
- name: Build sing-box .db file
# if: ${{ env.SHOULD_UPDATE }}
run: |
git clone https://github.com/bootmortis/sing-geosite
cp output/iran.dat sing-geosite/data/iran.dat
cd sing-geosite
go run -v .
mv iran-geosite.db ../output/iran-geosite.db
- name: Build sing-box lite .db file
# if: ${{ env.SHOULD_UPDATE }}
run: |
cp output/iran-lite.dat sing-geosite/data/iran.dat
cd sing-geosite
go run -v .
mv iran-geosite.db ../output/iran-geosite-lite.db
- name: Calculate checksum
# if: ${{ env.SHOULD_UPDATE }}
run: |
cd output
for file in *; do
sha256sum $file > $file.sha256
done
- name: Upload result as release
# if: ${{ env.SHOULD_UPDATE }}
uses: ncipollo/release-action@v1
with:
artifacts: "output/*.*"
body: "${{ env.TOTAL_DOMAINS }} Domains"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}