Skip to content

Commit 6052cea

Browse files
authored
Merge pull request #434 from maxmind/greg/stf-448
Deploy docs site with Hugo and GitHub Actions
2 parents de841c3 + 58f8000 commit 6052cea

10 files changed

Lines changed: 434 additions & 63 deletions

File tree

.github/workflows/pages.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions: {}
9+
10+
concurrency:
11+
group: pages
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
steps:
20+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
with:
22+
persist-credentials: false
23+
24+
- name: Setup mise
25+
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
26+
with:
27+
cache: true
28+
29+
- name: Build docs
30+
env:
31+
HUGO_BASEURL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/
32+
run: mise run build-docs
33+
34+
- name: Configure Pages
35+
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
36+
37+
- name: Upload artifact
38+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
39+
with:
40+
path: docs/public
41+
42+
deploy:
43+
needs: build
44+
runs-on: ubuntu-latest
45+
permissions:
46+
pages: write
47+
id-token: write
48+
environment:
49+
name: github-pages
50+
url: ${{ steps.deployment.outputs.page_url }}
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
*/.libs
99
*~
1010
.\#*
11-
.gh-pages
11+
docs/.hugo_build.lock
12+
docs/public/
1213
/INSTALL
1314
/autom4te.cache
1415
/bin/country_lookup

dev-bin/release.sh

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -111,45 +111,6 @@ make check
111111
make clean
112112
make safedist
113113

114-
if [ ! -d .gh-pages ]; then
115-
echo "Checking out gh-pages in .gh-pages"
116-
git clone -b gh-pages git@github.com:maxmind/libmaxminddb.git .gh-pages
117-
pushd .gh-pages
118-
else
119-
echo "Updating .gh-pages"
120-
pushd .gh-pages
121-
git pull
122-
fi
123-
124-
if [ -n "$(git status --porcelain)" ]; then
125-
echo ".gh-pages is not clean" >&2
126-
exit 1
127-
fi
128-
129-
index=index.md
130-
cat <<EOF >$index
131-
---
132-
layout: default
133-
title: libmaxminddb - a library for working with MaxMind DB files
134-
version: $version
135-
---
136-
EOF
137-
138-
cat ../doc/libmaxminddb.md >>$index
139-
140-
mmdblookup=mmdblookup.md
141-
cat <<EOF >$mmdblookup
142-
---
143-
layout: default
144-
title: mmdblookup - a utility to look up an IP address in a MaxMind DB file
145-
version: $version
146-
---
147-
EOF
148-
149-
cat ../doc/mmdblookup.md >>$mmdblookup
150-
151-
git commit -m "Updated for $version" -a
152-
153114
read -r -e -p "Push to origin? (y/n) " should_push
154115

155116
if [ "$should_push" != "y" ]; then
@@ -159,8 +120,4 @@ fi
159120

160121
git push
161122

162-
popd
163-
164-
git push
165-
166123
gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$version" "$dist"

