Skip to content

Build Country.mmdb #113

Build Country.mmdb

Build Country.mmdb #113

Workflow file for this run

name: Build Country.mmdb
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 4"
push:
branches:
- master
paths-ignore:
- ".gitignore"
- "config-example.json"
- "LICENSE"
- "README.md"
- ".github/dependabot.yml"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x.y
uses: actions/setup-go@v4
with:
go-version: ^1.19
- name: Set variables
run: |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
shell: bash
- name: Checkout codebase
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch external data
run: ./external.sh
- name: Build
run: |
go run .
- name: Verify mmdb files
run: |
cd ./output/maxmind || exit 1
go install -v github.com/maxmind/mmdbverify@latest
for name in $(ls *.mmdb); do
$(go env GOPATH)/bin/mmdbverify -file ${name}
done
- name: Generate sha256 checksum for mmdb files
run: |
cd ./output/maxmind || exit 1
for name in $(ls *.mmdb); do
sha256sum ${name} > ./${name}.sha256sum
done
- name: Move files to publish directory
run: |
mkdir -p publish
mv ./output/maxmind/*.mmdb ./output/maxmind/*.sha256sum ./output/clash/ipcidr/*.txt ./output/text ./publish/
- name: Git push assets to "release" branch
run: |
cd publish || exit 1
git init
git config --local user.name "mcha0"
git config --local user.email "[email protected]"
git checkout -b release
git add -A
git commit -m "${{ env.RELEASE_NAME }}"
git remote add geoip "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f -u geoip release
- name: Purge jsdelivr CDN
run: |
cd publish || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
done
- name: Upload files to GitHub release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ./publish/*
tag: ${{ env.TAG_NAME }}