geolite2-country 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,124 @@
1
+ name: Update GeoLite2-Country Database
2
+
3
+ on:
4
+ schedule:
5
+ # Run every Tuesday and Friday at 06:00 UTC (MaxMind update days)
6
+ - cron: '0 6 * * 2,5'
7
+ workflow_dispatch:
8
+ inputs:
9
+ force_publish:
10
+ description: 'Force publish to npm even if no changes'
11
+ required: false
12
+ default: 'false'
13
+ type: boolean
14
+
15
+ jobs:
16
+ update:
17
+ runs-on: ubuntu-latest
18
+ permissions:
19
+ contents: write
20
+ id-token: write # Required for npm trusted publishing (OIDC)
21
+
22
+ steps:
23
+ - name: Checkout repository
24
+ uses: actions/checkout@v4
25
+ with:
26
+ token: ${{ secrets.GITHUB_TOKEN }}
27
+
28
+ - name: Setup Node.js
29
+ uses: actions/setup-node@v4
30
+ with:
31
+ node-version: '24' # Node 24 includes npm 11.5.1+ required for OIDC
32
+ registry-url: 'https://registry.npmjs.org'
33
+
34
+ - name: Download latest GeoLite2-Country database
35
+ env:
36
+ MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
37
+ run: |
38
+ echo "Downloading GeoLite2-Country database..."
39
+
40
+ # Download the database
41
+ curl -fsSL -o GeoLite2-Country.tar.gz \
42
+ "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${MAXMIND_LICENSE_KEY}&suffix=tar.gz"
43
+
44
+ # Check if download was successful
45
+ if [ ! -f GeoLite2-Country.tar.gz ] || [ ! -s GeoLite2-Country.tar.gz ]; then
46
+ echo "Download failed or file is empty"
47
+ exit 1
48
+ fi
49
+
50
+ # Extract the mmdb file
51
+ tar -xzf GeoLite2-Country.tar.gz
52
+
53
+ # Find and move the mmdb file
54
+ MMDB_FILE=$(find . -name "GeoLite2-Country.mmdb" -type f)
55
+ if [ -z "$MMDB_FILE" ]; then
56
+ echo "Could not find GeoLite2-Country.mmdb in archive"
57
+ exit 1
58
+ fi
59
+
60
+ mv "$MMDB_FILE" ./GeoLite2-Country.mmdb
61
+
62
+ # Compress with maximum compression
63
+ gzip -9 -f GeoLite2-Country.mmdb
64
+
65
+ # Cleanup
66
+ rm -rf GeoLite2-Country.tar.gz GeoLite2-Country_*/
67
+
68
+ echo "Database downloaded and compressed successfully"
69
+ ls -lh GeoLite2-Country.mmdb.gz
70
+
71
+ - name: Check for changes
72
+ id: check_changes
73
+ run: |
74
+ FORCE="${{ inputs.force_publish }}"
75
+ if [ "$FORCE" == "true" ]; then
76
+ echo "Force publish requested"
77
+ echo "changed=true" >> $GITHUB_OUTPUT
78
+ elif git diff --quiet GeoLite2-Country.mmdb.gz 2>/dev/null; then
79
+ echo "No changes detected"
80
+ echo "changed=false" >> $GITHUB_OUTPUT
81
+ else
82
+ echo "Changes detected"
83
+ echo "changed=true" >> $GITHUB_OUTPUT
84
+ fi
85
+
86
+ - name: Update version and commit
87
+ if: steps.check_changes.outputs.changed == 'true'
88
+ run: |
89
+ # Bump patch version
90
+ npm version patch --no-git-tag-version
91
+
92
+ # Get new version
93
+ NEW_VERSION=$(node -p "require('./package.json').version")
94
+ echo "New version: $NEW_VERSION"
95
+
96
+ # Update README with current date
97
+ CURRENT_DATE=$(date +%Y-%m-%d)
98
+ sed -i "s/Last updated: .*/Last updated: ${CURRENT_DATE}/" README.md
99
+
100
+ # Configure git
101
+ git config --global user.name 'github-actions[bot]'
102
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
103
+
104
+ # Commit and push
105
+ git add .
106
+ git commit -m "Update GeoLite2-Country database to v${NEW_VERSION} - ${CURRENT_DATE}"
107
+ git push
108
+
109
+ - name: Publish to npm
110
+ if: steps.check_changes.outputs.changed == 'true'
111
+ run: npm publish --provenance --access public
112
+
113
+ - name: Summary
114
+ run: |
115
+ if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then
116
+ echo "### Database Updated Successfully" >> $GITHUB_STEP_SUMMARY
117
+ echo "" >> $GITHUB_STEP_SUMMARY
118
+ echo "- New version published to npm" >> $GITHUB_STEP_SUMMARY
119
+ echo "- CDN will be updated automatically via jsDelivr" >> $GITHUB_STEP_SUMMARY
120
+ else
121
+ echo "### No Updates Required" >> $GITHUB_STEP_SUMMARY
122
+ echo "" >> $GITHUB_STEP_SUMMARY
123
+ echo "The database is already up to date." >> $GITHUB_STEP_SUMMARY
124
+ fi
Binary file
package/README.md CHANGED
@@ -1,18 +1,125 @@
1
- # GeoLite2-Country (MaxMind.com) CDN files
1
+ # GeoLite2-Country - Free IP to Country Database
2
2
 
