From 337d8d2b9f84eec14b39cdc95552a4f56d301337 Mon Sep 17 00:00:00 2001 From: zydou Date: Tue, 29 Aug 2023 12:19:02 +0800 Subject: [PATCH] feat: add `ubuntu` series base image --- .github/workflows/test.yml | 42 +++++++++++++++++++++++--------------- README.md | 42 ++++++++++++++++++-------------------- action.yml | 18 +++++++++++++--- 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8d04df..4c5d88a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,14 +15,18 @@ on: - cron: 0 12 1 * * workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: strategy: fail-fast: false matrix: texlive_version: [2018, 2019, 2020, 2021, 2022, 2023, latest] - debian_release: [buster, bullseye, bookworm, trixie] - name: Test ${{matrix.texlive_version}}-${{matrix.debian_release}} + base_image: [buster, bullseye, bookworm, trixie, xenial, bionic, focal, jammy] + name: Test ${{matrix.texlive_version}}-${{matrix.base_image}} runs-on: ubuntu-latest steps: - name: Set up Git repository @@ -32,7 +36,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: test.tex working_directory: test/ @@ -40,7 +44,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: test.tex working_directory: test/ pre_compile: | @@ -52,7 +56,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: | file1.tex file2.tex @@ -62,7 +66,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: glob_test*.tex working_directory: test/ @@ -70,7 +74,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: subdir*/main.tex working_directory: test/ work_in_root_file_dir: true @@ -79,7 +83,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: extglob/!(subdir3)_glob/*.tex working_directory: test/ work_in_root_file_dir: true @@ -88,7 +92,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: globstar/**/*.tex working_directory: test/ work_in_root_file_dir: true @@ -97,7 +101,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: math.tex working_directory: test/ @@ -105,7 +109,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: biblatex.tex working_directory: test/ @@ -113,15 +117,17 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: eps.tex working_directory: test/ - name: Compile LaTeX document with minted and lualatex + # skip for xenial and bionic because of pygments issue + if: matrix.base_image != 'xenial' && matrix.base_image != 'bionic' uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: minted.tex working_directory: test/ latexmk_shell_escape: true @@ -135,7 +141,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: extra_fonts.tex working_directory: test/ latexmk_use_xelatex: true @@ -145,7 +151,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: graphviz.tex working_directory: test/ compiler: arara @@ -156,7 +162,7 @@ jobs: uses: ./ with: texlive_version: ${{ matrix.texlive_version }} - debian_release: ${{ matrix.debian_release }} + base_image: ${{ matrix.base_image }} root_file: | error.tex not_error.tex @@ -203,6 +209,8 @@ jobs: run: file test/eps.pdf | grep -q ' PDF ' - name: Test minted and lualatex (minted.tex) + # skip for xenial and bionic because of pygments issue + if: matrix.base_image != 'xenial' && matrix.base_image != 'bionic' run: file test/minted.pdf | grep -q ' PDF ' - name: Test extra_fonts (extra_fonts.tex) @@ -219,6 +227,6 @@ jobs: - name: Upload uses: actions/upload-artifact@v3 with: - name: texlive-${{ matrix.texlive_version }}-${{ matrix.debian_release }} + name: texlive-${{ matrix.texlive_version }}-${{ matrix.base_image }} path: test if: always() diff --git a/README.md b/README.md index 31ae795..d020ec4 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ This is a GitHub Action to compile LaTeX documents, and it's based on [xu-cheng/ | | **Original** | **This Action** | | ----------------------- | ------------ | --------------- | -| base image | Alpine | Debian | +| base image | Alpine | Debian & Ubuntu | | install system packages | apk add | apt-get install | -| choose texlive version | ✅ | ✅ | -| choose base image | / | ✅ | +| change texlive version | ✅ | ✅ | +| change base image | / | ✅ | -The main difference is that this action uses `Debian` as the base image, whereas the original uses `Alpine`. Certain tools require `glibc` to function properly. With Debian OS, you won't encounter any glibc-related issues and can use `apt-get` to install a wider range of packages compared to using `apk` in Alpine. For instance, the Alpine-based image lacks the [xindy package](https://github.com/xu-cheng/latex-action/issues/32). +The main difference is that this action uses `Debian` or `Ubuntu` as the base image, whereas the original uses `Alpine`. Certain tools require `glibc` to function properly. Within debian or ubuntu, you won't encounter any glibc-related issues and can use `apt-get` to install a wider range of packages compared to using `apk` in Alpine. For instance, the Alpine-based image lacks the [xindy package](https://github.com/xu-cheng/latex-action/issues/32). -In addition, this action also allows you to specify the TeX Live version and the Debian release version through input parameters. In contrast, the original action requires the use of different tags to specify the TeX Live version. The advantage of this is that you can easily use `matrix` syntax to build your document with multiple TeX Live versions. For example: +In addition, this action also allows you to specify the TeX Live version and the base image version through input parameters. ~~In contrast, the original action requires the use of different tags to specify the TeX Live version.~~ The advantage of this is that you can easily use `matrix` syntax to build your document with multiple TeX Live versions. For example: ```yaml jobs: @@ -23,13 +23,11 @@ jobs: strategy: fail-fast: false matrix: - texlive: [2023, 2022, 2021, 2020, 2019, 2018] # `latest` is also valid - debian: [buster, bullseye, bookworm, trixie] - name: texlive-${{ matrix.texlive }}-${{ matrix.debian_release }} + texlive_version: [2023, 2022, 2021, 2020, 2019, 2018] # `latest` is also valid + base_image: [buster, bullseye, bookworm, trixie, xenial, bionic, focal, jammy] + name: texlive-${{ matrix.texlive_version }}-${{ matrix.base_image }} ``` -It's not possible to do this for the original action because currently GitHub Actions doesn't support to use `matrix` syntax in `uses` field. - ## Inputs Each input is provided as a key inside the `with` section of the action. @@ -93,11 +91,11 @@ Each input is provided as a key inside the `with` section of the action. - `texlive_version` (optional, defaults to: "latest") - The TeX Live version to be used. Currently, you can choose from `2018`, `2019`, `2020`, `2021`, `2022`, `2023`, or `latest`. + The TeX Live version to be used. Currently, you can choose from `2018`, `2019`, `2020`, `2021`, `2022`, `2023`, or `latest`. (These choices may be outdated, please [check this page for the latest choices](https://github.com/zydou/texlive)) -- `debian_release` (optional, defaults to: "trixie") +- `base_image` (optional, defaults to: "trixie") - The Debian release of base image to be used. Currently, you can choose from `buster`, `bullseye`, `bookworm`, or `trixie`. + The base image version to be used. Currently, you can choose from `buster`, `bullseye`, `bookworm`, `trixie`, `xenial`, `bionic`, `focal`, or `jammy`. (These choices may be outdated, please [check this page for the latest choices](https://github.com/zydou/texlive)) **The following inputs are only valid if the input `compiler` is not changed.** @@ -132,10 +130,10 @@ jobs: strategy: fail-fast: false matrix: - texlive: [2023, 2022, 2021] # choose from 2018 to 2023, or latest - # if you need to use different debian release, uncomment the following line - # debian: [buster, bullseye, bookworm, trixie] - name: Build with texlive-${{ matrix.texlive }} + # choose from 2018 to 2023, or latest + texlive_version: [2023, 2022, 2021] + # base_image: [buster, bullseye, bookworm, trixie, xenial, bionic, focal, jammy] + name: Build with texlive-${{ matrix.texlive_version }} runs-on: ubuntu-latest permissions: contents: write @@ -145,10 +143,10 @@ jobs: - name: Compile LaTeX document uses: zydou/latex-action@v3 with: - texlive_version: ${{ matrix.texlive }} + texlive_version: ${{ matrix.texlive_version }} + # base_image: ${{ matrix.base_image }} work_in_root_file_dir: true continue_on_error: true - glob_root_file: true root_file: | **/*.tex @@ -166,11 +164,11 @@ jobs: mkdir public find . -type f -name "*.pdf" -exec cp {} public \; - - name: Push pdf files to texlive-${{matrix.texlive}} branch + - name: Push pdf files to texlive-${{matrix.texlive_version}} branch if: github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch uses: JamesIves/github-pages-deploy-action@v4 with: - branch: texlive-${{ matrix.texlive }} + branch: texlive-${{ matrix.texlive_version }} folder: ./public single-commit: true commit-message: ${{ github.event.head_commit.message }} @@ -243,7 +241,7 @@ Sometimes you may have custom package (`.sty`) or class (`.cls`) files in other with: root_file: main.tex env: - TEXINPUTS: ".:./custom_template//:" + TEXINPUTS: '.:./custom_template//:' ``` You can find more information of `TEXINPUTS` [here](https://tex.stackexchange.com/a/93733). diff --git a/action.yml b/action.yml index 96cd57f..23075ae 100644 --- a/action.yml +++ b/action.yml @@ -6,9 +6,12 @@ inputs: texlive_version: description: Tex Live version to be used default: latest - debian_release: - description: Debian debian_release to be used + base_image: + description: Base image to be used default: trixie + debian_release: + description: "[Deprecated] use `base_image` instead" + default: deprecated root_file: description: The root LaTeX file to be compiled required: true @@ -52,6 +55,15 @@ inputs: runs: using: composite steps: + - name: set base_image + shell: bash + run: | + if [[ "${{ inputs.debian_release }}" != "deprecated" ]]; then + echo "Deprecated warning: `debian_release` is deprecated, use `base_image` instead." + echo "BASE_IMG=${{ inputs.debian_release }}" >> "${GITHUB_ENV}" + else + echo "BASE_IMG=${{ inputs.base_image }}" >> "${GITHUB_ENV}" + fi - shell: bash run: > docker run --rm @@ -115,7 +127,7 @@ runs: -v "$GITHUB_ACTION_PATH/entrypoint.sh":/entrypoint.sh -w "$GITHUB_WORKSPACE" --entrypoint "/entrypoint.sh" - zydou/texlive:${{ inputs.texlive_version }}-${{ inputs.debian_release }} + zydou/texlive:${{ inputs.texlive_version }}-${{ env.BASE_IMG }} "${{ inputs.root_file }}" "${{ inputs.working_directory }}" "${{ inputs.work_in_root_file_dir }}"