From e48c319249268bba9df892489bd5660c8f94ffe0 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Wed, 16 Sep 2026 02:07:55 +0200 Subject: [PATCH] ci: package reports without zip dependency --- Jenkinsfile | 6 +++--- README.md | 3 ++- beffroi.sh | 4 ++-- scripts/package-reports.sh | 12 ++++++------ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a6506c3..f03296c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { stage('Package Reports') { environment { - REPORT_ZIP_PASSWORD = credentials('typst-reporter-publish-password') + REPORT_ARCHIVE_PASSWORD = credentials('typst-reporter-publish-password') } steps { sh ''' @@ -59,7 +59,7 @@ pipeline { set -eu ./beffroi.sh package "${CI_REPORT_DIR}" "${CI_ARTIFACT_DIR}" ''' - archiveArtifacts artifacts: '.ci-artifacts/*.zip.enc', fingerprint: true + archiveArtifacts artifacts: '.ci-artifacts/*.tar.gz.enc', fingerprint: true } } @@ -69,7 +69,7 @@ pipeline { sh ''' set -eu mkdir -p "${DEPLOY_DIR}" - for archive in Reports.zip.enc Diagnostics.zip.enc; do + for archive in Reports.tar.gz.enc Diagnostics.tar.gz.enc; do cp "${CI_ARTIFACT_DIR}/${archive}" "${DEPLOY_DIR}/.${archive}.tmp" mv -f "${DEPLOY_DIR}/.${archive}.tmp" "${DEPLOY_DIR}/${archive}" done diff --git a/README.md b/README.md index b84d7bc..bb8854e 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ commit them with the reports submodule update, and run: ./beffroi.sh all build/publication ``` -Jenkins runs the same build and publishes encrypted report archives from `main`. +Jenkins runs the same build and publishes encrypted `Reports.tar.gz.enc` and +`Diagnostics.tar.gz.enc` archives from `main`. ## Commands diff --git a/beffroi.sh b/beffroi.sh index 39b5a08..2181b2f 100755 --- a/beffroi.sh +++ b/beffroi.sh @@ -37,7 +37,7 @@ case "$command_name" in scripts/build-publication.sh "$1" ;; package) - [[ $# -eq 2 ]]||usage 2; require zip unzip openssl + [[ $# -eq 2 ]]||usage 2; require tar gzip openssl scripts/package-reports.sh "$1" "$2" ;; test) @@ -52,7 +52,7 @@ case "$command_name" in [[ $# -eq 0 ]]||usage 2 require git typst echo "Core tools are available." - for optional in uv zip unzip openssl; do + for optional in uv tar gzip openssl; do if command -v "$optional" >/dev/null 2>&1; then "$optional" --version 2>/dev/null | head -n 1 || true; else echo "Optional tool missing: $optional"; fi done ;; diff --git a/scripts/package-reports.sh b/scripts/package-reports.sh index 7630e4a..54fa205 100755 --- a/scripts/package-reports.sh +++ b/scripts/package-reports.sh @@ -1,20 +1,20 @@ #!/usr/bin/env bash set -euo pipefail set +x -: "${REPORT_ZIP_PASSWORD:?Set REPORT_ZIP_PASSWORD to encrypt publication archives}" +: "${REPORT_ARCHIVE_PASSWORD:?Set REPORT_ARCHIVE_PASSWORD to encrypt publication archives}" build_root=${1:-}; artifact_dir=${2:-} [[ -n "$build_root" && -n "$artifact_dir" && $# -eq 2 ]]||{ echo "Usage: $0 BUILD_ROOT ARTIFACT_DIR" >&2; exit 2; } build_root=$(realpath "$build_root"); mkdir -p "$artifact_dir"; artifact_dir=$(realpath "$artifact_dir") -for command in zip unzip openssl; do command -v "$command" >/dev/null||{ echo "$command is required" >&2; exit 1; }; done +for command in tar gzip openssl; do command -v "$command" >/dev/null||{ echo "$command is required" >&2; exit 1; }; done stage=$(mktemp -d "${TMPDIR:-/tmp}/report-package.XXXXXXXX"); trap 'rm -rf "$stage"' EXIT for category in Reports Diagnostics; do source_dir="$build_root/${category,,}/pdfs"; [[ -d "$source_dir" ]]||source_dir="$build_root/${category,,}" count=0 while IFS= read -r -d '' pdf; do [[ -s "$pdf" && $(head -c 5 "$pdf") == '%PDF-' ]]||{ echo "Invalid PDF: $pdf" >&2; exit 1; }; ((count+=1)); done < <(find "$source_dir" -type f -name '*.pdf' -print0) ((count > 0))||{ echo "No PDFs for $category" >&2; exit 1; } - (cd "$source_dir" && zip -q -r "$stage/$category.zip" . -i '*.pdf') - openssl enc -aes-256-cbc -salt -pbkdf2 -pass env:REPORT_ZIP_PASSWORD -in "$stage/$category.zip" -out "$artifact_dir/$category.zip.enc" - openssl enc -d -aes-256-cbc -pbkdf2 -pass env:REPORT_ZIP_PASSWORD -in "$artifact_dir/$category.zip.enc" -out "$stage/$category.verify.zip" - unzip -tq "$stage/$category.verify.zip" >/dev/null + tar -C "$source_dir" -czf "$stage/$category.tar.gz" . + openssl enc -aes-256-cbc -salt -pbkdf2 -pass env:REPORT_ARCHIVE_PASSWORD -in "$stage/$category.tar.gz" -out "$artifact_dir/$category.tar.gz.enc" + openssl enc -d -aes-256-cbc -pbkdf2 -pass env:REPORT_ARCHIVE_PASSWORD -in "$artifact_dir/$category.tar.gz.enc" -out "$stage/$category.verify.tar.gz" + tar -tzf "$stage/$category.verify.tar.gz" >/dev/null done echo "Created encrypted report archives in $artifact_dir"