Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/actions/fontcustom/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Test with `docker build -t fontcustom . && docker run --rm -it fontcustom`
FROM ruby:2.7.8-alpine

# https://wiki.alpinelinux.org/wiki/GCC, including make; needed for custom builds and gem installs.
RUN apk add --no-cache build-base
# Needed for custom builds of sfnt2woff and woff2.
RUN apk add --no-cache git

# Workaround for
# > Error installing fontcustom:
# > The last version of ffi (~> 1.0) to support your Ruby & RubyGems was 1.17.0.
# > Try installing it with `gem install ffi -v 1.17.0` and then running the current command again
# > ffi requires RubyGems version >= 3.3.22. The current RubyGems version is 3.1.6.
# > Try 'gem update --system' to update RubyGems itself.
# As an additional workaround for "gem update --system" erroring with:
# > Error installing rubygems-update:
# > There are no versions of rubygems-update (= 3.5.14) compatible with your Ruby & RubyGems
# > rubygems-update requires Ruby version >= 3.0.0. The current ruby version is 2.7.8.225.
# downgrading to specific version because Rubygems 3.5 dropped support for Ruby 2.7.x
# https://blog.rubygems.org/2023/12/15/3.5.0-released.html
RUN gem update --system 3.4.22

# Install fontcustom with all required dependencies (fontforge, python2, sfnt2woff, woff2).
RUN gem install fontcustom --version 2.0.0
RUN apk add --no-cache fontforge --repository=https://dl-cdn.alpinelinux.org/alpine/v3.17/community
RUN apk add --no-cache python2 --repository=https://dl-cdn.alpinelinux.org/alpine/v3.15/community

WORKDIR /tmp
RUN git -c advice.detachedHead=false clone --branch v1.3.1 --depth 1 https://github.com/bramstein/sfnt2woff-zopfli.git \
&& cd sfnt2woff-zopfli \
&& make \
&& mv sfnt2woff-zopfli sfnt2woff
ENV PATH="$PATH:/tmp/sfnt2woff-zopfli"

# Alternatively: RUN apk add --no-cache woff2
WORKDIR /tmp
RUN git -c advice.detachedHead=false clone --branch v1.0.2 --depth 1 --recursive https://github.com/google/woff2.git \
&& cd woff2 \
&& make clean all
ENV PATH="$PATH:/tmp/woff2"

COPY fontcustom.sh entrypoint.sh
ENTRYPOINT ["/tmp/entrypoint.sh"]
15 changes: 15 additions & 0 deletions .github/actions/fontcustom/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "fontcustom"
description: "Build a font from SVG files using fontcustom."

inputs:
working-directory:
description: |
Working directory in local file system.
Cannot use step.*.working-directory, because it's not available with Actions only runs:.
required: true

runs:
using: docker
image: Dockerfile
args:
- ${{ inputs.working-directory }}
5 changes: 5 additions & 0 deletions .github/actions/fontcustom/fontcustom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -l
set -eo pipefail

cd "$1"
fontcustom compile
10 changes: 10 additions & 0 deletions .github/actions/iconfont/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Build iconfont"
description: "Build iconfont from SVG files using fontcustom."

runs:
using: composite
steps:
- name: "Build iconfont"
uses: ./.github/actions/fontcustom
with:
working-directory: sources/iconfont
32 changes: 2 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,8 @@ jobs:
with:
submodules: true

- name: "Setup old Ruby."
uses: ruby/setup-ruby@v1
with:
# ruby-version: sources/iconfont/.ruby-version # So checkout is needed.
working-directory: sources/iconfont
bundler-cache: false
cache-version: 0 # Increment this number if you need to re-download cached gems.

- name: "Install fontcustom with all dependencies."
working-directory: sources/iconfont
run: "${GITHUB_WORKSPACE}/.github/workflows/install-fontcustom.sh"

- name: "Build iconfont."
working-directory: sources/iconfont
run: fontcustom compile
uses: ./.github/actions/iconfont

- name: "Upload 'iconfont' artifact."
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -164,24 +151,9 @@ jobs:
submodules: true
ref: ${{ steps.params.outputs.sha }}

- name: "Setup old Ruby."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: ruby/setup-ruby@v1
with:
# ruby-version: sources/iconfont/.ruby-version # So checkout is needed.
working-directory: sources/iconfont
bundler-cache: false
cache-version: 0 # Increment this number if you need to re-download cached gems.

- name: "Install fontcustom with all dependencies."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: sources/iconfont
run: "${GITHUB_WORKSPACE}/.github/workflows/install-fontcustom.sh"

- name: "Build iconfont."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: sources/iconfont
run: fontcustom compile
uses: ./.github/actions/iconfont

- name: "Setup Ruby."
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/install-fontcustom.sh

This file was deleted.