Skip to content

Daily Build

Daily Build #825

Workflow file for this run

name: Daily Build
on:
workflow_dispatch:
schedule:
- cron: 0 19 * * 0,2,4
# push:
# branches:
# - master
# paths:
# - '.github/start'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- name: Set Golang environment
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Set env 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 "CUR_WEEK=$(date +%a)" >> $GITHUB_ENV
- name: Clone mmdb_china_ip_list
env:
REPO_URL: https://github.com/alecthw/mmdb_china_ip_list
REPO_BRANCH: master
run: git clone -b $REPO_BRANCH $REPO_URL
- name: Download GeoLite2-Country
env:
LICENSE_KEY: ${{ secrets.MAXMIND_GEOLITE2_LICENSE }}
run: |
cd mmdb_china_ip_list
curl -LR "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${LICENSE_KEY}&suffix=tar.gz" -o GeoLite2-Country.tar.gz
tar xzvf GeoLite2-Country.tar.gz
rm -f GeoLite2-Country.tar.gz
mv GeoLite2-Country_*/GeoLite2-Country.mmdb ./
rm -rf GeoLite2-Country_*
- name: Download GeoLite2-Country-CSV
env:
LICENSE_KEY: ${{ secrets.MAXMIND_GEOLITE2_LICENSE }}
run: |
cd mmdb_china_ip_list
curl -LR "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=${LICENSE_KEY}&suffix=zip" -o GeoLite2-Country-CSV.zip
unzip GeoLite2-Country-CSV.zip
rm -f GeoLite2-Country-CSV.zip
mv GeoLite2-Country-CSV_* mindmax
- name: Download china_ip_list
run: |
cd mmdb_china_ip_list
curl -LR -o china_ip_list.txt "https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt"
- name: Download chunzhen cn list
run: |
cd mmdb_china_ip_list
curl -LR -o chunzhen_cn.txt "https://raw.githubusercontent.com/metowolf/iplist/master/data/special/china.txt"
- name: Download calng ip list
run: |
cd mmdb_china_ip_list
curl -LR -o all_cn.txt "https://ispip.clang.cn/all_cn.txt"
curl -LR -o all_cn_ipv6.txt "https://ispip.clang.cn/all_cn_ipv6.txt"
- name: Download china-operator-ip list
run: |
cd mmdb_china_ip_list
curl -LR -o china_operator_ipv4.txt "https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china.txt"
curl -LR -o china_operator_ipv6.txt "https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china6.txt"
- name: Download china cloud ip
run: |
cd mmdb_china_ip_list
curl -LR -o cloud_cn.list "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Cloud/CloudCN/CloudCN.list"
- name: Build mmdb generator
run: |
cd mmdb_china_ip_list
go build -o mmdb_gen
- name: Generate mmdb file
run: |
cd mmdb_china_ip_list
./mmdb_gen -new
- name: Generate version file
run: |
cd mmdb_china_ip_list
echo ${{ env.TAG_NAME }} > version
- name: Prepare publish
run: |
mkdir -p publish/lite
cp -af mmdb_china_ip_list/version publish/version
cp -af mmdb_china_ip_list/china_ip_list.mmdb publish/Country.mmdb
cp -af mmdb_china_ip_list/lite_china_ip_list.mmdb publish/lite/Country.mmdb
- name: Push to release branch
run: |
cd publish
git init
git config --local user.name "${{ github.actor }}"
git config --local user.email "${{ github.actor }}@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
cp -af lite/Country.mmdb Country-lite.mmdb
- name: Upload to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SFTP_HOST }}
port: ${{ secrets.SFTP_PORT }}
username: ${{ secrets.SFTP_USERNAME }}
password: ${{ secrets.SFTP_PASSWORD }}
source: "publish/Country.mmdb,publish/version,publish/lite/Country.mmdb"
target: "/www/mmdb"
rm: true
strip_components: 1
- name: Release and upload
if: env.CUR_WEEK == 'Mon'
uses: softprops/action-gh-release@v2
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
draft: false
prerelease: false
files: |
./publish/version
./publish/Country.mmdb
./publish/Country-lite.mmdb