Skip to content

Split Fonts

Split Fonts #8

Workflow file for this run

name: Split Fonts
on:
workflow_dispatch:
jobs:
build:
name: get the fonts
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
node-version: '>=18.0.0'
registry-url: https://registry.npmjs.org
- name: Download fonts
id: down
uses: robinraju/[email protected]
with:
repository: lxgw/LxgwWenKai-Screen
latest: true
out-file-path: "tmp"
- name: Split fonts
run: |
npm install cn-font-split -g
rm -rf ./fonts/
rm -rf ./style.css
rm -rf ./VERSION
for i in $(echo "$(ls ./tmp)" | grep -i '\.ttf$')
do
font_name=$(echo "$i" | sed -E 's/(.+)\.ttf$/\1/i' | tr '[:upper:]' '[:lower:]')
cn-font-split -i=./tmp/$i -o=./fonts/$font_name --renameOutputFont='[index][ext]'
echo "@import url('./$font_name/result.css');" >> ./style.css
done
echo "${{ steps.down.outputs.tag_name }}" >> VERSION
mv VERSION fonts/VERSION
mv style.css fonts/style.css
rm -rf ./tmp/
- name: Auto Minify
uses: nizarmah/[email protected]
- name: Commit files
run: |
# mv style.min.css fonts/style.min.css
cd fonts || exit 1
git init
git config user.email github-actions[bot]@users.noreply.github.com
git config user.name github-actions[bot]
git checkout -b latest
git status
git add .
git commit -m "update ${{ steps.down.outputs.tag_name }}" -a
git tag ${{ steps.down.outputs.tag_name }}
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
tags: true
directory: fonts
branch: latest
- name: Edit package.json And Publish
run: |
git checkout main -- package.json
mv package.json fonts/package.json
cd fonts
VER=$(cat VERSION)
NORMALIZED_VERSION=$(echo $VER | sed 's/^v//' | awk -F. '{if($3==null) print$1"."$2".0"; else print$0}')
npm version $NORMALIZED_VERSION --no-git-tag-version
- run: |
cd fonts
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}