Skip to content

Build for TRPL

Build for TRPL #1056

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://fonts.google.com/download?family=Noto%20Sans
unzip Noto_Sans.zip -d fonts/Noto_Sans
curl -sL -o Noto_Sans_SC.zip https://fonts.google.com/download?family=Noto%20Sans%20SC
unzip Noto_Sans_SC.zip -d fonts/Noto_Sans_SC
curl -sL -o Noto_Sans_Mono.zip https://fonts.google.com/download?family=Noto%20Sans%20Mono
unzip Noto_Sans_Mono.zip -d fonts/Noto_Sans_Mono
rm -fv fonts/Noto_Sans_Mono/NotoSansMono-VariableFont_wdth,wght.ttf
curl -sL -o Noto_Sans_KR.zip https://fonts.google.com/download?family=Noto%20Sans%20KR
unzip Noto_Sans_KR.zip -d fonts/Noto_Sans_KR
curl -sL -o Noto_Sans_Thai.zip https://fonts.google.com/download?family=Noto%20Sans%20Thai
unzip Noto_Sans_Thai.zip -d fonts/Noto_Sans_Thai
rm -fv fonts/Noto_Sans_Thai/NotoSansThai-VariableFont_wdth,wght.ttf
curl -sL -o Noto_Sans_Arabic.zip https://fonts.google.com/download?family=Noto%20Sans%20Arabic
unzip Noto_Sans_Arabic.zip -d fonts/Noto_Sans_Arabic
curl -sL -o Noto_Sans_Hebrew.zip https://fonts.google.com/download?family=Noto%20Sans%20Hebrew
unzip Noto_Sans_Hebrew.zip -d fonts/Noto_Sans_Hebrew
curl -sL -o Noto_Sans_Devanagari.zip https://fonts.google.com/download?family=Noto%20Sans%20Devanagari
unzip Noto_Sans_Devanagari.zip -d fonts/Noto_Sans_Devanagari
rm -fv fonts/Noto_Sans_Devanagari/NotoSansDevanagari-VariableFont_wdth,wght.ttf
curl -sL -o Noto_Emoji.zip https://fonts.google.com/download?family=Noto%20Emoji
unzip Noto_Emoji.zip -d fonts/Noto_Emoji
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
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