Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add workflow support #2

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions .github/workflows/latex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Compile Latex and Release PDF

on:
push:
tags:
- 'v*'
branches:
- '*'

jobs:
workflow-setup:
name: Workflow Setup
runs-on: ubuntu-24.04
outputs:
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: 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 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: |
bash ./a.cli setup

- name: Compile LaTeX document
uses: xu-cheng/latex-action@v3
if: ${{ needs.workflow-setup.outputs.runner == 'ubuntu-latest' }}
with:
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 ${{ needs.workflow-setup.outputs.prefix }}.pdf ${{ needs.workflow-setup.outputs.pdf }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ needs.workflow-setup.outputs.prefixwithref }}
path: |
./*.tex
./*.bib
./*.gin
./*.bbl
./${{ needs.workflow-setup.outputs.pdf }}
./README.adoc
./hooks*
./img*
./dat*
./*.png
./a.cli
./*.sty
./exclude.txt
./sections*
./litterature*
./graphics*
!./.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: ${{ needs.workflow-setup.outputs.prefixwithref }}
path: ${{ github.workspace }}/artifact

- name: Archive Article
run: |
temp_dir=$(mktemp -d)
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: Create Release
id: create_release
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: |
artifact/${{ needs.workflow-setup.outputs.prefixwithref }}.pdf
${{ needs.workflow-setup.outputs.prefixwithref }}.tar.gz
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Create Release

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag for the release'
required: true
type: string
default: 'vx.y.z'

jobs:
create:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Release
run: |
bash ./release create ${{ github.event.inputs.tag }}
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
_minted*
*.aux
*.bbl
*.log
*.blg
*.out
*.pyg
*.fls
*.synctex.gz
main.pdf
*.toc
article.template.pdf
*.fdb_latexmk
*.fls
*.idx
*.ilg
*.ind
deliverable.chl
deliverable.lof
deliverable.lot
deliverable.pdf
deliverable.template.chl
deliverable.template.lof
deliverable.template.lot
deliverable.template.pdf
45 changes: 45 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"latex-workshop.latex.recipes": [
{
"name": "latexmk-pdf",
"tools": [
"latexmk-shell-escape"
]
},
{
"name": "pdflatex-shell-escape-recipe",
"tools": [
"pdflatex-shell-escape"
]
}
],
"latex-workshop.latex.tools": [
{
"name": "latexmk-shell-escape",
"command": "latexmk",
"args": [
"--shell-escape",
"-pdf",
"-interaction=nonstopmode",
"-synctex=1",
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex-shell-escape",
"command": "pdflatex",
"args": [
"--shell-escape",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}
],
"latex-workshop.latex.autoBuild.run": "onFileChange",
"latex-workshop.latex.autoBuild.enabled": true,
"latex-workshop.latex.build.showOutput": "always",
"latex-workshop.latex.outDir": "%DIR%"
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BASE=template
DIRECTORY=HYPERRIDEDeliverable
DIRECTORY=numpexDeliverable
bib:
bibtool -v -d -s -- 'preserve.key.case=on' -x $(BASE).aux > $(BASE)-new.bib
mv $(BASE).bib $(BASE)-old.bib
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LaTeX style files for HYPERRIDE deliverables.
LaTeX style files for numpex deliverables.
===============================================

Basic usage:
Expand All @@ -8,7 +8,7 @@ The basic structure of a deliverable formatted according with these
styles should be (minimally):

\documentclass[11pt]{report}
\usepackage{hyperride}
\usepackage{numpex}

\begin{document}

Expand All @@ -24,7 +24,7 @@ styles should be (minimally):
\istChange{}{}{}{}

%% Deliverable information
\ProjectAcronym{HYPERRIDE}
\ProjectAcronym{numpex}
\ProjectFullTitle{Hybrid Provision of Energy based on Reliability and Resiliency by Integration of Dc Equipment}
\ProjectRefNo{957788}
\delivNumber{Dx.y}
Expand Down
Loading