Enhancing paper text and images #32
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: Compile Latex and Release PDF | |
on: | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- '*' | |
jobs: | |
build_latex: | |
runs-on: ubuntu-latest | |
outputs: | |
prefix: ${{ steps.repo_name.outputs.prefix }} | |
prefixwithref: ${{ steps.repo_name.outputs.prefixwithref }} | |
pdf: ${{ steps.repo_name.outputs.pdf }} | |
tex: ${{ steps.repo_name.outputs.tex }} | |
env: | |
VERSION: ${{ github.ref_name }} | |
steps: | |
- name: Set up Git repository | |
uses: actions/checkout@v4 | |
- name: Get Repository Name | |
id: repo_name | |
run: | | |
prefix=$(echo "${{ github.repository }}" | cut -d'/' -f2) | |
echo "prefix=$prefix" >> "$GITHUB_OUTPUT" | |
prefixwithref=$(echo "$prefix")-${{ github.ref_name }} | |
echo "prefixwithref=$prefixwithref" >> "$GITHUB_OUTPUT" | |
echo "pdf=$prefixwithref.pdf" >> "$GITHUB_OUTPUT" | |
echo "tex=$prefix.tex" >> "$GITHUB_OUTPUT" | |
- name: Install hooks | |
run: | | |
sh ./setup-hooks.sh | |
git checkout ${{ github.ref }} # checkout the branch or tag to update gitinfo2 | |
- name: Compile LaTeX document | |
uses: xu-cheng/latex-action@v3 | |
with: | |
root_file: ${{ steps.repo_name.outputs.tex }} | |
latexmk_shell_escape: true | |
post_compile: "latexmk -c; rm -rf _minted*" | |
- name: Rename PDF | |
run: mv ${{ steps.repo_name.outputs.prefix }}.pdf ${{ steps.repo_name.outputs.pdf }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.repo_name.outputs.prefixwithref }} | |
path: | | |
./*.tex | |
./*.bib | |
./*.gin | |
./*.bbl | |
./readme.* | |
./img-* | |
!./.git* | |
!./.github* | |
!./.vscode* | |
!./.idea* | |
!./.DS_Store* | |
!./.gitignore* | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ steps.repo_name.outputs.prefixwithref }} | |
path: ${{ github.workspace }}/artifact | |
- name: List Artifact | |
run: ls -R ${{ github.workspace }} | |
- name: Archive Article | |
run: | | |
temp_dir=$(mktemp -d) | |
tar -czvf "${temp_dir}/${{ steps.repo_name.outputs.prefixwithref }}.tar.gz" -C artifact ./ | |
mv "${temp_dir}/${{ steps.repo_name.outputs.prefixwithref }}.tar.gz" ./ | |
rm -rf "$temp_dir" | |
- name: Check compilation of LaTeX document from artifact | |
uses: xu-cheng/latex-action@v3 | |
with: | |
root_file: ${{ steps.repo_name.outputs.tex }} | |
latexmk_shell_escape: true | |
post_compile: "latexmk -c; rm -rf _minted*" | |
work_in_root_file_dir: ${{ github.workspace }}/artifact | |
- name: Create Release | |
id: create_release | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: false | |
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') || contains(github.ref, 'preview') }} | |
name: Release ${{ github.ref_name }} | |
generate_release_notes: true | |
tag_name: ${{ github.ref }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: | | |
${{ steps.repo_name.outputs.pdf }} | |
${{ steps.repo_name.outputs.prefixwithref }}.tar.gz |