Skip to content

Download fonts

Download fonts #457

Workflow file for this run

name: Download fonts
on:
workflow_dispatch:
schedule:
- cron: "0 19 * * *"
push:
branches:
- main
paths-ignore:
- "**/README.md"
jobs:
Update:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@main
- name: Set variables
run: |
echo "misans_download_url=https://hyperos.mi.com/font-download/MiSans.zip" >> ${GITHUB_ENV}
echo "firacode_download_url=https://github.com/ryanoasis/nerd-fonts/releases/download" >> ${GITHUB_ENV}
echo "sarasa_download_url=https://github.com/be5invis/Sarasa-Gothic/releases/download" >> ${GITHUB_ENV}
echo "lxgw_download_url=https://github.com/lxgw/LxgwWenKai/releases/download" >> ${GITHUB_ENV}
echo "source_download_url=https://github.com/adobe-fonts/source-han-serif/releases/download" >> ${GITHUB_ENV}
echo "noto_download_url=https://raw.githubusercontent.com/googlefonts/noto-emoji/main/fonts/NotoColorEmoji_WindowsCompatible.ttf" >> ${GITHUB_ENV}
shell: bash
- name: Download `MiSans`
run: |
mkdir -p ./tmp/ ./MiSans/ ./fonts/
wget -P ./tmp/ "${misans_download_url}"
unzip -o ./tmp/MiSans.zip -d ./tmp/
misans_time=$(date -d "$(stat -c %y "./tmp/MiSans/otf/MiSans-Regular.otf")" +"%Y-%m-%d")
echo "misans_time=$misans_time" >> ${GITHUB_ENV}
cp -f ./tmp/MiSans/otf/MiSans-* ./MiSans/
rm -rf ./tmp*
- name: Download `FiraCode Nerd`
run: |
mkdir -p ./tmp/FiraCode-Nerd/ ./FiraCode-Nerd/
firacode_version=$(curl -sSL https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest | jq -r '.tag_name')
echo "firacode_version=$firacode_version" >> ${GITHUB_ENV}
firacode_time=$(curl -sSL https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest | jq -r '.created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
echo "firacode_time=$firacode_time" >> ${GITHUB_ENV}
wget -P ./tmp/ "${firacode_download_url}/${firacode_version}/FiraCode.zip"
unzip -o ./tmp/FiraCode.zip -d ./tmp/FiraCode-Nerd/
cp -f ./tmp/FiraCode-Nerd/FiraCodeNerdFontMono-* ./FiraCode-Nerd/
rm -rf ./tmp*
- name: Download `Sarasa Gothic`
run: |
mkdir -p ./tmp/Sarasa-Gothic/ ./Sarasa-Gothic/
sarasa_version=$(curl -sSL https://api.github.com/repos/be5invis/Sarasa-Gothic/releases/latest | jq -r '.tag_name' | sed 's/^v//')
echo "sarasa_version=$sarasa_version" >> ${GITHUB_ENV}
sarasa_time=$(curl -sSL https://api.github.com/repos/be5invis/Sarasa-Gothic/releases/latest | jq -r '.created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
echo "sarasa_time=$sarasa_time" >> ${GITHUB_ENV}
wget -P ./tmp/ "${sarasa_download_url}/v${sarasa_version}/SarasaMonoSC-TTF-${sarasa_version}.7z"
7z x "./tmp/SarasaMonoSC-TTF-${sarasa_version}.7z" -otmp/Sarasa-Gothic/
cp -f ./tmp/Sarasa-Gothic/SarasaMonoSC-* ./Sarasa-Gothic/
rm -rf ./tmp*
- name: Download `LxgwWenKai`
run: |
mkdir -p ./tmp/LxgwWenKai/ ./LxgwWenKai/
lxgw_version=$(curl -sSL https://api.github.com/repos/lxgw/LxgwWenKai/releases/latest | jq -r '.tag_name')
echo "lxgw_version=$lxgw_version" >> ${GITHUB_ENV}
lxgw_time=$(curl -sSL https://api.github.com/repos/lxgw/LxgwWenKai/releases/latest | jq -r '.created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
echo "lxgw_time=$lxgw_time" >> ${GITHUB_ENV}
wget -P ./tmp/ "${lxgw_download_url}/${lxgw_version}/lxgw-wenkai-${lxgw_version}.zip"
unzip -o "./tmp/lxgw-wenkai-${lxgw_version}.zip" -d ./tmp/
cp -f ./tmp/lxgw-wenkai-${lxgw_version}/LXGWWenKai-* ./LxgwWenKai/
rm -rf ./tmp*
- name: Download `Source Han Serif`
run: |
mkdir -p ./tmp/Source-Han-Serif/ ./Source-Han-Serif/
source_version=$(curl -sSL https://api.github.com/repos/adobe-fonts/source-han-serif/releases/latest | jq -r '.tag_name')
echo "source_version=$source_version" >> ${GITHUB_ENV}
source_time=$(curl -sSL https://api.github.com/repos/adobe-fonts/source-han-serif/releases/latest | jq -r '.created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
echo "source_time=$source_time" >> ${GITHUB_ENV}
wget -P ./tmp/ "${source_download_url}/${source_version}/09_SourceHanSerifSC.zip"
unzip -o ./tmp/09_SourceHanSerifSC.zip -d ./tmp/
cp -f ./tmp/OTF/SimplifiedChinese/SourceHanSerifSC-* ./Source-Han-Serif/
rm -rf ./tmp*
- name: Download `Noto Color Emoji`
run: |
mkdir -p ./Noto-Color-Emoji/
noto_version=$(curl -sSL https://raw.githubusercontent.com/googlefonts/noto-emoji/main/NotoColorEmoji.tmpl.ttx.tmpl | grep 'fontRevision' | awk -F'"' '{print $2}')
echo "noto_version=$noto_version" >> ${GITHUB_ENV}
noto_time=$(curl -sSL https://raw.githubusercontent.com/googlefonts/noto-emoji/main/NotoColorEmoji.tmpl.ttx.tmpl | grep 'created' | awk -F'"' '{print $2}' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
echo "noto_time=$noto_time" >> ${GITHUB_ENV}
wget -P ./Noto-Color-Emoji/ "${noto_download_url}"
- name: Zip `MiSans`
uses: montudor/action-zip@v1
with:
args: zip -qq -r ./fonts/MiSans.zip ./MiSans/
- name: Zip `FiraCode Nerd`
uses: montudor/action-zip@v1
with:
args: zip -qq -r ./fonts/FiraCode-Nerd.zip ./FiraCode-Nerd/
- name: Zip `Sarasa Gothic`
uses: montudor/action-zip@v1
with:
args: zip -qq -r ./fonts/Sarasa-Gothic.zip ./Sarasa-Gothic/
- name: Zip `LxgwWenKai`
uses: montudor/action-zip@v1
with:
args: zip -qq -r ./fonts/LxgwWenKai.zip ./LxgwWenKai/
- name: Zip `Source Han Serif`
uses: montudor/action-zip@v1
with:
args: zip -qq -r ./fonts/Source-Han-Serif.zip ./Source-Han-Serif/
- name: Zip `Noto Color Emoji`
uses: montudor/action-zip@v1
with:
args: zip -qq -r ./fonts/Noto-Color-Emoji.zip ./Noto-Color-Emoji/
- name: Release and upload `fonts` assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: fonts
tag: fonts
overwrite: true
body: |
更新 [MiSans](https://hyperos.mi.com/font) 字体,发布于 ${{ env.misans_time }}
更新 [FiraCode Nerd](https://github.com/ryanoasis/nerd-fonts) 字体至 ${{ env.firacode_version }},发布于 ${{ env.firacode_time }}
更新 [Sarasa Gothic](https://github.com/be5invis/Sarasa-Gothic) 字体至 v${{ env.sarasa_version }},发布于 ${{ env.sarasa_time }}
更新 [LxgwWenKai](https://github.com/lxgw/LxgwWenKai) 字体至 ${{ env.lxgw_version }},发布于 ${{ env.lxgw_time }}
更新 [Source Han Serif](https://github.com/adobe-fonts/source-han-serif) 字体至 v${{ env.source_version }},发布于 ${{ env.source_time }}
更新 [Noto Color Emoji](https://github.com/googlefonts/noto-emoji) 字体至 v${{ env.noto_version }},发布于 ${{ env.noto_time }}
file_glob: true
file: ./fonts/*
- name: Delete old workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 3
keep_minimum_runs: 1