-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: "Build LaTeX using latexmk" | ||
description: "Build LaTeX files and set output file name with version or branch info" | ||
author: "range3" | ||
runs: | ||
using: "docker" | ||
image: "Dockerfile" | ||
inputs: | ||
latex_file_name: | ||
description: "LaTeX file to build (default: main.tex)" | ||
required: false | ||
default: "main.tex" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
#!/bin/bash | ||
set -eux | ||
|
||
# build pdf | ||
latexmk | ||
# Set the LaTeX file name, defaulting to main.tex if not provided | ||
LATEX_FILE_NAME="${INPUT_LATEX_FILE_NAME:-main.tex}" | ||
|
||
# Determine the version or branch name | ||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | ||
VERSION_NAME=$(echo "${GITHUB_REF}" | sed 's/refs\/tags\///') | ||
else | ||
VERSION_NAME=$(echo "${GITHUB_HEAD_REF}") | ||
fi | ||
|
||
# Determine the output PDF name | ||
FILE_BASENAME=$(basename "${LATEX_FILE_NAME}" .tex) | ||
OUTPUT_PDF="${FILE_BASENAME}-${VERSION_NAME}.pdf" | ||
|
||
# Export environment variables for GitHub Actions to use in later steps | ||
echo "LATEXMK_LATEX_FILE_NAME=${LATEX_FILE_NAME}" >> $GITHUB_ENV | ||
echo "LATEXMK_OUTPUT_PDF=${OUTPUT_PDF}" >> $GITHUB_ENV | ||
|
||
# Build the LaTeX document | ||
latexmk -pdf "${LATEX_FILE_NAME}" | ||
|
||
# Rename the output file with version or branch information | ||
mv "${FILE_BASENAME}.pdf" "${OUTPUT_PDF}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,25 +14,15 @@ jobs: | |
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
submodules: recursive | ||
- name: Build LaTeX files by latexmk | ||
|
||
- name: Build LaTeX and Set Output File Name | ||
uses: ./.github/actions/latexmk | ||
- name: Create a Release | ||
id: create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload a Release Asset | ||
id: upload-release-asset | ||
uses: actions/[email protected] | ||
latex_file_name: ${{ github.event.inputs.latex_file_name || 'main.tex' }} | ||
|
||
- name: Create and Upload a Release Asset | ||
uses: softprops/[email protected] | ||
with: | ||
files: ./${{ env.OUTPUT_PDF }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
asset_path: ./main.pdf | ||
asset_name: main.pdf | ||
asset_content_type: application/pdf |