mirror of
https://github.com/wp-statistics/GeoLite2-City.git
synced 2025-12-29 14:12:24 +00:00
Compare commits
11 Commits
9784472bf3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b87c4ead44 | ||
|
|
2e8566bf9f | ||
|
|
30a42b6399 | ||
|
|
0c73944f33 | ||
|
|
82ff47b78f | ||
|
|
8e5721423c | ||
|
|
8de42b3b24 | ||
|
|
6d85063e73 | ||
|
|
f58c55a434 | ||
|
|
4e1f4c08a4 | ||
|
|
74b38eb6f3 |
22
.github/workflows/npm-publish.yml
vendored
22
.github/workflows/npm-publish.yml
vendored
@@ -1,22 +0,0 @@
|
|||||||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
||||||
|
|
||||||
name: Node.js Package
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 12
|
|
||||||
- run: npm install
|
|
||||||
- run: npm test
|
|
||||||
- uses: JS-DevTools/npm-publish@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
|
||||||
124
.github/workflows/update-database.yml
vendored
Normal file
124
.github/workflows/update-database.yml
vendored
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
name: Update GeoLite2-City Database
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Run every Tuesday and Friday at 06:00 UTC (MaxMind update days)
|
||||||
|
- cron: '0 6 * * 2,5'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
force_publish:
|
||||||
|
description: 'Force publish to npm even if no changes'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
id-token: write # Required for npm trusted publishing (OIDC)
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '24' # Node 24 includes npm 11.5.1+ required for OIDC
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|
||||||
|
- name: Download latest GeoLite2-City database
|
||||||
|
env:
|
||||||
|
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
|
||||||
|
run: |
|
||||||
|
echo "Downloading GeoLite2-City database..."
|
||||||
|
|
||||||
|
# Download the database
|
||||||
|
curl -fsSL -o GeoLite2-City.tar.gz \
|
||||||
|
"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${MAXMIND_LICENSE_KEY}&suffix=tar.gz"
|
||||||
|
|
||||||
|
# Check if download was successful
|
||||||
|
if [ ! -f GeoLite2-City.tar.gz ] || [ ! -s GeoLite2-City.tar.gz ]; then
|
||||||
|
echo "Download failed or file is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the mmdb file
|
||||||
|
tar -xzf GeoLite2-City.tar.gz
|
||||||
|
|
||||||
|
# Find and move the mmdb file
|
||||||
|
MMDB_FILE=$(find . -name "GeoLite2-City.mmdb" -type f)
|
||||||
|
if [ -z "$MMDB_FILE" ]; then
|
||||||
|
echo "Could not find GeoLite2-City.mmdb in archive"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv "$MMDB_FILE" ./GeoLite2-City.mmdb
|
||||||
|
|
||||||
|
# Compress with maximum compression
|
||||||
|
gzip -9 -f GeoLite2-City.mmdb
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
rm -rf GeoLite2-City.tar.gz GeoLite2-City_*/
|
||||||
|
|
||||||
|
echo "Database downloaded and compressed successfully"
|
||||||
|
ls -lh GeoLite2-City.mmdb.gz
|
||||||
|
|
||||||
|
- name: Check for changes
|
||||||
|
id: check_changes
|
||||||
|
run: |
|
||||||
|
FORCE="${{ inputs.force_publish }}"
|
||||||
|
if [ "$FORCE" == "true" ]; then
|
||||||
|
echo "Force publish requested"
|
||||||
|
echo "changed=true" >> $GITHUB_OUTPUT
|
||||||
|
elif git diff --quiet GeoLite2-City.mmdb.gz 2>/dev/null; then
|
||||||
|
echo "No changes detected"
|
||||||
|
echo "changed=false" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Changes detected"
|
||||||
|
echo "changed=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Update version and commit
|
||||||
|
if: steps.check_changes.outputs.changed == 'true'
|
||||||
|
run: |
|
||||||
|
# Bump patch version
|
||||||
|
npm version patch --no-git-tag-version
|
||||||
|
|
||||||
|
# Get new version
|
||||||
|
NEW_VERSION=$(node -p "require('./package.json').version")
|
||||||
|
echo "New version: $NEW_VERSION"
|
||||||
|
|
||||||
|
# Update README with current date
|
||||||
|
CURRENT_DATE=$(date +%Y-%m-%d)
|
||||||
|
sed -i "s/Last updated: .*/Last updated: ${CURRENT_DATE}/" README.md
|
||||||
|
|
||||||
|
# Configure git
|
||||||
|
git config --global user.name 'github-actions[bot]'
|
||||||
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||||
|
|
||||||
|
# Commit and push
|
||||||
|
git add .
|
||||||
|
git commit -m "Update GeoLite2-City database to v${NEW_VERSION} - ${CURRENT_DATE}"
|
||||||
|
git push
|
||||||
|
|
||||||
|
- name: Publish to npm
|
||||||
|
if: steps.check_changes.outputs.changed == 'true'
|
||||||
|
run: npm publish --provenance --access public
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
run: |
|
||||||
|
if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then
|
||||||
|
echo "### Database Updated Successfully" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- New version published to npm" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- CDN will be updated automatically via jsDelivr" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "### No Updates Required" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "The database is already up to date." >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
Binary file not shown.
128
README.md
128
README.md
@@ -1,19 +1,123 @@
|
|||||||
# GeoLite2-City Database via jsDelivr CDN
|
# GeoLite2-City - Free IP Geolocation Database
|
||||||
|
|
||||||
The GeoLite2-City database, provided by [MaxMind](https://www.maxmind.com/), is used for accurate geo-location information. It is an essential component of [WP Statistics](https://wordpress.org/plugins/wp-statistics/), a popular privacy-focused analytics solution for WordPress, enabling detailed insights into visitor locations.
|
[](https://www.npmjs.com/package/geolite2-city)
|
||||||
|
[](https://www.npmjs.com/package/geolite2-city)
|
||||||
|
[](https://creativecommons.org/licenses/by-sa/4.0/)
|
||||||
|
[](https://github.com/wp-statistics/GeoLite2-City)
|
||||||
|
|
||||||
### Database Maintenance & Update Schedule
|
Free MaxMind GeoLite2-City database for IP geolocation. Get city-level location data from any IP address. Automatically updated and served via jsDelivr CDN.
|
||||||
Since this database is integrated with the WP Statistics plugin, **we currently update the database twice per month** to maintain the accuracy and reliability of the geo-location data.
|
|
||||||
|
|
||||||
After realizing its potential utility for other developers and projects, we decided to make the database easily accessible via GitHub and the jsDelivr CDN.
|
**Website:** [geo.wp-statistics.com](https://geo.wp-statistics.com)
|
||||||
|
|
||||||
#### Last updated: 2025-09-12
|
#### Last updated: 2025-12-26
|
||||||
|
|
||||||
### Direct Download URL
|
---
|
||||||
You can download the latest version of the GeoLite2-City database using the following link: [GeoLite2-City.mmdb.gz](https://cdn.jsdelivr.net/npm/geolite2-city/GeoLite2-City.mmdb.gz)
|
|
||||||
|
|
||||||
### Source Location
|
## Features
|
||||||
For the complete directory and additional resources, visit: [GeoLite2-City Source](https://cdn.jsdelivr.net/npm/geolite2-city/)
|
|
||||||
|
|
||||||
### License Information
|
- **City-Level Accuracy** - Get country, city, coordinates, timezone, and more
|
||||||
The GeoLite2-City database is distributed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/). Please review the license to understand your rights and responsibilities when using this resource.
|
- **Auto-Updated** - Database updated automatically every Tuesday & Friday
|
||||||
|
- **Fast CDN** - Served via jsDelivr with global edge locations
|
||||||
|
- **No Authentication** - Direct download, no API keys required
|
||||||
|
- **Free Forever** - Open source under CC BY-SA 4.0 license
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### Direct Download
|
||||||
|
|
||||||
|
```
|
||||||
|
https://cdn.jsdelivr.net/npm/geolite2-city/GeoLite2-City.mmdb.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
### PHP
|
||||||
|
|
||||||
|
```php
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
$reader = new Reader('/path/to/GeoLite2-City.mmdb');
|
||||||
|
$record = $reader->city('128.101.101.101');
|
||||||
|
|
||||||
|
echo $record->country->name; // 'United States'
|
||||||
|
echo $record->city->name; // 'Minneapolis'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Node.js
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const { Reader } = require('@maxmind/geoip2-node');
|
||||||
|
|
||||||
|
const reader = await Reader.open('./GeoLite2-City.mmdb');
|
||||||
|
const response = reader.city('128.101.101.101');
|
||||||
|
|
||||||
|
console.log(response.country.names.en); // 'United States'
|
||||||
|
console.log(response.city.names.en); // 'Minneapolis'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Python
|
||||||
|
|
||||||
|
```python
|
||||||
|
import geoip2.database
|
||||||
|
|
||||||
|
reader = geoip2.database.Reader('./GeoLite2-City.mmdb')
|
||||||
|
response = reader.city('128.101.101.101')
|
||||||
|
|
||||||
|
print(response.country.name) # 'United States'
|
||||||
|
print(response.city.name) # 'Minneapolis'
|
||||||
|
```
|
||||||
|
|
||||||
|
### WordPress (WP Statistics)
|
||||||
|
|
||||||
|
```php
|
||||||
|
use WP_Statistics\Service\Geolocation\GeolocationFactory;
|
||||||
|
|
||||||
|
$location = GeolocationFactory::getLocation('128.101.101.101');
|
||||||
|
echo $location['city']; // 'Minneapolis'
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Database Info
|
||||||
|
|
||||||
|
| Property | Value |
|
||||||
|
|----------|-------|
|
||||||
|
| **CDN URL** | `https://cdn.jsdelivr.net/npm/geolite2-city/GeoLite2-City.mmdb.gz` |
|
||||||
|
| **npm** | `npm install geolite2-city` |
|
||||||
|
| **Update Schedule** | Every Tuesday & Friday (automatic) |
|
||||||
|
| **Size** | ~68 MB (compressed) |
|
||||||
|
| **Format** | MaxMind DB (MMDB) |
|
||||||
|
| **License** | [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Update Schedule
|
||||||
|
|
||||||
|
This database is **automatically updated** via GitHub Actions:
|
||||||
|
|
||||||
|
- **Schedule:** Every Tuesday and Friday at 06:00 UTC
|
||||||
|
- **Source:** [MaxMind GeoLite2](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data)
|
||||||
|
- **Distribution:** Published to npm, served via jsDelivr CDN
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Related Resources
|
||||||
|
|
||||||
|
- **Documentation:** [geo.wp-statistics.com](https://geo.wp-statistics.com)
|
||||||
|
- **DB-IP Alternative:** [DbIP-City-lite](https://github.com/wp-statistics/DbIP-City-lite)
|
||||||
|
- **Country Database:** [GeoLite2-Country](https://github.com/wp-statistics/GeoLite2-Country)
|
||||||
|
- **WP Statistics:** [wordpress.org/plugins/wp-statistics](https://wordpress.org/plugins/wp-statistics/)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This database is provided by [MaxMind](https://www.maxmind.com/). When using this database, please include appropriate attribution as required by the [CC BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GeoLite2-City by MaxMind is licensed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).
|
||||||
|
|
||||||
|
Maintained by [VeronaLabs](https://veronalabs.com) and the [WP Statistics](https://wp-statistics.com) team.
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "geolite2-city",
|
"name": "geolite2-city",
|
||||||
"version": "1.0.3",
|
"version": "1.0.24",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "geolite2-city",
|
"name": "geolite2-city",
|
||||||
"version": "1.0.3",
|
"version": "1.0.24",
|
||||||
"license": "CC-BY-NC-SA-4.0"
|
"license": "CC-BY-NC-SA-4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "geolite2-city",
|
"name": "geolite2-city",
|
||||||
"version": "1.0.18",
|
"version": "1.0.24",
|
||||||
"description": "GeoLite2-City.mmdb.gz CDN files based on Free Open Source CDN [jsDelivr!](https://www.jsdelivr.com/)",
|
"description": "GeoLite2-City.mmdb.gz CDN files based on Free Open Source CDN [jsDelivr!](https://www.jsdelivr.com/)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": ""
|
"test": ""
|
||||||
|
|||||||
Reference in New Issue
Block a user