2024-05-24 16:45:59 +02:00
|
|
|
name: "CI"
|
|
|
|
|
|
|
|
on:
|
2024-05-24 16:47:14 +02:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2024-05-24 16:45:59 +02:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
2024-10-28 13:19:50 +01:00
|
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
|
|
# First day of a month
|
|
|
|
- cron: '0 0 1 * *'
|
2024-05-24 16:45:59 +02:00
|
|
|
|
|
|
|
jobs:
|
2024-05-24 18:15:38 +02:00
|
|
|
build:
|
2024-05-24 17:00:03 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-05-24 18:15:38 +02:00
|
|
|
- uses: actions/checkout@v4
|
2024-05-24 18:26:15 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2024-10-14 09:29:34 +02:00
|
|
|
- name: Get Core Sans
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
if: "!github.event.pull_request.head.repo.fork"
|
2024-08-20 15:48:55 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
repository: mainmatter/core-sans-a-fonts
|
|
|
|
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
|
|
path: core-sans-a-fonts
|
2024-10-14 09:29:34 +02:00
|
|
|
- name: Install Core Sans Font
|
|
|
|
if: "!github.event.pull_request.head.repo.fork"
|
2024-08-20 15:48:55 +02:00
|
|
|
run: |
|
|
|
|
sudo cp -r core-sans-a-fonts/* /usr/local/share/fonts/
|
|
|
|
sudo fc-cache -f -v
|
|
|
|
fc-list | grep "Core Sans"
|
2024-10-14 09:29:34 +02:00
|
|
|
- name: Use Fallback font for fork PRs
|
|
|
|
if: "github.event.pull_request.head.repo.fork"
|
|
|
|
run: |
|
|
|
|
sed -i 's/"BoldFont=CoreSansA65.ttf",//g' book/book.toml
|
|
|
|
sed -i 's/"ItalicFont=CoreSansA45It.ttf",//g' book/book.toml
|
|
|
|
sed -i 's/"BoldItalicFont=CoreSansA65It.ttf",//g' book/book.toml
|
|
|
|
sed -i 's/CoreSansA45.ttf/Open Sans:style=Regular/g' book/book.toml
|
2024-05-24 18:15:38 +02:00
|
|
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
2024-08-06 17:09:04 +02:00
|
|
|
- name: Install exercise plugin
|
2024-05-24 18:15:38 +02:00
|
|
|
run: cargo install --path helpers/mdbook-exercise-linker
|
2024-08-06 17:09:04 +02:00
|
|
|
- name: Install link shortener plugin
|
|
|
|
run: cargo install --path helpers/mdbook-link-shortener
|
2024-10-02 15:47:57 +02:00
|
|
|
- name: Install mdbook-pandoc, calibre, pdftk and related dependencies
|
2024-08-05 17:52:15 +02:00
|
|
|
run: |
|
|
|
|
cargo install mdbook-pandoc --locked --version 0.7.1
|
|
|
|
sudo apt-get update
|
2024-10-14 09:29:34 +02:00
|
|
|
sudo apt-get install -y fonts-noto fonts-open-sans calibre pdftk
|
|
|
|
sudo fc-cache -f -v
|
2024-08-05 17:52:15 +02:00
|
|
|
export PANDOC_VERSION=3.3
|
|
|
|
curl -LsSf https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz | tar zxf -
|
|
|
|
echo "$PWD/pandoc-${PANDOC_VERSION}/bin" >> $GITHUB_PATH
|
|
|
|
shell: bash
|
|
|
|
- name: Setup TeX Live
|
|
|
|
uses: teatimeguest/setup-texlive-action@v3
|
|
|
|
with:
|
|
|
|
packages:
|
|
|
|
scheme-basic
|
|
|
|
luatex
|
|
|
|
lualatex-math
|
|
|
|
luacolor
|
|
|
|
luatexbase
|
|
|
|
luaotfload
|
|
|
|
framed
|
|
|
|
unicode-math
|
|
|
|
xcolor
|
|
|
|
geometry
|
|
|
|
longtable
|
|
|
|
booktabs
|
|
|
|
array
|
|
|
|
lua-ul
|
|
|
|
etoolbox
|
|
|
|
fancyvrb
|
|
|
|
footnote
|
|
|
|
selnolig
|
|
|
|
natbib
|
|
|
|
csquotes
|
|
|
|
bookmark
|
|
|
|
xurl
|
|
|
|
amsmath
|
|
|
|
setspace
|
|
|
|
iftex
|
|
|
|
- name: Check `tlmgr` version
|
|
|
|
run: tlmgr --version
|
2024-05-24 18:15:38 +02:00
|
|
|
- uses: taiki-e/install-action@v2
|
|
|
|
with:
|
|
|
|
tool: mdbook
|
2024-05-24 16:45:59 +02:00
|
|
|
- name: Build book
|
2024-08-06 17:09:04 +02:00
|
|
|
env:
|
|
|
|
LINK_SHORTENER_VERIFY: "true"
|
2024-05-24 16:45:59 +02:00
|
|
|
run: |
|
|
|
|
cd book
|
2024-05-24 18:15:38 +02:00
|
|
|
mdbook build
|
2024-10-02 15:47:57 +02:00
|
|
|
- name: Add cover and back to downloadable PDF
|
|
|
|
run: |
|
|
|
|
pdftk book/assets/cover.pdf book/book/pandoc/pdf/100-exercises-to-learn-rust.pdf book/assets/back.pdf cat output book/book/pandoc/pdf/100-exercises-to-learn-rust-with-cover.pdf
|
|
|
|
mv book/book/pandoc/pdf/100-exercises-to-learn-rust-with-cover.pdf book/book/pandoc/pdf/100-exercises-to-learn-rust.pdf
|
2024-08-13 15:53:43 +02:00
|
|
|
- name: Convert HTML to ePUB
|
|
|
|
run: |
|
|
|
|
cd book/book/pandoc/html
|
|
|
|
sed -i 's|<code>\\newpage</code>{=latex}||g' 100-exercises-to-learn-rust.html
|
|
|
|
ebook-convert 100-exercises-to-learn-rust.html 100-exercises-to-learn-rust.epub \
|
|
|
|
--embed-all-fonts \
|
|
|
|
--subset-embedded-fonts
|
2024-05-24 16:45:59 +02:00
|
|
|
- name: Link Checker
|
|
|
|
uses: lycheeverse/lychee-action@v1
|
|
|
|
with:
|
|
|
|
fail: true
|
|
|
|
args: |
|
|
|
|
--exclude-loopback
|
|
|
|
--require-https
|
|
|
|
--no-progress
|
2024-08-05 17:52:15 +02:00
|
|
|
book/book/html/
|
|
|
|
# Upload the HTML book as an artifact
|
2024-05-24 18:15:38 +02:00
|
|
|
- uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: book
|
2024-08-05 17:52:15 +02:00
|
|
|
# When you support multiple formats, the output directory changes
|
|
|
|
# to include the format in its path.
|
|
|
|
path: book/book/html
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
|
|
with:
|
2024-08-06 17:09:04 +02:00
|
|
|
name: online-pdf
|
2024-08-05 17:52:15 +02:00
|
|
|
path: book/book/pandoc/pdf/100-exercises-to-learn-rust.pdf
|
2024-08-06 17:09:04 +02:00
|
|
|
- uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: paperback
|
|
|
|
path: book/book/pandoc/paperback/100-exercises-to-learn-rust.pdf
|
2024-08-13 15:53:43 +02:00
|
|
|
- uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: ePUB
|
|
|
|
path: book/book/pandoc/html/100-exercises-to-learn-rust.epub
|
2024-08-06 17:09:04 +02:00
|
|
|
|
|
|
|
is_fresh:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- run: sudo apt-get update && sudo apt-get install -y jq
|
|
|
|
- run: |
|
2024-08-06 17:34:08 +02:00
|
|
|
./helpers/json2redirects.sh book/link2alias.json > site/_redirects
|
2024-08-06 17:09:04 +02:00
|
|
|
# Verify nothing has changed, meaning that the redirect file is up-to-date
|
|
|
|
- run: |
|
2024-08-06 17:34:08 +02:00
|
|
|
git diff --exit-code site/_redirects
|
2024-05-24 18:15:38 +02:00
|
|
|
|
2024-11-08 14:50:09 +01:00
|
|
|
gravity:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [build]
|
|
|
|
steps:
|
|
|
|
- uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
path: book
|
2024-11-12 12:34:36 +01:00
|
|
|
pattern: online-pdf
|
2024-11-08 14:50:09 +01:00
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
with:
|
|
|
|
version: 9
|
2024-11-12 12:34:36 +01:00
|
|
|
- run: ls -las ./book
|
2024-11-08 14:50:09 +01:00
|
|
|
- name: Run Gravity
|
2024-11-12 12:34:36 +01:00
|
|
|
run: pnpm dlx @gravityci/cli "./book/**/*"
|
2024-11-08 14:50:09 +01:00
|
|
|
env:
|
|
|
|
GRAVITY_TOKEN: ${{ secrets.GRAVITY_TOKEN }}
|
|
|
|
|
2024-05-24 18:15:38 +02:00
|
|
|
formatter:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: dprint/check@v2.2
|