Skip to content

generate woff2 fonts from ttf fonts #3893

generate woff2 fonts from ttf fonts

generate woff2 fonts from ttf fonts #3893

Workflow file for this run

name: generate woff2 fonts from ttf fonts
on:
# runs every 6 hours
schedule:
- cron: '0 */6 * * *'
# allow manually trigger
workflow_dispatch:
concurrency: generate
jobs:
check:
runs-on: ubuntu-latest
outputs:
need-build: ${{ steps.check.outputs.need-build }}
latest-version: ${{ steps.check.outputs.latest-version }}
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: check
id: check
run: |
# get the latest version
LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/jonz94/Sarasa-Gothic-Nerd-Fonts/releases/latest | jq -r .tag_name | cut -d v -f 2)
echo latest version of jonz94/Sarasa-Gothic-Nerd-Fonts is ${LATEST_VERSION}
# get the current version
CURRENT_VERSION=$(cat ${GITHUB_WORKSPACE}/ci/VERSION)
echo current version is ${CURRENT_VERSION}
if [[ "$LATEST_VERSION" == "$CURRENT_VERSION" ]]; then
echo everything is up to date!
echo "::set-output name=need-build::false"
else
echo a newer version is available
echo "::set-output name=need-build::true"
echo "::set-output name=latest-version::${LATEST_VERSION}"
fi
build:
runs-on: ubuntu-latest
needs: check
if: ${{ needs.check.outputs.need-build == 'true' }}
strategy:
matrix:
styles: ['fixed', 'fixed-slab', 'mono', 'mono-slab', 'term', 'term-slab', 'gothic', 'ui']
orthographies: ['cl', 'hc', 'j', 'k', 'sc', 'tc']
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: download sarasa ${{ matrix.styles }} ${{ matrix.orthographies }} fonts
run: |
LATEST_VERSION="${{ needs.check.outputs.latest-version }}"
echo downloading Sarasa Gothic Nerd Fonts ${LATEST_VERSION}
curl -L https://github.com/jonz94/Sarasa-Gothic-Nerd-Fonts/releases/download/v${LATEST_VERSION}/sarasa-${{ matrix.styles }}-${{ matrix.orthographies }}-nerd-font.zip --create-dirs -o ${GITHUB_WORKSPACE}/ci/inputs/sarasa.zip
unzip ${GITHUB_WORKSPACE}/ci/inputs/sarasa.zip -d ${GITHUB_WORKSPACE}/ci/inputs
rm ${GITHUB_WORKSPACE}/ci/inputs/sarasa.zip
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: generate woff2 fonts for sarasa ${{ matrix.styles }} ${{ matrix.orthographies }}
run: |
# generate woff2 fonts using fonttools
pip install fonttools brotli
python ${GITHUB_WORKSPACE}/ci/scripts/main.py
- name: zip patched font files
run: zip -r sarasa-${{ matrix.styles }}-${{ matrix.orthographies }}-nerd-font-woff2.zip ${GITHUB_WORKSPACE}/ci/outputs/*.woff2
- name: upload zip
uses: actions/upload-artifact@v3
with:
name: sarasa-${{ matrix.styles }}-${{ matrix.orthographies }}-nerd-font-woff2.zip
path: sarasa-${{ matrix.styles }}-${{ matrix.orthographies }}-nerd-font-woff2.zip
commit-and-tag:
name: commit and tag
runs-on: ubuntu-latest
needs: [check, build]
steps:
- uses: actions/checkout@v3
with:
ref: main
token: ${{ secrets.WORKFLOW_PERSONAL_ACCESS_TOKEN }}
- name: commit
run: |
LATEST_VERSION="${{ needs.check.outputs.latest-version }}"
echo $LATEST_VERSION > ${GITHUB_WORKSPACE}/ci/VERSION
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
git commit -m "馃 ci: update fonts to v${LATEST_VERSION}"
git push -f origin main
git tag -a v${LATEST_VERSION} -m "馃帀 build: release version v${LATEST_VERSION}"
git push origin --tags