Skip to content

Commit

Permalink
Merge branch 'main' into 12-reviewer1
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhomm authored Nov 1, 2024
2 parents 3ff95fa + ed01942 commit 0ec3e9c
Show file tree
Hide file tree
Showing 13 changed files with 627 additions and 68 deletions.
132 changes: 100 additions & 32 deletions .github/workflows/latex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,63 @@ on:
- '*'

jobs:
build_latex:
runs-on: ubuntu-latest
workflow-setup:
name: Workflow Setup
runs-on: ubuntu-24.04
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 }}
runner: ${{ steps.texlive_runner.outputs.runner }}
prefix: ${{ steps.doc_prefix.outputs.prefix }}
prefixwithref: ${{ steps.doc_prefix.outputs.prefixwithref }}
pdf: ${{ steps.doc_prefix.outputs.pdf }}
tex: ${{ steps.doc_prefix.outputs.tex }}
steps:
- name: Set up Git repository
uses: actions/checkout@v4
- name: Get TeXLive Runner
id: texlive_runner
run: |
if ! [ -z "$GH_TOKEN" ]; then
runners=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/feelpp/actions/runners)
texlive=$(echo $runners | jq --arg label "self-texlive" '[.runners[] | any(.labels[]; .name == $label) and .status == "online"] | any')
if [ "$texlive" = "false" ]; then
echo "runner=ubuntu-latest" >> "$GITHUB_OUTPUT"
else
echo "runner=self-texlive" >> "$GITHUB_OUTPUT"
fi
else
echo "runner=ubuntu-latest" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.TOKEN_RUNNER }}

- name: Get Repository Name
id: repo_name
- name: Get Document Prefix
id: doc_prefix
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: Show Outputs
run: |
echo "runner=${{ steps.texlive_runner.outputs.runner }}"
echo "prefix=${{ steps.doc_prefix.outputs.prefix }}"
echo "prefixwithref=${{ steps.doc_prefix.outputs.prefixwithref }}"
echo "pdf=${{ steps.doc_prefix.outputs.pdf }}"
echo "tex=${{ steps.doc_prefix.outputs.tex }}"
build_latex:
needs: workflow-setup
runs-on: ${{ needs.workflow-setup.outputs.runner }}
name: Build LaTeX Artifact
env:
VERSION: ${{ github.ref_name }}
steps:
- name: Set up Git repository
uses: actions/checkout@v4
with:
clean: true

- name: Install hooks
run: |
Expand All @@ -38,58 +73,91 @@ jobs:
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v3
if: ${{ needs.workflow-setup.outputs.runner == 'ubuntu-latest' }}
with:
root_file: ${{ steps.repo_name.outputs.tex }}
root_file: ${{ needs.workflow-setup.outputs.tex }}
latexmk_shell_escape: true
post_compile: "latexmk -c; rm -rf _minted*"

- name: Compile LaTeX document
if: ${{ needs.workflow-setup.outputs.runner == 'self-texlive' }}
run: |
latexmk -shell-escape -pdf -file-line-error -halt-on-error -interaction=nonstopmode ${{ needs.workflow-setup.outputs.tex }}
- name: Rename PDF
run: mv ${{ steps.repo_name.outputs.prefix }}.pdf ${{ steps.repo_name.outputs.pdf }}
run: mv ${{ needs.workflow-setup.outputs.prefix }}.pdf ${{ needs.workflow-setup.outputs.pdf }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.repo_name.outputs.prefixwithref }}
name: ${{ needs.workflow-setup.outputs.prefixwithref }}
path: |
./*.tex
./*.bib
./*.gin
./*.bbl
./readme.*
./${{ needs.workflow-setup.outputs.pdf }}
./README.adoc
./img-*
./release
./setup-hooks.sh
!./.git*
!./.github*
!./.vscode*
!./.idea*
!./.DS_Store*
!./.gitignore*
check:
needs: [build_latex,workflow-setup]
runs-on: ${{ needs.workflow-setup.outputs.runner }}
name: Check LaTeX Artifact
steps:
-
name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.workflow-setup.outputs.prefixwithref }}
path: ${{ github.workspace }}/artifact
-
name: List Artifact
run: ls -R ${{ github.workspace }}
-
name: Check compilation of LaTeX document from artifact
if: ${{ needs.workflow-setup.outputs.runner == 'ubuntu-latest' }}
uses: xu-cheng/latex-action@v3
with:
root_file: ${{ needs.workflow-setup.outputs.tex }}
latexmk_shell_escape: true
post_compile: "latexmk -c; rm -rf _minted*"
working_directory: ${{ github.workspace }}/artifact
-
name: Check compilation of LaTeX document from artifact
if: ${{ needs.workflow-setup.outputs.runner == 'self-texlive' }}
run: |
latexmk -shell-escape -pdf -file-line-error -halt-on-error -interaction=nonstopmode ${{ needs.workflow-setup.outputs.tex }}
working-directory: ${{ github.workspace }}/artifact

release:
needs: [workflow-setup,build_latex, check]
runs-on: ${{ needs.workflow-setup.outputs.runner }}
name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{ steps.repo_name.outputs.prefixwithref }}
name: ${{ needs.workflow-setup.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" ./
tar -czvf "${temp_dir}/${{ needs.workflow-setup.outputs.prefixwithref }}.tar.gz" -C artifact ./
mv "${temp_dir}/${{ needs.workflow-setup.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
Expand All @@ -99,5 +167,5 @@ jobs:
tag_name: ${{ github.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ steps.repo_name.outputs.pdf }}
${{ steps.repo_name.outputs.prefixwithref }}.tar.gz
artifact/${{ needs.workflow-setup.outputs.prefixwithref }}.pdf
${{ needs.workflow-setup.outputs.prefixwithref }}.tar.gz
Loading

0 comments on commit 0ec3e9c

Please sign in to comment.