Skip to content

Commit a1aff38

Browse files
committed
refactor release ci
1 parent 66b6ee2 commit a1aff38

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.github/workflows/generate_release_pdf.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ on:
1010
- '**.md'
1111

1212
env:
13-
TYPST_FILE_NAME: book
13+
TYPST_FILE_NAME: cppguidebook
1414
TYPST_FONT_PATH: fonts
15+
MIRROR_SITE_URL: https://142857.red
16+
MIRROR_SITE_TOKEN: ${{ env.SEVEN_TOKEN }}
1517

1618
jobs:
1719
build_typst:
@@ -52,12 +54,12 @@ jobs:
5254
url=$(echo "$file_ref" | jq -r '.url')
5355
fontname=$(basename "$filename")
5456
echo $url $fontname
55-
curl "$url" -o "${{ env.TYPST_FONT_PATH }}/$fontname"
57+
curl -L "$url" -o "${{ env.TYPST_FONT_PATH }}/$fontname"
5658
done <<< "$file_refs"
5759
ls -l ${{ env.TYPST_FONT_PATH }}
5860
fi
5961
for form in Light Regular Bold; do
60-
curl -sSL "https://github.com/lxgw/LxgwWenKai/releases/download/v1.330/LXGWWenKai-$form.ttf" -o "${{ env.TYPST_FONT_PATH }}/LXGWWenKai-$form.ttf"
62+
curl -L "https://github.com/lxgw/LxgwWenKai/releases/download/v1.330/LXGWWenKai-$form.ttf" -o "${{ env.TYPST_FONT_PATH }}/LXGWWenKai-$form.ttf"
6163
done
6264
6365
- name: Prepare Typst environment
@@ -68,6 +70,11 @@ jobs:
6870
typst fonts --variants --font-path ${{ env.TYPST_FONT_PATH }}
6971
typst compile ${{ env.TYPST_FILE_NAME }}.typ ${{ env.TYPST_FILE_NAME }}.pdf --font-path ${{ env.TYPST_FONT_PATH }}
7072
73+
- name: Publish to mirror site
74+
continue-on-error: true
75+
run: |
76+
curl -X PUT -L ${{ env.MIRROR_SITE_URL }}/${{ env.TYPST_FILE_NAME }}.pdf -d @file=${{ env.TYPST_FILE_NAME }}.pdf -d token=${{ env.MIRROR_SITE_TOKEN }}
77+
7178
- name: Delete old Release
7279
uses: actions/github-script@v5
7380
with:
@@ -89,6 +96,8 @@ jobs:
8996
uses: softprops/action-gh-release@v1
9097
with:
9198
name: 伟大,无需多言
92-
body: 小彭老师发布的最新 C++ 大典,更新时间 ${{ steps.tag.outputs.release_date }}
99+
body: |
100+
小彭老师发布的最新 C++ 大典,更新时间 ${{ steps.tag.outputs.release_date }}
101+
> Release 页面太慢?GitHub 卡顿,无法下载?访问 [小彭老师自己维护的镜像](${{ env.MIRROR_SITE_URL }}/${{ env.TYPST_FILE_NAME }}.pdf)。
93102
tag_name: ${{ steps.tag.outputs.release_date }}
94103
files: ${{ env.TYPST_FILE_NAME }}.pdf

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Release 页面太慢?GitHub 卡顿,无法下载?访问 [小彭老师自己
1616
1717
## 你也可以参与编写的开源小册
1818

19-
本书完全开源,源文件为 [`book.typ`](book.typ)
19+
本书完全开源,源文件为 [`cppguidebook.typ`](cppguidebook.typ)
2020

2121
如果发现书写问题,或者你有想加入的新章节,有关于 C++ 新想法,新技巧分享给大家,可以提交 [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) 来帮助小彭老师一起写书。
2222

@@ -28,7 +28,7 @@ Release 页面太慢?GitHub 卡顿,无法下载?访问 [小彭老师自己
2828

2929
Typst 语言书写的 `.typ` 源文件编译后,得到可供阅读的 `.pdf` 文件。
3030

31-
克隆本仓库后,可以用 `typst compile book.typ` 命令编译生成 `book.pdf` 文件,也可以用 [`typst-preview`](https://github.com/Enter-tainer/typst-preview`) 等工具,一边修改源文件,一边实时预览效果。
31+
克隆本仓库后,可以用 `typst compile cppguidebook.typ` 命令编译生成 `cppguidebook.pdf` 文件,也可以用 [`typst-preview`](https://github.com/Enter-tainer/typst-preview`) 等工具,一边修改源文件,一边实时预览效果。
3232

3333
> 以下是第一章节的内容预览,要查看全文,请前往 Release 页面下载完整 PDF 文件。
3434

book.typ cppguidebook.typ

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// https://www.fonts.net.cn/fonts-zh/tag-kaiti-1.html
2-
31
#set text(
42
font: "Noto Serif CJK SC",
53
size: 7pt,

0 commit comments

Comments
 (0)