Skip to content

Commit 118d20c

Browse files
committed
Fix run-in-nix forwarding
1 parent 3db76e7 commit 118d20c

5 files changed

Lines changed: 228 additions & 34 deletions

File tree

.github/workflows/build.yaml

Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
name: Build font and specimen
22

3-
on: [push, pull_request, workflow_dispatch]
4-
permissions: write-all
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
release:
8+
types: [published]
9+
10+
permissions:
11+
contents: write
12+
pages: write
13+
id-token: write
514

615
jobs:
716
build:
@@ -43,18 +52,44 @@ jobs:
4352
NIX_CONFIG: "experimental-features = nix-command flakes"
4453
run: make build
4554
- name: Check with fontspector
55+
id: fontbakery
4656
env:
4757
NIX_CONFIG: "experimental-features = nix-command flakes"
48-
run: make test
58+
run: |
59+
set +e
60+
make test
61+
status=$?
62+
echo "exit_code=$status" >> "$GITHUB_OUTPUT"
63+
if [ "$status" -ne 0 ]; then
64+
echo "failed=true" >> "$GITHUB_OUTPUT"
65+
else
66+
echo "failed=false" >> "$GITHUB_OUTPUT"
67+
fi
68+
exit 0
4969
continue-on-error: true
5070
- name: Generate proofs
5171
env:
5272
NIX_CONFIG: "experimental-features = nix-command flakes"
5373
run: make proof
5474
- name: Set up test result site
55-
run: cp scripts/index.html out/index.html
75+
run: |
76+
mkdir -p out/ttf
77+
if compgen -G "fonts/ttf/*.ttf" > /dev/null; then
78+
rsync -av fonts/ttf/ out/ttf/
79+
else
80+
echo "No TTF files found to copy into out/ttf."
81+
fi
82+
python - <<'PY'
83+
import json
84+
from pathlib import Path
85+
86+
root = Path("out")
87+
manifest = [str(path.relative_to(root)) for path in (root / "ttf").rglob("*.ttf")]
88+
(root / "ttf_manifest.json").write_text(json.dumps(manifest, indent=2))
89+
PY
90+
cp scripts/index.html out/index.html
5691
- name: Collect deployment assets
57-
if: ${{ github.ref == 'refs/heads/main' }}
92+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
5893
uses: actions/upload-pages-artifact@v3
5994
with:
6095
path: ./out
@@ -67,10 +102,11 @@ jobs:
67102
out
68103
outputs:
69104
zip_name: ${{ env.ZIP_NAME }}
105+
validation_failed: ${{ steps.fontbakery.outputs.failed }}
70106

71107
deploy:
72108
name: Deploy results to GitHub Pages
73-
if: ${{ github.ref == 'refs/heads/main' }}
109+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
74110
needs: build
75111
runs-on: ubuntu-latest
76112
permissions:
@@ -83,6 +119,8 @@ jobs:
83119
- name: Deploy to GitHub Pages
84120
id: deployment
85121
uses: actions/deploy-pages@v4
122+
outputs:
123+
page_url: ${{ steps.deployment.outputs.page_url }}
86124

