diff --git a/.github/actions/fontcustom/Dockerfile b/.github/actions/fontcustom/Dockerfile new file mode 100644 index 0000000..6ae6b39 --- /dev/null +++ b/.github/actions/fontcustom/Dockerfile @@ -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"] diff --git a/.github/actions/fontcustom/action.yml b/.github/actions/fontcustom/action.yml new file mode 100644 index 0000000..394c449 --- /dev/null +++ b/.github/actions/fontcustom/action.yml @@ -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 }} diff --git a/.github/actions/fontcustom/fontcustom.sh b/.github/actions/fontcustom/fontcustom.sh new file mode 100755 index 0000000..981b1ab --- /dev/null +++ b/.github/actions/fontcustom/fontcustom.sh @@ -0,0 +1,5 @@ +#!/bin/sh -l +set -eo pipefail + +cd "$1" +fontcustom compile diff --git a/.github/actions/iconfont/action.yml b/.github/actions/iconfont/action.yml new file mode 100644 index 0000000..463b31d --- /dev/null +++ b/.github/actions/iconfont/action.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 578aae6..22be7f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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' }} diff --git a/.github/workflows/install-fontcustom.sh b/.github/workflows/install-fontcustom.sh deleted file mode 100755 index 1314ebb..0000000 --- a/.github/workflows/install-fontcustom.sh +++ /dev/null @@ -1,34 +0,0 @@ -set -eo pipefail - -mkdir -p fontcustom && cd fontcustom - -# 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 -gem update --system 3.4.22 - -gem install fontcustom --version 2.0.0 - -sudo apt-get install fontforge=1:20201107~dfsg-4build1 - -git -c advice.detachedHead=false clone --branch v1.3.1 --depth 1 https://github.com/bramstein/sfnt2woff-zopfli.git \ - && pushd sfnt2woff-zopfli \ - && make \ - && mv sfnt2woff-zopfli sfnt2woff \ - && echo "${PWD}" >> "${GITHUB_PATH}" \ - && popd - -git -c advice.detachedHead=false clone --branch v1.0.2 --depth 1 --recursive https://github.com/google/woff2.git \ - && pushd woff2 \ - && make clean all \ - && echo "${PWD}" >> "${GITHUB_PATH}" \ - && popd