GeoLite2 databases from MaxMind
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.6 KiB

name: Publish
on:
workflow_dispatch:
schedule:
- cron: 0 0 * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download
run: |
URI="https://download.maxmind.com/app/geoip_download?license_key=${{ secrets.LICENSE_KEY }}&suffix=tar.gz&edition_id=GeoLite2-"
TAG=$(curl -sI "${URI}ASN" | grep -i ^Content-Disposition | grep -oP '[0-9]{8}')
LOCAL_TAG=$(git tag | grep -P '[0-9]{8}' | sort | tail -n1)
echo "${LOCAL_TAG} -> ${TAG}"
[ "${TAG}" == "${LOCAL_TAG}" ] && echo "No need to update, bye!" && exit 1
echo -e "| File | Size | Date | SHA1 |\n| :-: | :-: | :-: | :-: |" > info
mkdir dist && echo "TAG_NAME=${TAG}" >> $GITHUB_ENV
for name in ASN City Country; do
wget "${URI}${name}" -qO - | tar xzf -
mv GeoLite2-*/*.mmdb dist/${name}.mmdb
SIZE=$(du -b dist/${name}.mmdb | awk '{print $1}')
HASH=$(sha1sum dist/${name}.mmdb | awk '{print $1}')
DATE=$(stat dist/${name}.mmdb | grep Modify | grep -oP '[0-9]{4}(-[0-9]{2}){2} ([0-9]{2}:){2}[0-9]{2}')
echo "| ${name}.mmdb | ${SIZE} | \`${DATE} UTC\` | \`${HASH}\` |" >> info
done
cd dist && sha1sum *.mmdb > sha1sums.txt
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/*
tag_name: ${{ env.TAG_NAME }}
body_path: ${{ github.workspace }}/info