|
22 | 22 | - name: Set up Git repository
|
23 | 23 | uses: actions/checkout@v4
|
24 | 24 |
|
| 25 | + - name: Cache Fonts |
| 26 | + uses: actions/cache@v4 |
| 27 | + id: cache-fonts |
| 28 | + with: |
| 29 | + path: fonts |
| 30 | + key: ${{ runner.os }}-fonts-noto_sans_sc-lxgwwenkai |
| 31 | + |
| 32 | + - name: Download Fonts |
| 33 | + if: steps.cache-fonts.outputs.cache-hit != 'true' |
| 34 | + run: | |
| 35 | + if [ -f "${{ env.TYPST_FONT_PATH }}/NotoSansSC-Regular.ttf" ]; then |
| 36 | + echo "Font already existed." |
| 37 | + else |
| 38 | + # Download font metadata |
| 39 | + mkdir -p cv |
| 40 | + curl -sL "https://fonts.google.com/download/list?family=Noto%20Sans%20SC" > cv/noto_sans_sc_raw.txt |
| 41 | +
|
| 42 | + # Remove ")]}'" from the beginning of the file |
| 43 | + tail -c +5 cv/noto_sans_sc_raw.txt > cv/noto_sans_sc_metadata.json |
| 44 | +
|
| 45 | + # Extract the necessary information from the JSON file |
| 46 | + file_refs=$(jq -rc '.manifest.fileRefs[]' cv/noto_sans_sc_metadata.json) |
| 47 | +
|
| 48 | + # Download, save the font file to /fonts |
| 49 | + mkdir -p ${{ env.TYPST_FONT_PATH }} |
| 50 | + while IFS= read -r file_ref; do |
| 51 | + filename=$(echo "$file_ref" | jq -r '.filename') |
| 52 | + url=$(echo "$file_ref" | jq -r '.url') |
| 53 | + fontname=$(basename "$filename") |
| 54 | + echo $url $fontname |
| 55 | + curl -L "$url" -o "${{ env.TYPST_FONT_PATH }}/$fontname" |
| 56 | + done <<< "$file_refs" |
| 57 | + ls -l ${{ env.TYPST_FONT_PATH }} |
| 58 | + fi |
| 59 | + for form in Light Regular Bold; do |
| 60 | + curl -L "https://github.com/lxgw/LxgwWenKai/releases/download/v1.330/LXGWWenKai-$form.ttf" -o "${{ env.TYPST_FONT_PATH }}/LXGWWenKai-$form.ttf" |
| 61 | + done |
| 62 | +
|
25 | 63 | - name: Prepare Mkdocs environment
|
26 | 64 | run: |
|
27 | 65 | pip install mkdocs
|
|
77 | 115 | > GitHub 卡顿,无法下载?访问 [小彭老师自己维护的镜像](${{ env.MIRROR_SITE_URL }}/cppguidebook.pdf)。
|
78 | 116 | > 喜欢在线阅读?访问 [GitHub Pages](https://parallel101.github.io/cppguidebook)
|
79 | 117 | tag_name: ${{ steps.tag.outputs.release_tag }}
|
80 |
| - files: |
81 |
| - - cppguidebook.pdf |
82 |
| - - cppguidebook-site.zip |
| 118 | + files: | |
| 119 | + cppguidebook.pdf |
| 120 | + cppguidebook-site.zip |
83 | 121 |
|
84 | 122 | - name: Publish to mirror site
|
85 | 123 | continue-on-error: true
|
|
0 commit comments