87125
# There are two ways a release can be created: either by pushing a tag, or by
88126
# creating a release from the GitHub UI. Pushing a tag does not automatically
@@ -93,18 +131,32 @@ jobs:
93131
release:
94132
name: Release bundle
95133
if: contains(github.ref, 'refs/tags/')
96-
needs: build
134+
needs:
135+
- build
136+
- deploy
97137
runs-on: ubuntu-latest
98138
env:
99139
ZIP_NAME: ${{ needs.build.outputs.zip_name }}
100140
GH_TOKEN: ${{ github.token }}
141+
PAGE_URL: ${{ needs.deploy.outputs.page_url }}
142+
VALIDATION_FAILED: ${{ needs.build.outputs.validation_failed }}
101143
steps:
102144
- uses: actions/checkout@v4
103145
- name: Use font artifacts from CI
104146
uses: actions/download-artifact@v5
105147
with:
106148
name: ${{ env.ZIP_NAME }}
107149
path: ${{ env.ZIP_NAME }}
150+
- name: Prepare proof asset
151+
id: proof
152+
run: |
153+
PROOF_PATH=$(find "${{ env.ZIP_NAME }}" -path "*/out/proof/diffenator2-report.html" | head -n 1 || true)
154+
if [ -n "$PROOF_PATH" ]; then
155+
cp "$PROOF_PATH" proof-report.html
156+
echo "asset=proof-report.html" >> "$GITHUB_OUTPUT"
157+
else
158+
echo "asset=" >> "$GITHUB_OUTPUT"
159+
fi
108160
- name: Copy ARTICLE.en_us.html to release directory
109161
run: cp documentation/ARTICLE.en_us.html ${{ env.ZIP_NAME }}/ARTICLE.en_us.html
110162
continue-on-error: true
@@ -117,15 +169,44 @@ jobs:
117169
run: echo "RELEASE_ZIP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')-${{github.ref_name}}" >> $GITHUB_ENV
118170
- name: Create release bundle
119171
run: mv ${{ env.ZIP_NAME }} ${{ env.RELEASE_ZIP_NAME }}; zip -r ${{ env.RELEASE_ZIP_NAME }}.zip ${{ env.RELEASE_ZIP_NAME }}
172+
- name: Build release notes
173+
run: |
174+
STATUS="Passed"
175+
if [ "${VALIDATION_FAILED}" = "true" ]; then
176+
STATUS="Failed"
177+
fi
178+
PROOF_LINK=${PAGE_URL%/}/proof/diffenator2-report.html
179+
FONTBAKERY_LINK=${PAGE_URL%/}/fontbakery
180+
{
181+
echo "## ${GITHUB_REF_NAME}"
182+
echo ""
183+
echo "- Demo and reports: ${PAGE_URL:-N/A}"
184+
echo "- Hosted proof: ${PROOF_LINK:-N/A}"
185+
echo "- FontBakery reports: ${FONTBAKERY_LINK:-N/A}"
186+
echo "- Validation status: ${STATUS}"
187+
if [ "${VALIDATION_FAILED}" = "true" ]; then
188+
echo ""
189+
echo "FontBakery reported issues during validation. See attached and hosted reports for details."
190+
fi
191+
} > release-notes.md
120192
- name: Check for release
121193
id: create_release
122194
run: |
123195
if ! gh release view ${{ github.ref_name }}; then
124-
git show -s --format=%B ${{ github.ref_name }} | tail -n +4 | gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} -F -
196+
gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} -F release-notes.md
197+
fi
198+
- name: Upload TTF assets
199+
run: |
200+
mapfile -t ttfs < <(find "${{ env.RELEASE_ZIP_NAME }}/fonts/ttf" -type f -name "*.ttf")
201+
if [ ${#ttfs[@]} -gt 0 ]; then
202+
gh release upload ${{ github.ref_name }} "${ttfs[@]}" --clobber
125203
fi
204+
- name: Upload proof report asset
205+
if: ${{ steps.proof.outputs.asset != '' }}
206+
run: gh release upload ${{ github.ref_name }} ${{ steps.proof.outputs.asset }} --clobber
126207
- name: Populate release
127208
run: |
128209
gh release upload ${{ github.ref_name }} ${{ env.RELEASE_ZIP_NAME }}.zip --clobber
129210
- name: Set release live
130211
run: |
131-
gh release edit ${{ github.ref_name }} --draft=false
212+
gh release edit ${{ github.ref_name }} --draft=false -F release-notes.md

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Iosevka Charon
22

3-
Custom Google Fonts–style repository for the Iosevka Charon and Iosevka Charon Mono builds. This project keeps the Google Fonts template layout while using the original Nix + uv toolchain from `iosevka-julsh`.
3+
Custom Google Fonts–compliant repository for the Iosevka Charon and Iosevka Charon Mono builds. This project keeps the Google Fonts template layout while using the repository's Nix + uv toolchain, and stays aligned with Google Fonts repository expectations.
44

55
## Building and testing
66

7-
The Make targets wrap the Nix flake dev shell (which bootstraps uv and the Python venv) and the Iosevka build scripts:
7+
The Make targets wrap the Nix flake dev shell (which bootstraps uv and the Python venv) and the Iosevka build scripts. If Nix is installed, `make` automatically enters the flake dev shell; when Nix is absent but Docker is available, the same flow runs inside the official `nixos/nix` container. With either tool installed, you can rely solely on the standard GNU Make entry points:
88

99
- `make build` – enter the Nix shell, sync the Iosevka submodule, build the fonts, and copy TTFs to `fonts/ttf/…`.
1010
- `make test` – run FontBakery (with the Beria Erfe script patch) against the built TTFs, writing reports to `out/fontbakery`.
1111
- `make proof` – generate diffenator2 HTML proofs in `out/proof` using the built TTFs.
1212

13-
You can also run any command inside the dev shell manually via `./scripts/run-in-nix.sh <command>`.
14-
1513
## Tooling
1614

1715
- Nix flake in `sources/flake.nix` provisions Node, uv, and supporting tools.

scripts/index.html

Lines changed: 119 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,121 @@
11
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1" />
6-
<title>My Font development</title>
7-
</head>
8-
<body>
9-
<h1>My Font testing pages</h1>
10-
<ul>
11-
<li>
12-
<a href="fontspector/fontspector-report.html">Fontspector Report</a>
13-
</li>
14-
<li>
15-
<a href="proof/diffenator2-report.html">Diffenator2 Report</a>
16-
</li>
17-
</ul>
18-
</body>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Iosevka Charon Demo and Reports</title>
7+
<style>
8+
body {
9+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
10+
line-height: 1.6;
11+
margin: 2rem auto;
12+
max-width: 960px;
13+
padding: 0 1.25rem;
14+
}
15+
16+
header {
17+
margin-bottom: 2rem;
18+
}
19+
20+
code {
21+
background: #f3f4f6;
22+
border-radius: 0.25rem;
23+
padding: 0.25rem 0.35rem;
24+
}
25+
26+
.font-card {
27+
border: 1px solid #e5e7eb;
28+
border-radius: 0.5rem;
29+
padding: 1rem;
30+
margin: 1rem 0;
31+
}
32+
33+
.sample {
34+
font-size: 1.25rem;
35+
margin-top: 0.5rem;
36+
}
37+
38+
.reports ul {
39+
list-style: disc;
40+
padding-left: 1.5rem;
41+
}
42+
</style>
43+
</head>
44+
<body>
45+
<header>
46+
<h1>Iosevka Charon QA and Demo</h1>
47+
<p>
48+
This page hosts the generated proof reports and quick previews of the
49+
built TTFs. Font files are served directly from the <code>ttf/</code>
50+
directory for quick inspection.
51+
</p>
52+
<div class="reports">
53+
<h2>Reports</h2>
54+
<ul>
55+
<li><a href="proof/diffenator2-report.html">Diffenator2 proof</a></li>
56+
<li>
57+
<a href="fontbakery">FontBakery markdown reports</a>
58+
(per-family markdown files)
59+
</li>
60+
</ul>
61+
</div>
62+
</header>
63+
64+
<section id="fonts">
65+
<h2>Font demos</h2>
66+
<div id="font-container">Loading font previews…</div>
67+
</section>
68+
69+
<script>
70+
async function loadManifest() {
71+
try {
72+
const response = await fetch("./ttf_manifest.json");
73+
if (!response.ok) throw new Error("manifest not found");
74+
return await response.json();
75+
} catch (err) {
76+
console.error("Could not load manifest", err);
77+
document.getElementById("font-container").textContent =
78+
"TTF manifest could not be loaded.";
79+
return [];
80+
}
81+
}
82+
83+
function createCard(path, index) {
84+
const fontId = `demo-font-${index}`;
85+
const card = document.createElement("div");
86+
card.className = "font-card";
87+
88+
const title = document.createElement("div");
89+
title.textContent = path;
90+
card.appendChild(title);
91+
92+
const style = document.createElement("style");
93+
style.textContent = `@font-face { font-family: "${fontId}"; src: url("${path}") format("truetype"); font-display: swap; }`;
94+
card.appendChild(style);
95+
96+
const sample = document.createElement("div");
97+
sample.className = "sample";
98+
sample.style.fontFamily = fontId;
99+
sample.textContent = "The quick brown fox jumps over the lazy dog. 0123456789";
100+
card.appendChild(sample);
101+
102+
return card;
103+
}
104+
105+
async function render() {
106+
const container = document.getElementById("font-container");
107+
const manifest = await loadManifest();
108+
if (!manifest.length) {
109+
return;
110+
}
111+
112+
container.textContent = "";
113+
manifest.forEach((path, index) => {
114+
container.appendChild(createCard(path, index));
115+
});
116+
}
117+
118+
render();
119+
</script>
120+
</body>
19121
</html>

scripts/run-in-nix.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
#!/usr/bin/env bash
22
#
3-
# Run a command inside the Nix + uv development environment.
3+
# Run a command inside the Nix + uv development environment with a Docker fallback.
44

55
set -euo pipefail
66

77
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
88
export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}${ROOT_DIR}"
99

1010
if [ -n "${IN_NIX_SHELL:-}" ]; then
11+
echo "Already inside a Nix shell. Continuing execution..."
1112
exec "$@"
1213
fi
1314

14-
exec nix develop --experimental-features 'nix-command flakes' "$ROOT_DIR/sources#default" \
15-
--command bash "$0" "$@"
15+
if command -v nix >/dev/null 2>&1; then
16+
echo "Nix is available, entering nix shell..."
17+
exec nix develop --experimental-features 'nix-command flakes' "$ROOT_DIR/sources#default" --command "$ROOT_DIR/scripts/run-in-nix.sh" "$@"
18+
else
19+
echo "Nix is not available. Attempting to use Docker with Nix image."
20+
if command -v docker >/dev/null 2>&1; then
21+
echo "Docker is available, running script inside a Nix container."
22+
exec docker run --rm -v "$ROOT_DIR:/app" -w /app nixos/nix \
23+
nix develop --experimental-features 'nix-command flakes' ./sources#default --command /app/scripts/run-in-nix.sh "$@"
24+
else
25+
echo "Docker is not available. Please install either Nix or Docker to proceed."
26+
exit 1
27+
fi
28+
fi

sources/requirements.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file was autogenerated by uv via the following command:
2-
# uv pip compile /Users/julsh/git/googlefonts-project-template/sources/requirements.txt --output-file /Users/julsh/git/googlefonts-project-template/sources/requirements.lock --prerelease=allow
2+
# uv pip compile /workspace/iosevka-charon/sources/requirements.txt --output-file /workspace/iosevka-charon/sources/requirements.lock --prerelease=allow
33
absl-py==2.3.1
44
# via
55
# gftools

0 commit comments

Comments
 (0)