Skip to content

Commit 1d7a890

Browse files
authored
Merge pull request #80 from maxmind/greg/eng-3475-mmdbverify-is-released
Prepare for release
2 parents f9cb6a3 + a020055 commit 1d7a890

File tree

8 files changed

+329
-24
lines changed

8 files changed

+329
-24
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
name: Release with GoReleaser
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
submodules: recursive
21+
persist-credentials: false
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.25'
27+
cache: false
28+
29+
- name: Run GoReleaser
30+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # 6.4.0
31+
with:
32+
distribution: goreleaser
33+
version: latest
34+
args: release --clean
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
mmdbverify

.goreleaser.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
project_name: 'mmdbverify'
2+
version: 2
3+
4+
before:
5+
hooks:
6+
- 'go mod tidy'
7+
8+
builds:
9+
- id: 'mmdbverify'
10+
main: './'
11+
binary: 'mmdbverify'
12+
goos:
13+
- 'darwin'
14+
- 'linux'
15+
- 'windows'
16+
ignore:
17+
- goos: 'darwin'
18+
goarch: '386'
19+
- goos: 'linux'
20+
goarch: '386'
21+
- goos: 'windows'
22+
goarch: '386'
23+
24+
archives:
25+
- id: 'mmdbverify'
26+
ids:
27+
- 'mmdbverify'
28+
wrap_in_directory: true
29+
format_overrides:
30+
- goos: windows
31+
formats:
32+
- zip
33+
files:
34+
- 'CHANGELOG.md'
35+
- 'LICENSE'
36+
- 'README.md'
37+
38+
checksum:
39+
name_template: 'checksums.txt'
40+
41+
snapshot:
42+
version_template: "{{ .Tag }}-next"
43+
44+
changelog:
45+
disable: true
46+
47+
nfpms:
48+
- id: 'mmdbverify'
49+
ids:
50+
- 'mmdbverify'
51+
vendor: 'MaxMind, Inc.'
52+
homepage: 'https://www.maxmind.com/'
53+
maintainer: 'MaxMind, Inc. <support@maxmind.com>'
54+
description: 'Tool to verify MaxMind MMDB database files.'
55+
license: 'Apache 2.0'
56+
formats:
57+
- 'deb'
58+
- 'rpm'
59+
bindir: '/usr/bin'
60+
contents:
61+
- src: 'CHANGELOG.md'
62+
dst: '/usr/share/doc/mmdbverify/CHANGELOG.md'
63+
- src: 'LICENSE'
64+
dst: '/usr/share/doc/mmdbverify/LICENSE'
65+
- src: 'README.md'
66+
dst: '/usr/share/doc/mmdbverify/README.md'
67+
68+
release:
69+
target_commitish: "{{ .FullCommit }}"

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to
7+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8+
9+
## [1.0.0] - 2025-11-14
10+
11+
### Added
12+
13+
- Initial official release of mmdbverify
14+
- Verify MaxMind DB file validity
15+
- Search tree validation
16+
- Data section validation
17+
- Metadata validation and sanity checks
18+
- Command-line interface with `-file` flag
19+
- Cross-platform builds (Linux, macOS, Windows for amd64 and arm64)
20+
- Debian and RPM package support
21+
- Clear error messages to stderr
22+
- Zero exit code on success, non-zero on failure
23+
24+
[unreleased]: https://github.com/maxmind/mmdbverify/compare/v1.0.0...HEAD
25+
[1.0.0]: https://github.com/maxmind/mmdbverify/releases/tag/v1.0.0

README.md

Lines changed: 181 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,189 @@
1-
MaxMind DB Verifier
2-
-------------------
1+
# mmdbverify
32

4-
This is a utility to verify that a MaxMind DB is valid. The search tree,
5-
data section, and metadata are all checked for validity and sanity. If the
6-
database cannot be parsed or is otherwise invalid, a short description will
7-
be sent to `stderr` and the utility will exit with a non-zero exit code. If
8-
successful, no output will be printed and an exit code of zero will be
9-
returned.
3+
A command-line utility to verify the validity of MaxMind DB (MMDB) files.
104

