-
Notifications
You must be signed in to change notification settings - Fork 2
155 lines (136 loc) · 4.29 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: ci
on:
push:
branches:
- master
- main
tags:
- "*"
permissions:
contents: write
jobs:
build:
name: Build MkDocs Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git Credentials
env:
GH_TOKEN: ${{ secrets.MKDOCS_MATERIALS_INSIDER_PAT }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git config --global url."https://${GH_TOKEN}@github.com/".insteadOf "[email protected]:"
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Cache Poetry dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Ubuntu dependencies
run: |
sudo apt-get update
sudo apt install -y pngquant ghostscript
- uses: abatilo/actions-poetry@v2
- run: poetry install
- name: Cache MkDocs build directory
uses: actions/cache@v4
with:
path: ./build
key: ${{ runner.os }}-mkdocs-build-${{ hashFiles('docs/**/*.md', 'mkdocs.yml') }}
restore-keys: |
${{ runner.os }}-mkdocs-build-
- name: Build Documentation with MkDocs
env:
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ secrets.MKDOCS_GIT_COMMITTERS_APIKEY }}
GH_TOKEN: ${{ secrets.MKDOCS_GIT_COMMITTERS_APIKEY }}
run: CI=true poetry run mkdocs gh-deploy --force
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: latex
path: ./build
book:
name: Build LaTeX Book
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: latex
path: ./build
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ hashFiles('Dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
driver: "docker-container"
buildkitd-flags: --oci-worker=true --oci-worker-gc=false
- name: Build Docker image
run: |
docker buildx build --cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
--load \
-t latex-ycr:latest .
- name: Build LaTeX Book (using Docker)
run: make ci
- name: Upload PDF Artifact
uses: actions/upload-artifact@v4
with:
name: PDF
path: build/book/output-print.pdf
release:
name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
needs: book
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download PDF Artifact
uses: actions/download-artifact@v4
with:
name: PDF
path: ./build
- name: Rename PDF file
run: |
mv ./build/output-print.pdf ./build/handbook.pdf
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body: "Release notes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/handbook.pdf
asset_name: handbook.pdf
asset_content_type: application/pdf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}