Skip to content

Build

Build #921

Workflow file for this run

name: Build
on:
push:
branches:
- main
paths-ignore:
- '**.md'
schedule:
- cron: '0 12 * * *'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.11'
cache: 'true'
- name: Install dependencies
run: pdm install
- name: Run tests
run: pdm run test
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.11'
cache: 'true'
- name: Set up Go
uses: actions/setup-go@v5
- name: Pull v2fly community domain list
uses: actions/checkout@v4
with:
repository: 'v2fly/domain-list-community'
path: 'domain-list-community'
- name: Pull Loyalsoldier's geosite tool
uses: actions/checkout@v4
with:
repository: 'Loyalsoldier/domain-list-custom'
path: 'tool_geosite'
- name: Install Loyalsoldier's geoip tool
run: go install github.com/Loyalsoldier/geoip@latest
- name: Build rulesets
run: pdm run build
- name: Download MaxMind GeoLite2 Country DB
env:
MAXMIND_KEY: ${{ secrets.MAXMIND_KEY }}
run: |
wget -O ./GeoLite2-Country.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${MAXMIND_KEY}&suffix=tar.gz"
tar xzvf ./GeoLite2-Country.tar.gz
cp ./GeoLite2-Country_*/GeoLite2-Country.mmdb ./
- name: Build Geosite DB
run: |
cd tool_geosite
go run ./ --datapath=../dists/geosite --outputpath=../dists --exportlists="" --togfwlist=""
- name: Build GeoIP DB
run: |
cat <<EOF > config.json
{
"input": [
{
"type": "private",
"action": "add"
},
{
"type": "maxmindMMDB",
"action": "add",
"args": {
"uri": "./GeoLite2-Country.mmdb"
}
},
{
"type": "cutter",
"action": "remove",
"args": {
"wantedList": ["cn"]
}
},
{
"type": "text",
"action": "add",
"args": {
"name": "cn",
"uri": "./dists/text/domestic_ip.txt",
"onlyIPType": "ipv4"
}
},
{
"type": "text",
"action": "add",
"args": {
"name": "cn",
"uri": "./dists/text/domestic_ip6.txt",
"onlyIPType": "ipv6"
}
}
],
"output": [
{
"type": "v2rayGeoIPDat",
"action": "output",
"args": {
"outputName": "geoip.dat",
"outputDir": "./dists"
}
},
{
"type": "maxmindMMDB",
"action": "output",
"args": {
"outputName": "geoip.mmdb",
"outputDir": "./dists",
"overwriteList": [
"cn",
"private"
]
}
}
]
}
EOF
geoip convert -c config.json
- name: Remove tmp files
run: |
rm -rf dists/geosite
rm dists/gfwlist.txt
- name: Build homepage
run: |
python build_homepage.py
cat <<EOF > dists/robots.txt
User-agent: *
Disallow: /*.txt
Disallow: /*.yaml
Disallow: /*.dat
Disallow: /*.mmdb
Disallow: /*.json
EOF
cat <<EOF > dists/404.html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>404 - xkww3n's Rules</title>
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<main>
<h1>xkww3n's Rules</h1>
<p>由 <a href="https://www.xkww3n.cyou">xkww3n</a> 维护的,面向多个代理软件的规则集</p>
<p>支持: Surge、Clash (Premium / Meta)、Stash、Choc、Quantumult (X)、Loon、Shadowrocket、LanceX 等</p>
<p>
项目源代码托管于 <a href="https://github.com/xkww3n/Rules/">GitHub</a>,
以 <a href="https://github.com/xkww3n/Rules/blob/main/LICENSE" target="_blank">MIT</a> 协议授权
</p>
<hr>
<p>资源不存在</p>
</main>
</body>
</html>
EOF
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2e54d1245681bc04eaa33ed5d68bdfa7
command: pages deploy dists --project-name=xkww3n-rules