docs/assets/css/main.css

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
:root {
2+
--fg: #2d2d2d;
3+
--bg: #faf9f7;
4+
--accent: #1a6b50;
5+
--accent-soft: rgba(26, 107, 80, 0.06);
6+
--border: #d5d0c8;
7+
--code-bg: #f0eeea;
8+
--heading: #1a1a1a;
9+
--muted: #70695f;
10+
}
11+
12+
::selection {
13+
background: rgba(26, 107, 80, 0.15);
14+
}
15+
16+
*,
17+
*::before,
18+
*::after {
19+
box-sizing: border-box;
20+
}
21+
22+
body {
23+
font-family: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
24+
font-size: 1.05rem;
25+
line-height: 1.78;
26+
color: var(--fg);
27+
background: var(--bg);
28+
max-width: 50rem;
29+
margin: 0 auto;
30+
padding: 3rem 1.5rem 5rem;
31+
}
32+
33+
h1,
34+
h2,
35+
h3,
36+
h4 {
37+
font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
38+
line-height: 1.35;
39+
}
40+
41+
h1 {
42+
font-size: 1.75rem;
43+
font-weight: 800;
44+
color: var(--heading);
45+
margin: 0 0 1.5rem;
46+
padding-bottom: 0.75rem;
47+
border-bottom: 3px solid var(--accent);
48+
}
49+
50+
h2 {
51+
font-size: 1.3rem;
52+
font-weight: 700;
53+
color: var(--heading);
54+
margin: 3rem 0 0.75rem;
55+
padding-bottom: 0.4rem;
56+
border-bottom: 1px solid var(--border);
57+
}
58+
59+
h3 {
60+
font-size: 1.05rem;
61+
font-weight: 700;
62+
color: var(--accent);
63+
margin: 2.5rem 0 0.5rem;
64+
padding: 0.4rem 0.75rem;
65+
border-left: 3px solid var(--accent);
66+
background: linear-gradient(135deg, var(--accent-soft), transparent 80%);
67+
border-radius: 0 3px 3px 0;
68+
}
69+
70+
h4 {
71+
font-size: 0.92rem;
72+
font-weight: 700;
73+
color: var(--muted);
74+
margin: 2rem 0 0.5rem;
75+
padding-bottom: 0.2rem;
76+
border-bottom: 1px dashed var(--border);
77+
}
78+
79+
p {
80+
margin: 0.8rem 0;
81+
}
82+
83+
a {
84+
color: var(--accent);
85+
text-decoration-thickness: 1px;
86+
text-underline-offset: 2px;
87+
transition: text-decoration-thickness 0.15s;
88+
}
89+
90+
a:hover {
91+
text-decoration-thickness: 2px;
92+
}
93+
94+
strong {
95+
color: var(--heading);
96+
font-weight: 700;
97+
}
98+
99+
ol,
100+
ul {
101+
padding-left: 1.75rem;
102+
}
103+
104+
li + li {
105+
margin-top: 0.3rem;
106+
}
107+
108+
code {
109+
font-family: "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
110+
font-size: 0.88em;
111+
background: var(--code-bg);
112+
padding: 0.15em 0.4em;
113+
border-radius: 3px;
114+
border: 1px solid rgba(0, 0, 0, 0.06);
115+
}
116+
117+
pre {
118+
background: var(--code-bg);
119+
border: 1px solid var(--border);
120+
border-radius: 5px;
121+
padding: 1rem 1.25rem;
122+
overflow-x: auto;
123+
line-height: 1.55;
124+
}
125+
126+
pre code {
127+
background: none;
128+
padding: 0;
129+
border: none;
130+
font-size: 0.85em;
131+
}
132+
133+
img {
134+
max-width: 100%;
135+
height: auto;
136+
}
137+
138+
.heading-anchor {
139+
opacity: 0;
140+
margin-left: 0.3em;
141+
font-weight: 400;
142+
text-decoration: none;
143+
transition: opacity 0.15s;
144+
}
145+
146+
h1:hover .heading-anchor,
147+
h2:hover .heading-anchor,
148+
h3:hover .heading-anchor,
149+
h4:hover .heading-anchor,
150+
.heading-anchor:focus {
151+
opacity: 0.4;
152+
}
153+
154+
.heading-anchor:hover {
155+
opacity: 1;
156+
}
157+
158+
.page-nav {
159+
margin-bottom: 2.5rem;
160+
display: flex;
161+
gap: 0.5rem;
162+
flex-wrap: wrap;
163+
}
164+
165+
.page-nav a {
166+
font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
167+
font-size: 0.85rem;
168+
font-weight: 600;
169+
text-decoration: none;
170+
color: var(--muted);
171+
padding: 0.3rem 0.75rem;
172+
border: 1px solid var(--border);
173+
border-radius: 999px;
174+
transition:
175+
color 0.15s,
176+
border-color 0.15s,
177+
background 0.15s;
178+
}
179+
180+
.page-nav a:hover {
181+
color: var(--accent);
182+
border-color: var(--accent);
183+
}
184+
185+
.page-nav a.active {
186+
color: var(--bg);
187+
background: var(--accent);
188+
border-color: var(--accent);
189+
}

docs/hugo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
title = "libmaxminddb"
2+
uglyURLs = true
3+
disableKinds = ["taxonomy", "term", "RSS"]
4+
5+
[[cascade]]
6+
layout = "default"
7+
8+
[markup.highlight]
9+
noClasses = true
10+
style = "github"
11+
12+
[[module.mounts]]
13+
source = "../doc/libmaxminddb.md"
14+
target = "content/_index.md"
15+
16+
[[module.mounts]]
17+
source = "../doc/mmdblookup.md"
18+
target = "content/mmdblookup.md"

docs/layouts/404.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Page not found | {{ .Site.Title }}</title>
7+
{{- $css := resources.Get "css/main.css" | fingerprint -}}
8+
<link
9+
rel="stylesheet"
10+
href="{{ $css.RelPermalink }}"
11+
integrity="{{ $css.Data.Integrity }}"
12+
crossorigin="anonymous"
13+
/>
14+
</head>
15+
<body>
16+
<main>
17+
<h1>Page not found</h1>
18+
<p>
19+
The page you're looking for doesn't exist. Return to
20+
<a href="{{ .Site.Home.RelPermalink }}">{{ .Site.Title }}</a>.
21+
</p>
22+
</main>
23+
</body>
24+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<h{{ .Level }} id="{{ .Anchor }}">
2+
{{- .Text | safeHTML -}}
3+
<a class="heading-anchor" href="#{{ .Anchor }}" aria-label="Link to {{ .PlainText }}">#</a>
4+
</h{{ .Level }}>

docs/layouts/_default/default.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
{{- $title := or .Title .File.BaseFileName -}}
7+
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title>
8+
{{- $css := resources.Get "css/main.css" | fingerprint -}}
9+
<link
10+
rel="stylesheet"
11+
href="{{ $css.RelPermalink }}"
12+
integrity="{{ $css.Data.Integrity }}"
13+
crossorigin="anonymous"
14+
/>
15+
</head>
16+
<body>
17+
<nav class="page-nav">
18+
<a href="{{ .Site.Home.RelPermalink }}"{{ if .IsHome }} class="active" aria-current="page"{{ end }}>{{ .Site.Title }}</a>
19+
{{ range .Site.RegularPages }}
20+
<a href="{{ .RelPermalink }}"{{ if eq $.RelPermalink .RelPermalink }} class="active" aria-current="page"{{ end }}>{{ or .Title .File.BaseFileName }}</a>
21+
{{ end }}
22+
</nav>
23+
<main>
24+
{{ .Content }}
25+
</main>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)