From 954a40e18d6f80dcb5a583dbecc69b2fd3a324e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Thu, 11 Jul 2024 00:36:41 +0100 Subject: [PATCH 1/5] Replace iconfont building with docker --- .github/actions/fontcustom/Dockerfile | 44 ++++++++++++++++++++++++ .github/actions/fontcustom/action.yml | 15 ++++++++ .github/actions/fontcustom/fontcustom.sh | 5 +++ .github/actions/iconfont/action.yml | 10 ++++++ .github/workflows/ci.yml | 32 ++--------------- .github/workflows/install-fontcustom.sh | 34 ------------------ 6 files changed, 76 insertions(+), 64 deletions(-) create mode 100644 .github/actions/fontcustom/Dockerfile create mode 100644 .github/actions/fontcustom/action.yml create mode 100644 .github/actions/fontcustom/fontcustom.sh create mode 100644 .github/actions/iconfont/action.yml delete mode 100755 .github/workflows/install-fontcustom.sh diff --git a/.github/actions/fontcustom/Dockerfile b/.github/actions/fontcustom/Dockerfile new file mode 100644 index 0000000..74dab5b --- /dev/null +++ b/.github/actions/fontcustom/Dockerfile @@ -0,0 +1,44 @@ +# 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 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 iconfont sources/iconfont +COPY fontcustom.sh entrypoint.sh +ENTRYPOINT ["./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 100644 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 From a81777495d522cf3c05aef6e5b9e1739d32d6a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Thu, 11 Jul 2024 00:38:49 +0100 Subject: [PATCH 2/5] Don't copy test folder --- .github/actions/fontcustom/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/fontcustom/Dockerfile b/.github/actions/fontcustom/Dockerfile index 74dab5b..ac0a270 100644 --- a/.github/actions/fontcustom/Dockerfile +++ b/.github/actions/fontcustom/Dockerfile @@ -39,6 +39,5 @@ RUN git -c advice.detachedHead=false clone --branch v1.0.2 --depth 1 --recursive && make clean all ENV PATH="$PATH:/tmp/woff2" -COPY iconfont sources/iconfont COPY fontcustom.sh entrypoint.sh ENTRYPOINT ["./entrypoint.sh"] From 97468e2c371518cb1e2015b81541b85a1fadf88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Thu, 11 Jul 2024 00:40:29 +0100 Subject: [PATCH 3/5] Add more no-cache --- .github/actions/fontcustom/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/fontcustom/Dockerfile b/.github/actions/fontcustom/Dockerfile index ac0a270..f96af9b 100644 --- a/.github/actions/fontcustom/Dockerfile +++ b/.github/actions/fontcustom/Dockerfile @@ -23,7 +23,7 @@ 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 python2 --repository=https://dl-cdn.alpinelinux.org/alpine/v3.15/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 \ From 01e26f298cf64d873fdc58dfe044998bace91df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Thu, 11 Jul 2024 00:41:26 +0100 Subject: [PATCH 4/5] Absolute path --- .github/actions/fontcustom/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/fontcustom/Dockerfile b/.github/actions/fontcustom/Dockerfile index f96af9b..6ae6b39 100644 --- a/.github/actions/fontcustom/Dockerfile +++ b/.github/actions/fontcustom/Dockerfile @@ -40,4 +40,4 @@ RUN git -c advice.detachedHead=false clone --branch v1.0.2 --depth 1 --recursive ENV PATH="$PATH:/tmp/woff2" COPY fontcustom.sh entrypoint.sh -ENTRYPOINT ["./entrypoint.sh"] +ENTRYPOINT ["/tmp/entrypoint.sh"] From a90c5c937941c13e25806f3ab40f8e7c964e62a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Thu, 11 Jul 2024 01:06:05 +0100 Subject: [PATCH 5/5] x --- .github/actions/fontcustom/fontcustom.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/actions/fontcustom/fontcustom.sh diff --git a/.github/actions/fontcustom/fontcustom.sh b/.github/actions/fontcustom/fontcustom.sh old mode 100644 new mode 100755