From 085c108888fa8ef2703cc21146932a6943841f5f Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Thu, 3 Jun 2021 15:10:22 +0800 Subject: [PATCH] ci: refine build process (#673) --- .github/ci/build_variants.sh | 17 +++++++ .github/ci/install-ubuntu-miktex.sh | 32 ------------ .github/ci/install-ubuntu-texlive.sh | 76 ---------------------------- .github/ci/texlive-ubuntu.profile | 12 ----- .github/workflows/build.yml | 41 ++++++--------- .github/workflows/release.yml | 51 +++++++++++++++++++ .gitignore | 2 + 7 files changed, 86 insertions(+), 145 deletions(-) create mode 100755 .github/ci/build_variants.sh delete mode 100755 .github/ci/install-ubuntu-miktex.sh delete mode 100755 .github/ci/install-ubuntu-texlive.sh delete mode 100644 .github/ci/texlive-ubuntu.profile create mode 100644 .github/workflows/release.yml diff --git a/.github/ci/build_variants.sh b/.github/ci/build_variants.sh new file mode 100755 index 00000000..873ca57d --- /dev/null +++ b/.github/ci/build_variants.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +rm -rf build +mkdir -p build + +sed -e "s|documentclass\[.*\]|documentclass\[type=bachelor\]|g" main.tex > build/build-bachelor.tex +sed -e "s|documentclass\[.*\]|documentclass\[type=master\]|g" main.tex > build/build-master.tex + +echo "--- Bachelor Template ---" +head build/build-bachelor.tex + +echo "--- Master Template ---" +head build/build-master.tex + +latexmk $@ -outdir=build build/build-*.tex diff --git a/.github/ci/install-ubuntu-miktex.sh b/.github/ci/install-ubuntu-miktex.sh deleted file mode 100755 index b71ee43e..00000000 --- a/.github/ci/install-ubuntu-miktex.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Change default package repository -export REPO=https://mirrors.rit.edu/CTAN/systems/win32/miktex - -# Install MiKTeX -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D6BC243565B2087BC3F897C9277A7293F59E4889 -echo "deb ${REPO}/setup/deb/ $(lsb_release -cs) universe" | sudo tee /etc/apt/sources.list.d/miktex.list -sudo apt-get update -qq -sudo apt-get install -y --no-install-recommends ghostscript miktex - -# Finish the setup -sudo miktexsetup finish -sudo initexmf --admin --set-config-value=[MPM]AutoInstall=1 -sudo mpm --admin --set-repository=$REPO/tm/packages/ -sudo mpm --admin --update-db -sudo initexmf --admin --update-fndb - -# Set user-specific TEXMF root directories -export MIKTEX_USERCONFIG=$HOME/.miktex/texmfs/config -export MIKTEX_USERDATA=$HOME/.miktex/texmfs/data -export MIKTEX_USERINSTALL=$HOME/.miktex/texmfs/install - -# Synchronize user-specific databases -mpm --update-db -initexmf --update-fndb - -# Update MiKTeX -sudo mpm --admin --update --verbose -mpm --update --verbose diff --git a/.github/ci/install-ubuntu-texlive.sh b/.github/ci/install-ubuntu-texlive.sh deleted file mode 100755 index cf423fa3..00000000 --- a/.github/ci/install-ubuntu-texlive.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Change default package repository -export REPO=https://mirrors.rit.edu/CTAN/systems/texlive/tlnet - -# See if there is a cached version of TeX Live available -export PATH=/tmp/texlive/bin/x86_64-linux:$PATH -echo "/tmp/texlive/bin/x86_64-linux" >> $GITHUB_PATH - -if ! command -v texlua > /dev/null; then - # Obtain TeX Live - wget $REPO/install-tl-unx.tar.gz - tar -xzf install-tl-unx.tar.gz - cd install-tl-20* - - # Install a minimal system - ./install-tl --profile ../.github/ci/texlive-ubuntu.profile --repository $REPO - cd .. -else - # Update TeX Live install but add nothing new - tlmgr update --self --all --no-auto-install -fi - -# Install TeX Live packages -tlmgr install \ - algorithm2e \ - alphalph \ - biber \ - biblatex \ - biblatex-gb7714-2015 \ - booktabs \ - caption \ - chngcntr \ - cjk \ - ctex \ - enumitem \ - environ \ - eso-pic \ - etoolbox \ - everysel \ - fandol \ - filehook \ - fontspec \ - footmisc \ - hologo \ - ifoddpage \ - latexmk \ - listings \ - logreq \ - multirow \ - newtx \ - ntheorem \ - pageslts \ - pdflscape \ - pdfpages \ - pgf \ - physics \ - relsize \ - silence \ - siunitx \ - tex-gyre \ - threeparttable \ - threeparttablex \ - tocloft \ - translator \ - trimspaces \ - txfonts \ - undolabl \ - xcolor \ - xecjk \ - xetex \ - xkeyval \ - xstring \ - zhnumber diff --git a/.github/ci/texlive-ubuntu.profile b/.github/ci/texlive-ubuntu.profile deleted file mode 100644 index f4930bcc..00000000 --- a/.github/ci/texlive-ubuntu.profile +++ /dev/null @@ -1,12 +0,0 @@ -selected_scheme scheme-basic -TEXDIR /tmp/texlive -TEXMFLOCAL /tmp/texlive/texmf-local -TEXMFSYSCONFIG /tmp/texlive/texmf-config -TEXMFSYSVAR /tmp/texlive/texmf-var -TEXMFHOME $TEXMFLOCAL -TEXMFCONFIG $TEXMFSYSCONFIG -TEXMFVAR $TEXMFSYSVAR -instopt_portable 1 -tlpdbopt_autobackup 0 -tlpdbopt_install_docfiles 0 -tlpdbopt_install_srcfiles 0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 234ac640..523ef24e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,48 +11,39 @@ on: name: Build jobs: - build-texlive: + build-xelatex: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 name: checkout code - - name: cache texlive installation - uses: actions/cache@v2 + - uses: xu-cheng/texlive-action/full@v1 with: - path: | - /tmp/texlive - key: ${{ runner.os }}-texlive - - run: .github/ci/install-ubuntu-texlive.sh - name: install texlive - - run: latexmk -quiet -halt-on-error -time main.tex - name: build - - run: cat main.log + run: | + .github/ci/build_variants.sh -halt-on-error -time -quiet -xelatex + name: build with XeLaTeX + - run: cat build/build-*.log name: display build log if: ${{ failure() || success() }} - uses: actions/upload-artifact@v2 with: - path: main.pdf + path: build/build-*.pdf + name: build-xelatex name: upload build artifacts - - build-miktex: + build-lualatex: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 name: checkout code - - name: cache miktex installation - uses: actions/cache@v2 + - uses: xu-cheng/texlive-action/full@v1 with: - path: | - ~/.miktex - key: ${{ runner.os }}-miktex - - run: .github/ci/install-ubuntu-miktex.sh - name: install miktex - - run: latexmk -quiet -halt-on-error -time main.tex - name: build - - run: cat main.log + run: | + .github/ci/build_variants.sh -halt-on-error -time -quiet -lualatex + name: build with LuaLaTeX + - run: cat build/build-*.log name: display build log if: ${{ failure() || success() }} - uses: actions/upload-artifact@v2 with: - path: main.pdf + path: build/build-*.pdf + name: build-lualatex name: upload build artifacts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..483b5d96 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +on: + push: + branches: + - release + tags: + - "v*" + +name: Release + +jobs: + release-xelatex: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + name: checkout code + - uses: xu-cheng/texlive-action/full@v1 + with: + run: | + .github/ci/build_variants.sh -halt-on-error -time -quiet -xelatex + name: build with XeLaTeX + - run: cat build/build-*.log + name: display build log + if: ${{ failure() || success() }} + - uses: actions/create-release@latest + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: ${{ github.event.head_commit.message }} + draft: true + prerelease: true + - name: add build-bachelor + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: build/build-bachelor.pdf + asset_name: build-bachelor.pdf + asset_content_type: application/pdf + - name: add build-master + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: build/build-master.pdf + asset_name: build-master.pdf + asset_content_type: application/pdf diff --git a/.gitignore b/.gitignore index f1948553..78604ad9 100644 --- a/.gitignore +++ b/.gitignore @@ -252,3 +252,5 @@ ehthumbs_vista.db # Project specific main.pdf thesis-bot.yml + +build/