Skip to content

Build geoip.dat

Build geoip.dat #227

Workflow file for this run

name: Build geoip.dat
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 4"
push:
branches:
- master
paths-ignore:
- "README.md"
- ".gitignore"
- "LICENSE"
- "**/dependabot.yml"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- 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: Get GeoLite2
env:
LICENSE_KEY: ${{ secrets.MAXMIND_LICEHSE }}
run: |
curl -L "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* geolite2
- name: Build geoip.dat
run: |
go run ./
- name: Generate sha256 checksum for dat files
run: |
cd ./output/dat || exit 1
for name in $(ls *.dat); do
sha256sum ${name} > ./${name}.sha256sum
done
- name: Move files to publish directory
run: |
mkdir -p publish
mv ./output/dat/*.dat ./output/dat/*.sha256sum ./publish
cp -fpPR ./output/text ./publish
- name: Git push assets to "release" branch
run: |
cd publish || exit 1
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
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 geoip release
- name: Release and upload assets
run: |
gh release create ${{ env.TAG_NAME }} -t ${{ env.RELEASE_NAME }} \
./publish/geoip.dat \
./publish/geoip.dat.sha256sum \
./publish/geoip-only-cn-private.dat \
./publish/geoip-only-cn-private.dat.sha256sum \
./publish/cn.dat \
./publish/cn.dat.sha256sum \
./publish/private.dat \
./publish/private.dat.sha256sum
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}