diff --git a/.github/actions/render/action.yml b/.github/actions/render/action.yml new file mode 100644 index 0000000..527d5b3 --- /dev/null +++ b/.github/actions/render/action.yml @@ -0,0 +1,62 @@ +name: 'Render' +description: 'Render a TCG Markdown document' +inputs: + input-md: + description: 'The name of the Markdown file to render' + required: true + output-basename: + description: 'The base name (without extension) to use for output file(s)' + required: true + pr-repo: + description: 'Pull request repo (use with pr-number)' + required: false + type: 'string' + pr-number: + description: 'Pull request number to reference (use with pr-repo)' + required: false + type: 'string' + pdf: + description: 'Render to PDF' + required: false + type: 'boolean' + default: 'true' + diffbase: + description: 'The revision to diff against (use with pdf)' + required: false + type: 'string' + html: + description: 'Render to HTML' + required: false + type: 'boolean' + default: 'false' + docx: + description: 'Render to Word' + required: false + type: 'boolean' + default: 'false' + tex: + description: 'Render to TeX' + required: false + type: 'boolean' + default: 'false' + extra-build-options: + description: 'Additional build options to be passed to build.sh' +runs: + using: 'composite' + steps: + # let the container take ownership of the repo dir, in case the user wants to check in the results + # workaround to https://github.com/actions/runner/issues/2033 + - run: chown -R $(id -u):$(id -g) $PWD + shell: sh + - run: > + /usr/bin/build.sh + --versioned_filenames + $( [ -n "${{ inputs.pr-repo }}" -a -n "${{ inputs.pr-number }}" ] && echo --pr_number=${{ inputs.pr-number }} --pr_repo=${{ inputs.pr-repo }} ) + $( [ ${{ inputs.pdf }} -a -n "${{ inputs.diffbase }}" ] && echo --diffbase=${{ inputs.diffbase }} --diffpdf=${{ inputs.output-basename }}.diff.pdf --diffpdflog=${{ inputs.output-basename }}.diff.pdf.log ) + $( ${{ inputs.pdf }} && echo --pdf=${{ inputs.output-basename }}.pdf --pdflog=${{ inputs.output-basename }}.pdf.log ) + $( ${{ inputs.html }} && echo --html=${{ inputs.output-basename }}.html ) + $( ${{ inputs.docx }} && echo --docx=${{ inputs.output-basename }}.docx ) + $( ${{ inputs.tex }} && echo --latex=${{ inputs.output-basename }}.tex ) + ${{ inputs.extra-build-options }} + ${{ inputs.input-md }} + shell: sh diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index bcc6687..77d12cf 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -25,7 +25,7 @@ jobs: # Login against a Docker registry # https://github.com/docker/login-action - name: Log into registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} diff --git a/.github/workflows/render-samples.yml b/.github/workflows/render-samples.yml index 962f9aa..c8ca38c 100644 --- a/.github/workflows/render-samples.yml +++ b/.github/workflows/render-samples.yml @@ -19,7 +19,7 @@ jobs: # Login against a Docker registry # https://github.com/docker/login-action - name: Log into registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -68,18 +68,23 @@ jobs: *.lof *.lot *.toc + *.upa + *.upb *.convert.pdf key: latex-${{ github.run_id }} restore-keys: latex - name: Run the action on guide - uses: trustedcomputinggroup/markdown@latest + uses: ./.github/actions/render with: input-md: guide.tcg - extra-build-options: "--versioned_filenames --pr_number=${{ github.event.number }} --pr_repo=${{ github.repository }} --diffbase=${{ github.event.pull_request.base.sha }}" - output-pdf: guide.pdf - output-tex: guide.tex - output-docx: guide.docx + output-basename: guide + pdf: true + tex: true + docx: true + diffbase: "${{ github.event.pull_request.base.sha }}" + pr-number: "${{ github.event.number }}" + pr-repo: "${{ github.repository }}" - name: Upload PDF uses: actions/upload-artifact@master @@ -87,6 +92,12 @@ jobs: name: PDF path: guide.*.pdf + - name: Upload logs + uses: actions/upload-artifact@master + with: + name: Logs + path: guide.*.log + - name: Upload TeX uses: actions/upload-artifact@master with: diff --git a/build.sh b/build.sh index 1ec3a1f..29ff0e9 100755 --- a/build.sh +++ b/build.sh @@ -378,7 +378,7 @@ if [ "${VERSIONED_FILENAMES}" == "yes" ]; then PDF_OUTPUT=$(prefix_filename "${version_prefix}" "${PDF_OUTPUT}") fi if [ ! -z "${DIFFPDF_OUTPUT}" ]; then - DIFFPDF_OUTPUT=$(prefix_filename "${DIFFBASE}_to_${version_prefix}" "${DIFFPDF_OUTPUT}") + DIFFPDF_OUTPUT=$(prefix_filename ".$(echo ${DIFFBASE} | cut -c1-10).to${version_prefix}" "${DIFFPDF_OUTPUT}") fi if [ ! -z "${LATEX_OUTPUT}" ]; then LATEX_OUTPUT=$(prefix_filename "${version_prefix}" "${LATEX_OUTPUT}") @@ -778,22 +778,26 @@ readonly TEMP_DIFF_TEX_FILE="${BUILD_DIR}/${INPUT_FILE}.diff.tex" readonly TEMP_LATEXDIFF_LOG="${BUILD_DIR}/latexdiff.log" export MERMAID_FILTER_FORMAT="pdf" if [ -n "${DIFFPDF_OUTPUT}" ]; then - git reset --hard ${DIFFBASE} - - do_md_fixups "${BUILD_DIR}/${INPUT_FILE}" - do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_DIFFBASE_TEX_FILE}" - latexdiff --type PDFCOMMENT --driver "${PDF_ENGINE}" "${TEMP_DIFFBASE_TEX_FILE}" "${TEMP_TEX_FILE}" > "${TEMP_DIFF_TEX_FILE}" 2>"${TEMP_LATEXDIFF_LOG}" - do_tex_fixups "${TEMP_DIFF_TEX_FILE}" - do_pdf "${TEMP_DIFF_TEX_FILE}" "${SOURCE_DIR}/${DIFFPDF_OUTPUT}" "${LATEX_LOG}" - - # Copy the logs, if requested. Note that this file gets the latexdiff and PDF driver output. - if [ -n "${DIFFPDFLOG_OUTPUT}" ]; then - mkdir -p "$(dirname ${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT})" - echo "latexdiff output:" > "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" - cat "${TEMP_LATEXDIFF_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" - echo "" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" - echo "${PDF_ENGINE} output:" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" - cat "${LATEX_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" + git fetch --unshallow --quiet && git reset --hard ${DIFFBASE} + if [ $? -ne 0 ]; then + FAILED=true + echo "diff output failed" + else + do_md_fixups "${BUILD_DIR}/${INPUT_FILE}" + do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_DIFFBASE_TEX_FILE}" + latexdiff --type PDFCOMMENT --driver "${PDF_ENGINE}" "${TEMP_DIFFBASE_TEX_FILE}" "${TEMP_TEX_FILE}" > "${TEMP_DIFF_TEX_FILE}" 2>"${TEMP_LATEXDIFF_LOG}" + do_tex_fixups "${TEMP_DIFF_TEX_FILE}" + do_pdf "${TEMP_DIFF_TEX_FILE}" "${SOURCE_DIR}/${DIFFPDF_OUTPUT}" "${LATEX_LOG}" + + # Copy the logs, if requested. Note that this file gets the latexdiff and PDF driver output. + if [ -n "${DIFFPDFLOG_OUTPUT}" ]; then + mkdir -p "$(dirname ${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT})" + echo "latexdiff output:" > "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" + cat "${TEMP_LATEXDIFF_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" + echo "" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" + echo "${PDF_ENGINE} output:" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" + cat "${LATEX_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}" + fi fi fi