3
- GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN [jsDelivr!](https://www.jsdelivr.com/)
3
+ [![npm version](https://img.shields.io/npm/v/geolite2-country.svg)](https://www.npmjs.com/package/geolite2-country)
4
+ [![npm downloads](https://img.shields.io/npm/dm/geolite2-country.svg)](https://www.npmjs.com/package/geolite2-country)
5
+ [![License](https://img.shields.io/badge/license-CC%20BY--SA%204.0-green)](https://creativecommons.org/licenses/by-sa/4.0/)
6
+ [![GitHub Stars](https://img.shields.io/github/stars/wp-statistics/GeoLite2-Country?style=social)](https://github.com/wp-statistics/GeoLite2-Country)
4
7
 
5
- #### Last updated: 2024-07-26
8
+ Free MaxMind GeoLite2-Country database for IP geolocation. Lightweight country-level lookup from any IP address. Automatically updated and served via jsDelivr CDN.
9
+
10
+ **Website:** [geo.wp-statistics.com](https://geo.wp-statistics.com)
11
+
12
+ ---
13
+
14
+ ## Features
15
+
16
+ - **Country-Level Lookup** - Fast country detection from IP addresses
17
+ - **Ultra Lightweight** - Smallest database option (~2 MB)
18
+ - **Auto-Updated** - Database updated automatically
19
+ - **Fast CDN** - Served via jsDelivr with global edge locations
20
+ - **No Authentication** - Direct download, no API keys required
21
+ - **Free Forever** - Open source under CC BY-SA 4.0 license
22
+
23
+ ---
24
+
25
+ ## Quick Start
26
+
27
+ ### Direct Download
6
28
 
7
- ## Download link
8
29
  ```
9
30
  https://cdn.jsdelivr.net/npm/geolite2-country/GeoLite2-Country.mmdb.gz
10
31
  ```
11
32
 
12
- ## Source
33
+ ### PHP
34
+
35
+ ```php
36
+ use GeoIp2\Database\Reader;
37
+
38
+ $reader = new Reader('/path/to/GeoLite2-Country.mmdb');
39
+ $record = $reader->country('128.101.101.101');
40
+
41
+ echo $record->country->name; // 'United States'
42
+ echo $record->country->isoCode; // 'US'
43
+ ```
44
+
45
+ ### Node.js
46
+
47
+ ```javascript
48
+ const { Reader } = require('@maxmind/geoip2-node');
49
+
50
+ const reader = await Reader.open('./GeoLite2-Country.mmdb');
51
+ const response = reader.country('128.101.101.101');
52
+
53
+ console.log(response.country.names.en); // 'United States'
54
+ console.log(response.country.isoCode); // 'US'
13
55
  ```
14
- https://cdn.jsdelivr.net/npm/geolite2-country/
56
+
57
+ ### Python
58
+
59
+ ```python
60
+ import geoip2.database
61
+
62
+ reader = geoip2.database.Reader('./GeoLite2-Country.mmdb')
63
+ response = reader.country('128.101.101.101')
64
+
65
+ print(response.country.name) # 'United States'
66
+ print(response.country.iso_code) # 'US'
15
67
  ```
16
68
 
69
+ ### WordPress (WP Statistics)
70
+
71
+ ```php
72
+ use WP_Statistics\Service\Geolocation\GeolocationFactory;
73
+
74
+ $location = GeolocationFactory::getLocation('128.101.101.101');
75
+ echo $location['country_code']; // 'US'
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Database Info
81
+
82
+ | Property | Value |
83
+ |----------|-------|
84
+ | **CDN URL** | `https://cdn.jsdelivr.net/npm/geolite2-country/GeoLite2-Country.mmdb.gz` |
85
+ | **npm** | `npm install geolite2-country` |
86
+ | **Update Schedule** | Automatic |
87
+ | **Size** | ~2 MB (compressed) |
88
+ | **Format** | MaxMind DB (MMDB) |
89
+ | **License** | [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) |
90
+
91
+ ---
92
+
93
+ ## Country vs City Database
94
+
95
+ | Feature | GeoLite2-Country | GeoLite2-City |
96
+ |---------|------------------|---------------|
97
+ | **File Size** | ~2 MB | ~68 MB |
98
+ | **Data** | Country only | Country, city, coordinates |
99
+ | **Speed** | Fastest | Fast |
100
+ | **Best For** | Geo-blocking, basic analytics | Detailed location needs |
101
+
102
+ Choose **Country** if you only need country-level data. Choose **City** for detailed location information.
103
+
104
+ ---
105
+
106
+ ## Related Resources
107
+
108
+ - **Documentation:** [geo.wp-statistics.com](https://geo.wp-statistics.com)
109
+ - **City Database:** [GeoLite2-City](https://github.com/wp-statistics/GeoLite2-City)
110
+ - **DB-IP Alternative:** [DbIP-City-lite](https://github.com/wp-statistics/DbIP-City-lite)
111
+ - **WP Statistics:** [wordpress.org/plugins/wp-statistics](https://wordpress.org/plugins/wp-statistics/)
112
+
113
+ ---
114
+
115
+ ## Attribution
116
+
117
+ 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/).
118
+
119
+ ---
120
+
17
121
  ## License
18
- [CC Attribution-ShareAlike 4.0](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en)
122
+
123
+ GeoLite2-Country by MaxMind is licensed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).
124
+
125
+ Maintained by [VeronaLabs](https://veronalabs.com) and the [WP Statistics](https://wp-statistics.com) team.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geolite2-country",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN [jsDelivr!](https://www.jsdelivr.com/)",
5
5
  "scripts": {
6
6
  "test": ""
@@ -1,22 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- push:
8
- branches:
9
- - master
10
- jobs:
11
- publish:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 12
18
- - run: npm install
19
- - run: npm test
20
- - uses: JS-DevTools/npm-publish@v1
21
- with:
22
- token: ${{ secrets.NPM_TOKEN }}