diff --git a/Jenkinsfile b/Jenkinsfile index 0e08f36..505513e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,11 @@ pipeline { BALANCE_SOURCE_FILE = "balance_report.typ" BALANCE_OUTPUT_FILE = "Ravenous_balance_report_build.pdf" BALANCE_PUBLISHED_FILE = "Ravenous_balance_report.pdf" + MASTER_SOURCE_FILE = "master_handbook.typ" + MASTER_PLAINTEXT_FILE = "Ravenous_master_handbook_plaintext.pdf" + MASTER_OUTPUT_FILE = "Ravenous_master_handbook_build.pdf" + MASTER_PUBLISHED_FILE = "Ravenous_master_handbook.pdf" + MASTER_PASSWORD = "billy" // Important: published books live under /mnt/books DEPLOY_DIR = "/mnt/books/Ravenous" @@ -49,6 +54,13 @@ pipeline { echo "Using:" typst --version + + if ! command -v qpdf >/dev/null 2>&1; then + echo "qpdf is required to protect the master handbook." >&2 + exit 1 + fi + + qpdf --version ''' } } @@ -67,11 +79,26 @@ pipeline { echo "Building ${BALANCE_SOURCE_FILE} -> ${BALANCE_OUTPUT_FILE}" typst compile "${BALANCE_SOURCE_FILE}" "${BALANCE_OUTPUT_FILE}" + echo "Building ${MASTER_SOURCE_FILE} -> ${MASTER_PLAINTEXT_FILE}" + typst compile "${MASTER_SOURCE_FILE}" "${MASTER_PLAINTEXT_FILE}" + + echo "Protecting the master handbook (password: ${MASTER_PASSWORD})" + qpdf --allow-weak-crypto \ + --encrypt "${MASTER_PASSWORD}" "${MASTER_PASSWORD}" 40 -- \ + "${MASTER_PLAINTEXT_FILE}" "${MASTER_OUTPUT_FILE}" + test -f "${OUTPUT_FILE}" test -f "${BALANCE_OUTPUT_FILE}" + test -f "${MASTER_OUTPUT_FILE}" + + # Never archive or publish the unprotected intermediate. + rm "${MASTER_PLAINTEXT_FILE}" echo "Builds complete:" - ls -lh "${OUTPUT_FILE}" "${BALANCE_OUTPUT_FILE}" + ls -lh \ + "${OUTPUT_FILE}" \ + "${BALANCE_OUTPUT_FILE}" \ + "${MASTER_OUTPUT_FILE}" ''' } } @@ -79,7 +106,7 @@ pipeline { stage('Archive PDFs') { steps { archiveArtifacts( - artifacts: "${OUTPUT_FILE},${BALANCE_OUTPUT_FILE}", + artifacts: "${OUTPUT_FILE},${BALANCE_OUTPUT_FILE},${MASTER_OUTPUT_FILE}", fingerprint: true ) } @@ -127,12 +154,12 @@ pipeline { publishChecks( conclusion: 'SUCCESS', name: 'Build Successful', - summary: 'The Ravenous rulebook and balance report were built successfully.', - text: 'The rulebook and balance report were compiled and published successfully.', + summary: 'The Ravenous rulebook, master handbook, and balance report were built successfully.', + text: 'All three PDFs were compiled and published successfully.', title: 'Build Successful' ) - echo '✅ Ravenous book and balance report built and published!' + echo '✅ Ravenous books and balance report built and published!' } failure { @@ -140,7 +167,7 @@ pipeline { conclusion: 'FAILURE', name: 'Build Failed', summary: 'A Ravenous PDF build or deployment failed.', - text: 'Rulebook or balance-report compilation/publication failed.', + text: 'Rulebook, master-handbook, or balance-report compilation/publication failed.', title: 'Build Failed' ) @@ -166,7 +193,7 @@ pipeline { * Publish the generated Ravenous PDFs. * * Build artifacts retain explicit CI names in Jenkins, while published copies - * use stable rulebook and balance-report names. + * use stable rulebook, master-handbook, and balance-report names. * * @param targetDir Directory receiving the compiled book. */ @@ -174,7 +201,7 @@ def deployTo(String targetDir) { sh """ set -e - echo "Publishing Ravenous and its balance report to ${targetDir}" + echo "Publishing Ravenous, its master handbook, and its balance report to ${targetDir}" mkdir -p "${targetDir}" @@ -186,9 +213,14 @@ def deployTo(String targetDir) { "${env.BALANCE_OUTPUT_FILE}" \ "${targetDir}/${env.BALANCE_PUBLISHED_FILE}" + rsync -a \ + "${env.MASTER_OUTPUT_FILE}" \ + "${targetDir}/${env.MASTER_PUBLISHED_FILE}" + echo "Published:" ls -lh \ "${targetDir}/${env.PUBLISHED_FILE}" \ - "${targetDir}/${env.BALANCE_PUBLISHED_FILE}" + "${targetDir}/${env.BALANCE_PUBLISHED_FILE}" \ + "${targetDir}/${env.MASTER_PUBLISHED_FILE}" """ }