Skip to content

Release

Release #55

Workflow file for this run

name: Release
on:
schedule:
- cron: '0 0 * * Mon'
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/bootmortis/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: 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
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 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: 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 }}