Skip to content

Commit 42f972c

Browse files
authored
Merge pull request #205 from jiangshengdev/ci-pdf
feat(ci): add GitHub Actions workflow for PDF generation
2 parents 4e84ff7 + 6fa953c commit 42f972c

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/generate-pdf.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Generate Tutorial PDF
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
submodules: 'recursive'
19+
20+
- name: Setup Environment
21+
run: |
22+
sudo apt update
23+
sudo apt install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-xetex fonts-freefont-otf texlive-fonts-recommended texlive-lang-chinese tex-gyre
24+
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
25+
sudo apt-get install -y nodejs
26+
npm install -g @mermaid-js/mermaid-cli
27+
sudo apt-get install -y python3-sphinx
28+
sudo apt-get install -y python3-pip
29+
30+
- name: Apply Patch
31+
run: |
32+
git apply --reject scripts/latexpdf.patch
33+
34+
- name: Install Python Dependencies
35+
run: |
36+
pip install -r requirements.txt
37+
38+
- name: Generate PDF
39+
run: |
40+
make latexpdf
41+
42+
- name: Upload PDF to Artifacts
43+
uses: actions/upload-artifact@v2
44+
with:
45+
name: tutorial-pdf
46+
path: build/latex/rcore-tutorial-book-v3.pdf
47+
48+
- name: Get Current Date and Time
49+
id: datetime
50+
run: echo "::set-output name=datetime::$(date +'%Y%m%d-%H%M')"
51+
52+
- name: Create Release
53+
id: create_release
54+
uses: actions/create-release@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
tag_name: ${{ steps.datetime.outputs.datetime }}
59+
release_name: Release ${{ steps.datetime.outputs.datetime }}
60+
draft: false
61+
prerelease: false
62+
63+
- name: Upload PDF to Release
64+
uses: actions/upload-release-asset@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
upload_url: ${{ steps.create_release.outputs.upload_url }}
69+
asset_path: ./build/latex/rcore-tutorial-book-v3.pdf
70+
asset_name: rcore-tutorial-book-v3.pdf
71+
asset_content_type: application/pdf

0 commit comments

Comments
 (0)