11-
Note that this tool may flag a database as invalid even though it is
12-
completely parseable. This may happen if there is unexpected data in the
13-
data section or metadata that is not well-formed.
5+
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6+
[![Go Version](https://img.shields.io/badge/Go-1.24%2B-00ADD8?logo=go)](https://golang.org)
147

15-
Usage
16-
=====
8+
## Overview
179

18-
Required:
10+
This utility verifies that a MaxMind DB file is valid by checking:
1911

20-
* -file=[FILENAME] - The path to the database to test.
12+
- **Search tree** - Validates the tree structure used for IP lookups
13+
- **Data section** - Ensures all data is properly formatted and accessible
14+
- **Metadata** - Verifies metadata is well-formed and contains expected fields
2115

22-
Copyright and License
23-
=====================
16+
If the database is valid, the tool exits silently with status code `0`. If
17+
invalid, an error description is printed to `stderr` and the tool exits with a
18+
non-zero status code.
2419

25-
This software is Copyright (c) 2015-2025 by MaxMind, Inc.
20+
**Note:** This tool may flag a database as invalid even if it can be parsed.
21+
This occurs when there is unexpected or malformed data in the data section or
22+
metadata.
2623

27-
This is free software, licensed under the Apache License, Version 2.0.
24+
## Installation
25+
26+
### Binary Releases (Recommended)
27+
28+
Download pre-built binaries from the
29+
[GitHub Releases page](https://github.com/maxmind/mmdbverify/releases).
30+
31+
> **Architecture Guide:**
32+
>
33+
> - `amd64` = x86-64 / x64 (most common for Intel/AMD processors)
34+
> - `arm64` = ARM 64-bit (Apple Silicon, AWS Graviton, Raspberry Pi 4+)
35+
> - `darwin` = macOS
36+
37+
#### Linux
38+
39+
**Using .deb package (Debian/Ubuntu):**
40+
41+
```bash
42+
# Download the .deb file for your architecture from the releases page
43+
sudo dpkg -i mmdbverify_<VERSION>_linux_<ARCH>.deb
44+
```
45+
46+
**Using .rpm package (RedHat/CentOS/Fedora):**
47+
48+
```bash
49+
# Download the .rpm file for your architecture from the releases page
50+
sudo rpm -i mmdbverify_<VERSION>_linux_<ARCH>.rpm
51+
```
52+
53+
**Using tar.gz archive:**
54+
55+
```bash
56+
# Download and extract
57+
tar -xzf mmdbverify_<VERSION>_linux_<ARCH>.tar.gz
58+
sudo mv mmdbverify/mmdbverify /usr/local/bin/
59+
```
60+
61+
#### macOS
62+
63+
```bash
64+
# Download the appropriate file for your Mac:
65+
# - darwin_arm64 for Apple Silicon (M1/M2/M3/M4)
66+
# - darwin_amd64 for Intel Macs
67+
tar -xzf mmdbverify_<VERSION>_darwin_<ARCH>.tar.gz
68+
sudo mv mmdbverify/mmdbverify /usr/local/bin/
69+
```
70+
71+
#### Windows
72+
73+
1. Download the Windows zip file for your architecture from the releases page
74+
2. Extract the zip file
75+
3. Add `mmdbverify.exe` to your PATH or run it directly
76+
77+
**Using PowerShell:**
78+
79+
```powershell
80+
# Extract
81+
Expand-Archive -Path mmdbverify_<VERSION>_windows_<ARCH>.zip -DestinationPath .
82+
83+
# Run
84+
.\mmdbverify\mmdbverify.exe -file C:\path\to\database.mmdb
85+
```
86+
87+
### From Source
88+
89+
```bash
90+
go install github.com/maxmind/mmdbverify@latest
91+
```
92+
93+
### Build Locally
94+
95+
```bash
96+
git clone https://github.com/maxmind/mmdbverify.git
97+
cd mmdbverify
98+
go build
99+
```
100+
101+
## Usage
102+
103+
```bash
104+
# Verify a database file (silent on success)
105+
mmdbverify -file /path/to/GeoIP2-City.mmdb
106+
107+
# Verify with verbose output
108+
mmdbverify -file /path/to/GeoIP2-City.mmdb -verbose
109+
# Verifying /path/to/GeoIP2-City.mmdb...
110+
# /path/to/GeoIP2-City.mmdb is valid
111+
112+
# Check exit code
113+
echo $?
114+
# 0
115+
116+
# Failure (error printed to stderr with filename, non-zero exit code)
117+
mmdbverify -file /path/to/invalid.mmdb
118+
# Error verifying /path/to/invalid.mmdb: invalid database metadata
119+
echo $?
120+
# 1
121+
```
122+
123+
### Command-Line Flags
124+
125+
- `-file` - **Required.** Path to the MaxMind DB file to verify
126+
- `-verbose` - Print verification status messages
127+
128+
## Examples
129+
130+
### Verify GeoIP2 Database
131+
132+
```bash
133+
# Silent mode (default)
134+
mmdbverify -file GeoIP2-City.mmdb
135+
136+
# Verbose mode
137+
mmdbverify -file GeoIP2-City.mmdb -verbose
138+
```
139+
140+
### Verify Multiple Databases
141+
142+
```bash
143+
# Verify all MMDB files with verbose output
144+
for db in *.mmdb; do
145+
mmdbverify -file "$db" -verbose
146+
done
147+
```
148+
149+
### Use in CI/CD Pipeline
150+
151+
```bash
152+
# Exit immediately if validation fails
153+
mmdbverify -file GeoIP2-Country.mmdb || exit 1
154+
```
155+
156+
## Use Cases
157+
158+
- **Pre-deployment validation** - Verify databases before deploying to
159+
production
160+
- **Download verification** - Ensure downloaded MMDB files are not corrupted
161+
- **CI/CD pipelines** - Validate databases in automated testing workflows
162+
- **Quality assurance** - Check custom MMDB files created with
163+
[mmdbwriter](https://github.com/maxmind/mmdbwriter)
164+
165+
## Requirements
166+
167+
- Go 1.24 or later (for building from source)
168+
- MaxMind DB files to verify (GeoIP2, GeoLite2, or custom MMDB files)
169+
170+
## Related Tools
171+
172+
- [mmdbinspect](https://github.com/maxmind/mmdbinspect) - Inspect and query MMDB
173+
files
174+
- [mmdbwriter](https://github.com/maxmind/mmdbwriter) - Create custom MMDB files
175+
- [mmdbconvert](https://github.com/maxmind/mmdbconvert) - Convert MMDB to
176+
CSV/Parquet
177+
178+
## License
179+
180+
Copyright (c) 2015-2025 by MaxMind, Inc.
181+
182+
This software is licensed under the Apache License, Version 2.0. See
183+
[LICENSE](LICENSE) for details.
184+
185+
## Support
186+
187+
- **Issues:** [GitHub Issues](https://github.com/maxmind/mmdbverify/issues)
188+
- **MaxMind Support:**
189+
[https://support.maxmind.com](https://support.maxmind.com)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ go 1.24.0
44

55
require github.com/oschwald/maxminddb-golang/v2 v2.1.0
66

7-
require golang.org/x/sys v0.37.0 // indirect
7+
require golang.org/x/sys v0.38.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
66
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
77
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
88
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
9-
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
10-
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
9+
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
10+
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
1111
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1212
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
func main() {
1313
required := "<REQUIRED>"
1414
file := flag.String("file", required, "The path to the MaxMind DB to verify")
15+
verbose := flag.Bool("verbose", false, "Print verification status messages")
1516

1617
flag.Parse()
1718

@@ -20,14 +21,24 @@ func main() {
2021
os.Exit(1)
2122
}
2223

24+
if *verbose {
25+
fmt.Printf("Verifying %s...\n", *file)
26+
}
27+
2328
reader, err := maxminddb.Open(*file)
2429
if err != nil {
25-
fmt.Fprintf(os.Stderr, "Error opening file: %v\n", err)
30+
fmt.Fprintf(os.Stderr, "Error opening %s: %v\n", *file, err)
2631
os.Exit(1)
2732
}
2833

2934
if err := reader.Verify(); err != nil {
30-
fmt.Fprintf(os.Stderr, "Error verifying file: %v\n", err)
35+
reader.Close()
36+
fmt.Fprintf(os.Stderr, "Error verifying %s: %v\n", *file, err)
3137
os.Exit(1)
3238
}
39+
reader.Close()
40+
41+
if *verbose {
42+
fmt.Printf("%s is valid\n", *file)
43+
}
3344
}

0 commit comments

Comments
 (0)