Skip to content

Build for TRPL

Build for TRPL #1145

Workflow file for this run

name: Build for TRPL
on:
push:
branches:
- master
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
repository_dispatch:
jobs:
build_and_deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Update rustup
run: rustup self update
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.74.1 -c rust-docs
rustup default 1.74.1
- name: Install mdbook
run: |
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.36/mdbook-v0.4.36-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "$(pwd)/bin" >> ${GITHUB_PATH}
- name: Clone trpl book
run: git clone https://x-access-token:${GITHUB_TOKEN}@github.com/rust-lang/book.git trpl-en
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clone trpl book
run: git clone https://x-access-token:${GITHUB_TOKEN}@github.com/KaiserY/trpl-zh-cn.git trpl-zh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install mdbook-typst-pdf
run: |
curl -sL -o bin/mdbook-typst-pdf https://github.com/KaiserY/mdbook-typst-pdf/releases/download/0.1.2/mdbook-typst-pdf-x86_64-unknown-linux-gnu
chmod +x bin/mdbook-typst-pdf
echo "$(pwd)/bin" >> ${GITHUB_PATH}
- name: Install font
run: |
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
sudo apt-get -y install msttcorefonts
mkdir fonts
mkdir -p ~/.local/share/fonts
curl -sL -o Noto_Sans.zip https://github.com/notofonts/latin-greek-cyrillic/releases/download/NotoSans-v2.013/NotoSans-v2.013.zip
unzip Noto_Sans.zip -d fonts/Noto_Sans
curl -sL -o Noto_Sans_SC.zip https://github.com/notofonts/noto-cjk/releases/download/Sans2.004/08_NotoSansCJKsc.zip
unzip Noto_Sans_SC.zip -d fonts/Noto_Sans_SC
curl -sL -o Noto_Sans_Mono.zip https://github.com/notofonts/latin-greek-cyrillic/releases/download/NotoSansMono-v2.014/NotoSansMono-v2.014.zip
unzip Noto_Sans_Mono.zip -d fonts/Noto_Sans_Mono
curl -sL -o Noto_Sans_KR.zip https://github.com/notofonts/noto-cjk/releases/download/Sans2.004/07_NotoSansCJKkr.zip
unzip Noto_Sans_KR.zip -d fonts/Noto_Sans_KR
curl -sL -o Noto_Sans_Thai.zip https://github.com/notofonts/thai/releases/download/NotoSansThai-v2.002/NotoSansThai-v2.002.zip
unzip Noto_Sans_Thai.zip -d fonts/Noto_Sans_Thai
curl -sL -o Noto_Sans_Arabic.zip https://github.com/notofonts/arabic/releases/download/NotoNaskhArabic-v2.018/NotoNaskhArabic-v2.018.zip
unzip Noto_Sans_Arabic.zip -d fonts/Noto_Sans_Arabic
curl -sL -o Noto_Sans_Devanagari.zip https://github.com/notofonts/devanagari/releases/download/NotoSansDevanagari-v2.004/NotoSansDevanagari-v2.004.zip
unzip -: Noto_Sans_Devanagari.zip -d fonts/Noto_Sans_Devanagari
curl -sL -o NotoColorEmoji.ttf https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf
mv NotoColorEmoji.ttf fonts/NotoColorEmoji.ttf
curl -sL -o times_sans_serif.zip https://dl.dafont.com/dl/?f=times_sans_serif
unzip times_sans_serif.zip -d fonts/times_sans_serif
curl -sOL https://github.com/notofonts/hebrew/releases/download/NotoSansHebrew-v2.003/NotoSansHebrew-v2.003.zip
unzip -: NotoSansHebrew-v2.003.zip
mv -v NotoSansHebrew fonts/
mv fonts/* ~/.local/share/fonts/
fc-cache -rv
- name: init oss config
uses: yizhoumo/setup-ossutil@v1
with:
ossutil-version: '1.7.3'
endpoint: ${{secrets.OSS_ENDPOINT}}
access-key-id: ${{secrets.OSS_ID}}
access-key-secret: ${{secrets.OSS_SECRET}}
sts-token: ""
- name: Build trpl book
run: |
# Build trpl book
mkdir -pv trpl-archive/{en,zh}
cd trpl-en && \
mdbook build && \
cp -ar book/* ../trpl-archive/en/
cd ../trpl-zh && \
mdbook build && \
ls -al && \
cp -ar book/html/* ../trpl-archive/zh/
cp "book/typst-pdf/Rust 程序设计语言 简体中文版.pdf" ../trpl-archive/zh/
# Upload to oss
ls -alhtr && \
cd .. && \
ossutil sync trpl-archive/ oss://${{ secrets.OSS_BUCKET }}/trpl/ -f --delete
- name: Sending Build Status
if: always()
env:
DINGTALK_ACCESS_TOKEN: ${{ secrets.DINGTALK_ACCESS_TOKEN }}
DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }}
JOB_STATE: ${{ job.status }}
RUNNER_OS: ${{ runner.os }}
GITHUB_REF: ${{ github.ref }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_WORKFLOW: ${{ env.GITHUB_WORKFLOW }}
run: python3 notify.py