├── .github └── workflows │ └── CI.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── dictionary.txt └── tex └── paper.tex /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | # Laurence Kedward 2021 2 | # Licensed for use under the MIT license 3 | # (See LICENSE file) 4 | 5 | name: CI 6 | 7 | on: 8 | push: 9 | branches: 10 | - main 11 | pull_request: 12 | workflow_dispatch: 13 | 14 | env: 15 | APT_DEPS: texlive-latex-recommended texlive-latex-extra texlive-extra-utils latexdiff perl rubber 16 | REPO_URL: https://github.com/LKedward/latex-github-collab 17 | TEXTIDOTE_URL: https://github.com/sylvainhalle/textidote/releases/download/v0.8.2/textidote_0.8.2_all.deb 18 | 19 | jobs: 20 | SpellCheck: 21 | runs-on: ubuntu-latest 22 | if: "!contains(github.event.head_commit.message, 'skip-ci')" 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v3 26 | 27 | - name: Install Ubuntu Dependencies 28 | run: | 29 | wget ${{ env.TEXTIDOTE_URL }} 30 | sudo apt-get install -y ./textidote*.deb 31 | sudo pip3 install codespell 32 | 33 | - name: Run spell check 34 | run: make spellcheck 35 | 36 | Build: 37 | runs-on: ubuntu-latest 38 | if: "!contains(github.event.head_commit.message, 'skip-ci')" 39 | steps: 40 | - name: Checkout code 41 | uses: actions/checkout@v3 42 | 43 | - run: | 44 | git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 45 | 46 | - name: Install Ubuntu Dependencies 47 | run: | 48 | sudo apt-get update 49 | sudo apt install ${{ env.APT_DEPS }} 50 | 51 | - name: Compile paper 52 | run : make 53 | 54 | - name: Run TexCount 55 | id: texcount 56 | run : | 57 | TEXCOUNT_OUT=$(make count) 58 | TEXCOUNT_OUT="${TEXCOUNT_OUT//$'\n'/'%0A'}" 59 | echo "output=$TEXCOUNT_OUT" >> $GITHUB_OUTPUT 60 | 61 | - name: Run latexdiff for PR 62 | if: github.event_name == 'pull_request' 63 | run: make diff 64 | 65 | - name: Checkout previews branch 66 | uses: actions/checkout@v3 67 | with: 68 | ref: previews 69 | path: previews 70 | 71 | - name: Define preview directory (PRs) 72 | if: github.event_name == 'pull_request' 73 | run: echo "BUILD_DIR=pr-${{github.event.number}}" >> $GITHUB_ENV 74 | 75 | - name: Define preview directory 76 | if: github.event_name != 'pull_request' 77 | run: echo "BUILD_DIR=master" >> $GITHUB_ENV 78 | 79 | - name: Collect pdf previews for upload 80 | run: | 81 | mkdir -p previews/${{env.BUILD_DIR}} 82 | cp tex/paper.pdf previews/${{env.BUILD_DIR}}/ 83 | test -f tex/main.pdf && cp tex/main.pdf previews/${{env.BUILD_DIR}}/paper-diffmain.pdf || true 84 | 85 | - name: Upload paper preview 86 | uses: EndBug/add-and-commit@v9 87 | with: 88 | cwd: previews 89 | add: '${{env.BUILD_DIR}}' 90 | new_branch: previews 91 | message: 'Upload pdf preview for ${{env.BUILD_DIR}}' 92 | 93 | - name: Get Time 94 | if: github.event_name == 'pull_request' 95 | id: time 96 | uses: nanzm/get-time-action@v1.1 97 | with: 98 | timeZone: 0 99 | format: 'DD-MM-YYYY HH:mm:ss' 100 | 101 | - name: Find previous bot comment 102 | if: github.event_name == 'pull_request' 103 | uses: peter-evans/find-comment@v2 104 | id: fc 105 | with: 106 | issue-number: ${{ github.event.pull_request.number }} 107 | comment-author: 'github-actions[bot]' 108 | body-includes: Preview 109 | 110 | - name: Create PR comment 111 | if: github.event_name == 'pull_request' 112 | uses: peter-evans/create-or-update-comment@v2 113 | with: 114 | comment-id: ${{ steps.fc.outputs.comment-id }} 115 | issue-number: ${{github.event.number}} 116 | body: | 117 | Preview this branch rendered at <${{env.REPO_URL}}/blob/previews/${{env.BUILD_DIR}}/paper.pdf> 118 | Preview the latexdiff rendered at <${{env.REPO_URL}}/blob/previews/${{env.BUILD_DIR}}/paper-diffmain.pdf> 119 |
120 | Click to view TexCount output 121 | 122 | ``` 123 | ${{ steps.texcount.outputs.output }} 124 | ``` 125 |
126 | 127 | Last updated: ${{ steps.time.outputs.time }} UTC for ${{ github.event.pull_request.head.sha }} 128 | edit-mode: replace 129 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tex/*.aux 2 | tex/*.bbl 3 | tex/*.blg 4 | tex/*.log 5 | tex/*.out 6 | tex/*.pdf 7 | tex/*.synctex.gz 8 | tex/*.txt 9 | tex/*.eps 10 | tex/paper-diff* 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Laurence Kedward 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Laurence Kedward 2021 2 | # Licensed for use under the MIT License (see LICENSE file) 3 | 4 | SHELL=/bin/bash 5 | SRC=tex/paper.tex 6 | 7 | all: 8 | rubber --pdf --into tex $(SRC) 9 | 10 | clean: 11 | rubber --clean --into tex $(SRC) 12 | 13 | count: 14 | texcount $(SRC) 15 | 16 | diff: DIFF_FILE_CMD=$(shell latexdiff-vc tex/paper.tex -r origin/main --force|grep Generated|cut -d\ -f4) 17 | 18 | diff: 19 | rubber --pdf --into tex $(DIFF_FILE_CMD) 20 | rubber --clean --into tex $(DIFF_FILE_CMD) 21 | 22 | spellcheck: $(SRC).txt 23 | codespell -I dictionary.txt $(SRC).txt 24 | 25 | count2: $(SRC).txt 26 | wc -w $^ 27 | 28 | %.txt: % 29 | textidote --clean $^ > $@ 30 | 31 | .PHONY: all clean count diff spellcheck 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Collaborative LaTeX Writing using Git and Github Actions 2 | 3 | [![CI](https://github.com/LKedward/latex-github-collab/actions/workflows/CI.yml/badge.svg)](https://github.com/LKedward/latex-github-collab/actions/workflows/CI.yml) [[__View Paper Preview__](https://github.com/LKedward/latex-github-collab/blob/previews/master/paper.pdf)] 4 | 5 | A Github repository template for writing LaTeX documents collaboratively with automatic rendering using Github actions. 6 | 7 | - Renders the paper on every push to master 8 | - Renders the paper for pull requests, including latex-diff with master 9 | - Calculates document word count for pull requests using texcount 10 | 11 | ## Compiling Locally 12 | 13 | Compiling locally is possible with any LaTeX distribution; the github actions [workflow](https://github.com/LKedward/latex-github-collab/blob/master/.github/workflows/CI.yml) (Ubuntu 20.04) uses the following packages (all installable via `apt`): 14 | 15 | - `texlive-latex-recommended` 16 | - `texlive-latex-extra` 17 | - `texlive-extra-utils` (_optional:_ needed for `texcount`) 18 | - [`rubber`](https://gitlab.com/latex-rubber/rubber/) (_optional:_ needed for Makefile usage) 19 | - `perl` (_optional:_ needed for texcount and latexdiff) 20 | - `latexdiff`(_optional_) 21 | 22 | For running the spellcheck, the following packages are required: 23 | 24 | - [`textidote`](https://github.com/sylvainhalle/textidote/releases/tag/v0.8.2) (for generating plain-text from tex) 25 | - `codespell` (installable with `pip3`) 26 | 27 | For convenience a Makefile is included which relies on the [rubber](https://gitlab.com/latex-rubber/rubber/) LaTeX wrapper: 28 | 29 | ``` 30 | $ make # generate paper.pdf 31 | $ make clean # cleanup 32 | $ make spellcheck # run codespell 33 | $ make count # run TexCount 34 | $ make diff # run latexdiff with master 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /dictionary.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LKedward/latex-github-collab/da8f22f54e775e90532f794ed9f50cf876d9d0fc/dictionary.txt -------------------------------------------------------------------------------- /tex/paper.tex: -------------------------------------------------------------------------------- 1 | \documentclass[]{article} 2 | 3 | \title{Collaborative LaTeX Writing using Git and Github Actions} 4 | \author{Laurence Kedward} 5 | 6 | \usepackage{listings} 7 | \usepackage[colorlinks,urlcolor=blue,linkcolor=blue,citecolor=blue]{hyperref} 8 | 9 | \begin{document} 10 | 11 | \maketitle 12 | 13 | 14 | Repository available at: \url{https://github.com/LKedward/latex-github-collab} 15 | 16 | \section{Compiling Locally} 17 | 18 | \subsection{Prerequisites} 19 | 20 | Compiling locally is possible with any LaTeX distribution; the github actions workflow running on Ubuntu 20.04 uses the following packages (all installable via `apt`): 21 | 22 | \subsection*{Mandatory} 23 | \begin{itemize} 24 | 25 | \item \texttt{texlive-latex-recommended} 26 | \item \texttt{texlive-latex-extra} 27 | 28 | \end{itemize} 29 | 30 | \subsection*{Optional} 31 | \begin{itemize} 32 | 33 | \item \texttt{texlive-latex-utils} \quad (for \texttt{texcount}) 34 | \item \texttt{rubber} \quad (for using the \texttt{Makefile}) 35 | \item \texttt{perl} \quad (for \texttt{texcount} and \texttt{latexdiff}) 36 | \item \texttt{latexdiff} 37 | 38 | \end{itemize} 39 | 40 | 41 | \subsection{Makefile} 42 | 43 | For convenience a Makefile is included which relies on the [rubber](https://gitlab.com/latex-rubber/rubber/) LaTeX wrapper: 44 | 45 | 46 | \begin{center} 47 | \begin{lstlisting}[language=Bash,morekeywords={make}] 48 | $ make # generate paper.pdf 49 | $ make clean # cleanup 50 | $ make spellcheck # run codespell 51 | $ make count # run TexCount 52 | $ make diff # run latexdiff with master 53 | \end{lstlisting} 54 | \end{center} 55 | 56 | 57 | \section{License: MIT} 58 | 59 | The Makefile and Github actions workflow are licensed under the MIT license 60 | 61 | \begin{quote} 62 | MIT License 63 | 64 | Copyright (c) 2021 Laurence Kedward 65 | 66 | Permission is hereby granted, free of charge, to any person obtaining a copy 67 | of this software and associated documentation files (the "Software"), to deal 68 | in the Software without restriction, including without limitation the rights 69 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 70 | copies of the Software, and to permit persons to whom the Software is 71 | furnished to do so, subject to the following conditions: 72 | 73 | The above copyright notice and this permission notice shall be included in all 74 | copies or substantial portions of the Software. 75 | 76 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 77 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 78 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 79 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 80 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 81 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 82 | SOFTWARE. 83 | \end{quote} 84 | 85 | 86 | 87 | \end{document} 88 | --------------------------------------------------------------------------------