Escaped dollar symbols causing italic in english version #122
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Render book | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
render-books: | |
name: Render books | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Extract branch name | |
if: github.event_name != 'pull_request' | |
shell: bash | |
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV | |
id: extract_branch | |
- name: Extract branch name on pull request | |
if: github.event_name == 'pull_request' | |
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get version | |
run: | | |
version=$(cat ./VERSION) | |
version=${version##+( )} # Trim left whitespaces | |
version=${version%%+( )} # Trim right whitespaces | |
echo "BOOK_VERSION=$version" >> $GITHUB_ENV | |
echo "version : $version" | |
- name: Checking version format | |
run: | | |
if ! [[ $BOOK_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(-[0-9]+)?)?$ ]] | |
then | |
echo "Invalid version format. Check your ./VERSION file." | |
exit 1 | |
fi | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%B %Y')" | |
- name: Install pandoc | |
run: | | |
wget https://github.com/jgm/pandoc/releases/download/2.9.2.1/pandoc-2.9.2.1-1-amd64.deb | |
sudo dpkg -i pandoc-2.9.2.1-1-amd64.deb | |
sudo apt-get update && sudo apt-get install -y make texlive texlive-xetex texlive-latex-extra texlive-fonts-recommended pdftk | |
- name: Configure pdftk | |
run: | | |
sudo sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml | |
- name: Install mainfont | |
run: | | |
mkdir -p "$HOME/.local/share/fonts" | |
cp ./fra/templates/fonts/* "$HOME/.local/share/fonts" | |
cp ./eng/templates/fonts/* "$HOME/.local/share/fonts" | |
- name: Render PDF | |
run: | | |
sed -i -E "s/date: .+/date: ${{ steps.date.outputs.date }} - ${{ env.BOOK_VERSION }}/g" ./fra/metadata.yml | |
sed -i -E "s/date: .+/date: ${{ steps.date.outputs.date }} - ${{ env.BOOK_VERSION }}/g" ./eng/metadata.yml | |
cd ./fra && make pdf && cd - | |
mv ./fra/build/pdf/book.pdf ./fra/build/pdf/book-fra.pdf | |
cd ./eng && make pdf && cd - | |
mv ./eng/build/pdf/book.pdf ./eng/build/pdf/book-eng.pdf | |
- name: Render HTML | |
run: | | |
cd ./fra && make html && cd - | |
cd ./eng && make html && cd - | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: book-fra-pdf-${{ env.BOOK_VERSION }} | |
path: ./fra/build/pdf/book-fra.pdf | |
retention-days: 1 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: book-fra-html-${{ env.BOOK_VERSION }} | |
path: ./fra/build/html/ | |
retention-days: 1 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: book-eng-pdf-${{ env.BOOK_VERSION }} | |
path: ./eng/build/pdf/book-eng.pdf | |
retention-days: 1 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: book-eng-html-${{ env.BOOK_VERSION }} | |
path: ./eng/build/html/ | |
retention-days: 1 | |
# Pictures in the book may be referenced at some place in the text. | |
# Ex: \ref{fig:name} in the text to reference the \label{fig:name} illustration. | |
# | |
# When badly referenced, pandoc generates a double questionmarks ("??") in the place | |
# of the latex tags. This Action checks if there are no "??" in the generated PDF. | |
check-latex-references: | |
needs: render-books | |
name: Check valid latex references | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install poppler-utils | |
run: | | |
sudo apt-get update && sudo apt-get install -y poppler-utils | |
- name: Get version | |
run: | | |
version=$(cat ./VERSION) | |
version=${version##+( )} # Trim left whitespaces | |
version=${version%%+( )} # Trim right whitespaces | |
echo "BOOK_VERSION=$version" >> $GITHUB_ENV | |
echo "version : $version" | |
- name: Checking version format | |
run: | | |
if ! [[ $BOOK_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(-[0-9]+)?)?$ ]] | |
then | |
echo "Invalid version format. Check your ./VERSION file." | |
exit 1 | |
fi | |
- name: Download FR artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book-fra-pdf-${{ env.BOOK_VERSION }} | |
path: ./ | |
- name: Get FR text from book | |
run: | | |
pdftotext ./book-fra.pdf | |
- name: Get FR text from book | |
run: | | |
if grep -q "??" ./book-fra.pdf; then | |
echo "The file contains the string '??'" | |
else | |
echo "The file does not contain the string '??'" | |
fi | |
- name: Download EN artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book-eng-pdf-${{ env.BOOK_VERSION }} | |
path: ./ | |
- name: Get EN text from book | |
run: | | |
pdftotext ./book-eng.pdf | |
- name: Get EN text from book | |
run: | | |
if grep -q "??" ./book-eng.pdf; then | |
echo "The file contains the string '??'" | |
else | |
echo "The file does not contain the string '??'" | |
fi | |
check-version-change: | |
name: "Check version change" | |
runs-on: ubuntu-22.04 | |
needs: check-latex-references | |
outputs: | |
version_changed: ${{ steps.check.outputs.version_changed }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.sha }} | |
fetch-depth: 2 | |
- name: Get Previous Commit | |
id: prev_commit | |
run: echo "::set-output name=sha::$(git log --skip=1 -n 1 --pretty=format:'%H')" | |
- name: Check VERSION file change | |
id: check | |
run: | | |
if git diff --name-only ${{ steps.prev_commit.outputs.sha }} ${{ github.sha }} | grep '^VERSION$'; then | |
echo "VERSION file was modified." | |
echo "::set-output name=version_changed::true" | |
else | |
echo "VERSION file was not modified." | |
echo "::set-output name=version_changed::false" | |
fi | |
deploy-to-gh-pages: | |
if: needs.check-version-change.outputs.version_changed == 'true' && (github.ref == 'refs/heads/main') | |
needs: check-version-change | |
runs-on: ubuntu-22.04 | |
name: Deploy to GitHub Pages | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Get version | |
run: | | |
version=$(cat ./VERSION) | |
version=${version##+( )} # Trim left whitespaces | |
version=${version%%+( )} # Trim right whitespaces | |
echo "BOOK_VERSION=$version" >> $GITHUB_ENV | |
echo "version : $version" | |
- name: Checking version format | |
run: | | |
if ! [[ $BOOK_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(-[0-9]+)?)?$ ]] | |
then | |
echo "Invalid version format. Check your ./VERSION file." | |
exit 1 | |
fi | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book-fra-html-${{ env.BOOK_VERSION }} | |
path: output/fra/ | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book-eng-html-${{ env.BOOK_VERSION }} | |
path: output/eng/ | |
- name: Optimize images | |
run: | | |
sudo apt-get install -y jpegoptim optipng | |
find ./output/ -iname '*.jpg' -exec jpegoptim {} \; -o -iname '*.png' -exec optipng {} \; | |
- name: Copy default index files | |
run: | | |
cp ./index.html ./output/ | |
cp -r ./images ./output/ | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: output/ | |
full_commit_message: Publishing version ${{ env.BOOK_VERSION }} - ${{ github.event.head_commit.message }} | |
cname: book-devops.berwick.fr | |
release: | |
if: needs.check-version-change.outputs.version_changed == 'true' && (github.ref == 'refs/heads/main') | |
needs: check-version-change | |
runs-on: ubuntu-22.04 | |
name: Generate book files for release | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Get version | |
run: | | |
version=$(cat ./VERSION) | |
version=${version##+( )} # Trim left whitespaces | |
version=${version%%+( )} # Trim right whitespaces | |
echo "BOOK_VERSION=$version" >> $GITHUB_ENV | |
echo "version : $version" | |
- name: Checking version format | |
run: | | |
if ! [[ $BOOK_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(-[0-9]+)?)?$ ]] | |
then | |
echo "Invalid version format. Check your ./VERSION file." | |
exit 1 | |
fi | |
- name: Download FR PDF artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book-fra-pdf-${{ env.BOOK_VERSION }} | |
path: ./ | |
- name: Download EN PDF artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book-eng-pdf-${{ env.BOOK_VERSION }} | |
path: ./ | |
- name: Get version | |
id: get-version | |
run: | | |
VERSION_CONTENT=$(cat VERSION) | |
echo "::set-output name=version::$VERSION_CONTENT" | |
if [[ $VERSION_CONTENT == *"-alpha"* ]] || [[ $VERSION_CONTENT == *"-beta"* ]] || [[ $VERSION_CONTENT == *"-rc"* ]]; then | |
echo "::set-output name=prerelease::true" | |
else | |
echo "::set-output name=prerelease::false" | |
fi | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ env.BOOK_VERSION }} | |
tag_name: ${{ env.BOOK_VERSION }} | |
files: | | |
./book-fra.pdf | |
./book-eng.pdf | |
prerelease: ${{ steps.get-version.outputs.prerelease }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} |