Skip to content

Commit 5c08beb

Browse files
committed
Add build-font composite action and wire build/release workflows
Pulls the existing build steps (Docker image, run.sh, samples, diff check) into .github/actions/build-font, plus a pytest step and a release-artifact generation step that runs unconditionally. build.yml invokes the composite action with version=0.0-dev on every push and PR — exercising the full versioning pipeline so release-time surprises are caught at PR review. release.yml fires on release: published, invokes the composite action with the release tag name as the version, and uploads the five versioned assets (.otf, .ttf, .woff, .woff2, .js) to the release with gh release upload.
1 parent c04d5c1 commit 5c08beb

3 files changed

Lines changed: 123 additions & 49 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build xkcd-script font
2+
description: Build the unversioned font, run the diff check, generate versioned release artifacts, and upload dist/ as a workflow artifact.
3+
4+
inputs:
5+
version:
6+
description: 'Version to bake into release artifacts (e.g. 2026.0, or 0.0-dev for non-release CI).'
7+
required: true
8+
push-image:
9+
description: 'Whether to push the fontbuilder Docker image to GHCR.'
10+
required: false
11+
default: 'false'
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Log in to GitHub Container Registry
17+
if: inputs.push-image == 'true'
18+
uses: docker/login-action@v3
19+
with:
20+
registry: ghcr.io
21+
username: ${{ github.actor }}
22+
password: ${{ env.GITHUB_TOKEN }}
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Build (and optionally push) Docker image
28+
uses: docker/build-push-action@v6
29+
with:
30+
context: xkcd-script/generator
31+
load: true
32+
push: ${{ inputs.push-image }}
33+
tags: ghcr.io/ipython/xkcd-font:fontbuilder
34+
cache-from: type=gha
35+
cache-to: type=gha,mode=max
36+
37+
- name: Generate font
38+
shell: bash
39+
run: FONTBUILDER_IMAGE=ghcr.io/ipython/xkcd-font:fontbuilder xkcd-script/generator/run.sh
40+
41+
- name: Generate samples
42+
shell: bash
43+
run: xkcd-script/samples/preview.sh
44+
45+
- name: Check generated files match committed files
46+
shell: bash
47+
run: |
48+
git diff --exit-code xkcd-script/font/ xkcd-script/samples/ || {
49+
echo ""
50+
echo "Generated files differ from committed files."
51+
echo "Download the 'xkcd-script-font-${{ inputs.version }}' artifact from this run and commit the updated unversioned files (xkcd-script.{otf,ttf,woff,sfd} and the sample PNGs)."
52+
exit 1
53+
}
54+
55+
- name: Run pytest
56+
shell: bash
57+
run: |
58+
docker run --rm -v "$PWD":/repo -w /repo ghcr.io/ipython/xkcd-font:fontbuilder \
59+
python3 -m pytest xkcd-script/generator/tests/ -v
60+
61+
- name: Generate release artifacts
62+
shell: bash
63+
run: |
64+
rm -rf dist
65+
docker run --rm -v "$PWD":/repo -w /repo ghcr.io/ipython/xkcd-font:fontbuilder \
66+
python3 xkcd-script/generator/generate_release_artifacts.py \
67+
--version "${{ inputs.version }}" \
68+
--font-dir xkcd-script/font \
69+
--js xkcd-script/xkcd-mathjax3.js \
70+
--out-dir dist
71+
72+
- name: Upload unversioned + release artifacts
73+
uses: actions/upload-artifact@v4
74+
if: always()
75+
with:
76+
name: xkcd-script-font-${{ inputs.version }}
77+
path: |
78+
xkcd-script/font/xkcd-script.otf
79+
xkcd-script/font/xkcd-script.ttf
80+
xkcd-script/font/xkcd-script.woff
81+
xkcd-script/font/xkcd-script.sfd
82+
xkcd-script/samples/ipsum.png
83+
xkcd-script/samples/handwriting.png
84+
xkcd-script/samples/kerning.png
85+
dist/**

.github/workflows/build.yml

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,11 @@ jobs:
1212
permissions:
1313
contents: read
1414
packages: write
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1517
steps:
1618
- uses: actions/checkout@v4
17-
18-
- name: Log in to GitHub Container Registry
19-
if: github.event_name == 'push'
20-
uses: docker/login-action@v3
19+
- uses: ./.github/actions/build-font
2120
with:
22-
registry: ghcr.io
23-
username: ${{ github.actor }}
24-
password: ${{ secrets.GITHUB_TOKEN }}
25-
26-
- name: Set up Docker Buildx
27-
uses: docker/setup-buildx-action@v3
28-
29-
- name: Build (and push on master) Docker image
30-
uses: docker/build-push-action@v6
31-
with:
32-
context: xkcd-script/generator
33-
load: true
34-
push: ${{ github.event_name == 'push' }}
35-
tags: ghcr.io/ipython/xkcd-font:fontbuilder
36-
cache-from: type=gha
37-
cache-to: type=gha,mode=max
38-
39-
- name: Generate font
40-
run: FONTBUILDER_IMAGE=ghcr.io/ipython/xkcd-font:fontbuilder xkcd-script/generator/run.sh
41-
42-
- name: Generate samples
43-
run: xkcd-script/samples/preview.sh
44-
45-
- name: Upload generated artifacts
46-
uses: actions/upload-artifact@v4
47-
if: always()
48-
with:
49-
name: xkcd-script-font
50-
path: |
51-
xkcd-script/font/xkcd-script.otf
52-
xkcd-script/font/xkcd-script.ttf
53-
xkcd-script/font/xkcd-script.woff
54-
xkcd-script/font/xkcd-script.sfd
55-
xkcd-script/samples/ipsum.png
56-
xkcd-script/samples/handwriting.png
57-
xkcd-script/samples/kerning.png
58-
59-
- name: Check generated files match committed files
60-
run: |
61-
git diff --exit-code xkcd-script/font/ xkcd-script/samples/ || {
62-
echo ""
63-
echo "Generated files differ from committed files."
64-
echo "Download the 'xkcd-script-font' artifact from this run and commit the updated files."
65-
exit 1
66-
}
21+
version: 0.0-dev
22+
push-image: ${{ github.event_name == 'push' }}

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-upload:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
packages: write
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.release.tag_name }}
19+
20+
- uses: ./.github/actions/build-font
21+
with:
22+
version: ${{ github.event.release.tag_name }}
23+
push-image: 'true'
24+
25+
- name: Upload assets to the release
26+
run: |
27+
gh release upload "${{ github.event.release.tag_name }}" \
28+
dist/xkcd-script-${{ github.event.release.tag_name }}.otf \
29+
dist/xkcd-script-${{ github.event.release.tag_name }}.ttf \
30+
dist/xkcd-script-${{ github.event.release.tag_name }}.woff \
31+
dist/xkcd-script-${{ github.event.release.tag_name }}.woff2 \
32+
dist/xkcd-mathjax3-${{ github.event.release.tag_name }}.js \
33+
--clobber

0 commit comments

Comments
 (0)