diff --git a/.github/workflows/manubot.yaml b/.github/workflows/manubot.yaml index 9a7d5766..3d390d60 100644 --- a/.github/workflows/manubot.yaml +++ b/.github/workflows/manubot.yaml @@ -8,6 +8,17 @@ on: branches: - main - master + workflow_dispatch: + inputs: + BUILD_PDF: + description: generate PDF output (true or false) + default: "true" + BUILD_DOCX: + description: generate DOCX output (true or false) + default: "false" + BUILD_LATEX: + description: generate LaTeX output (true or false) + default: "false" jobs: manubot: name: Manubot @@ -21,6 +32,12 @@ jobs: with: # fetch entire commit history to support get_rootstock_commit fetch-depth: 0 + - name: Set Environment Variables (Workflow Dispatch) + if: github.event_name == 'workflow_dispatch' + run: | + echo "BUILD_PDF=${{ github.event.inputs.BUILD_PDF }}" >> $GITHUB_ENV + echo "BUILD_DOCX=${{ github.event.inputs.BUILD_DOCX }}" >> $GITHUB_ENV + echo "BUILD_LATEX=${{ github.event.inputs.BUILD_LATEX }}" >> $GITHUB_ENV - name: Set Environment Variables run: | TRIGGERING_SHA=${GITHUB_PULL_REQUEST_SHA:-$GITHUB_SHA} diff --git a/build/build.sh b/build/build.sh index 5cebfc59..778c9580 100755 --- a/build/build.sh +++ b/build/build.sh @@ -11,6 +11,16 @@ export TZ=Etc/UTC # Default Python to read/write text files using UTF-8 encoding export LC_ALL=en_US.UTF-8 +# Set option defaults +CI="${CI:-false}" +BUILD_PDF="${BUILD_PDF:-true}" +BUILD_DOCX="${BUILD_DOCX:-false}" +BUILD_LATEX="${BUILD_LATEX:-false}" +SPELLCHECK="${SPELLCHECK:-false}" +# Pandoc's configuration is specified via files of option defaults +# located in the $PANDOC_DATA_DIR/defaults directory. +PANDOC_DATA_DIR="${PANDOC_DATA_DIR:-build/pandoc}" + # Generate reference information echo >&2 "Retrieving and processing reference metadata" manubot process \ @@ -20,10 +30,6 @@ manubot process \ --skip-citations \ --log-level=INFO -# Pandoc's configuration is specified via files of option defaults -# located in the $PANDOC_DATA_DIR/defaults directory. -PANDOC_DATA_DIR="${PANDOC_DATA_DIR:-build/pandoc}" - # Make output directory mkdir -p output @@ -39,8 +45,9 @@ pandoc --verbose \ DOCKER_RUNNING="$(docker info &> /dev/null && echo "yes" || true)" # Create PDF output (unless BUILD_PDF environment variable equals "false") +# The double-commas (,,) lowercase the variable. # If Docker is not available, use WeasyPrint to create PDF -if [ "${BUILD_PDF:-}" != "false" ] && [ -z "$DOCKER_RUNNING" ]; then +if [ "${BUILD_PDF,,}" != "false" ] && [ -z "$DOCKER_RUNNING" ]; then echo >&2 "Exporting PDF manuscript using WeasyPrint" if [ -L images ]; then rm images; fi # if images is a symlink, remove it ln -s content/images @@ -53,9 +60,9 @@ if [ "${BUILD_PDF:-}" != "false" ] && [ -z "$DOCKER_RUNNING" ]; then fi # If Docker is available, use athenapdf to create PDF -if [ "${BUILD_PDF:-}" != "false" ] && [ -n "$DOCKER_RUNNING" ]; then +if [ "${BUILD_PDF,,}" != "false" ] && [ -n "$DOCKER_RUNNING" ]; then echo >&2 "Exporting PDF manuscript using Docker + Athena" - if [ "${CI:-}" = "true" ]; then + if [ "${CI,,}" = "true" ]; then # Incease --delay for CI builds to ensure the webpage fully renders, even when the CI server is under high load. # Local builds default to a shorter --delay to minimize runtime, assuming proper rendering is less crucial. MANUBOT_ATHENAPDF_DELAY="${MANUBOT_ATHENAPDF_DELAY:-5000}" @@ -77,7 +84,7 @@ if [ "${BUILD_PDF:-}" != "false" ] && [ -n "$DOCKER_RUNNING" ]; then fi # Create DOCX output (if BUILD_DOCX environment variable equals "true") -if [ "${BUILD_DOCX:-}" = "true" ]; then +if [ "${BUILD_DOCX,,}" = "true" ]; then echo >&2 "Exporting Word Docx manuscript" pandoc --verbose \ --data-dir="$PANDOC_DATA_DIR" \ @@ -86,7 +93,7 @@ if [ "${BUILD_DOCX:-}" = "true" ]; then fi # Create LaTeX output (if BUILD_LATEX environment variable equals "true") -if [ "${BUILD_LATEX:-}" = "true" ]; then +if [ "${BUILD_LATEX,,}" = "true" ]; then echo >&2 "Exporting LaTeX manuscript" pandoc \ --data-dir="$PANDOC_DATA_DIR" \ @@ -95,7 +102,7 @@ if [ "${BUILD_LATEX:-}" = "true" ]; then fi # Spellcheck -if [ "${SPELLCHECK:-}" = "true" ]; then +if [ "${SPELLCHECK,,}" = "true" ]; then export ASPELL_CONF="add-extra-dicts $(pwd)/build/assets/custom-dictionary.txt; ignore-case true" # Identify and store spelling errors diff --git a/build/environment.yml b/build/environment.yml index 40abf49e..8cac4276 100644 --- a/build/environment.yml +++ b/build/environment.yml @@ -20,7 +20,7 @@ dependencies: - yamllint=1.25.0 - pip: - errorhandler==2.0.1 - - git+https://github.com/manubot/manubot@2c028a7a87be24a76e2dec3ac7db6e8754ae6d4a + - git+https://github.com/manubot/manubot@2fc85b57be896c6262398f343b550197127c0ccb - isbnlib==3.10.3 - opentimestamps-client==0.7.0 - opentimestamps==0.4.1