From 079a44b5f65f5fbfbe5338dee210cb40d3eabbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Tue, 7 May 2024 09:46:17 +0200 Subject: [PATCH] Use 7zip for creating archives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- .github/actions/artifact_download/action.yml | 4 +- .github/actions/artifact_upload/action.yml | 40 +++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/actions/artifact_download/action.yml b/.github/actions/artifact_download/action.yml index edf875325..2b4c751ea 100644 --- a/.github/actions/artifact_download/action.yml +++ b/.github/actions/artifact_download/action.yml @@ -20,7 +20,7 @@ runs: uses: ./.github/actions/setup_bazel_nix with: nixTools: | - unzip + _7zz - name: Create temporary directory id: tempdir @@ -37,4 +37,4 @@ runs: shell: bash run: | mkdir -p ${{ inputs.path }} - unzip -P '${{ inputs.encryptionSecret }}' -qq -d ${{ inputs.path }} ${{ steps.tempdir.outputs.directory }}/archive.zip + 7zz x -p'${{ inputs.encryptionSecret }}' -t7z -o"${{ inputs.path }}" ${{ steps.tempdir.outputs.directory }}/archive.zip diff --git a/.github/actions/artifact_upload/action.yml b/.github/actions/artifact_upload/action.yml index 21f7b3cbe..2e77fbbc9 100644 --- a/.github/actions/artifact_upload/action.yml +++ b/.github/actions/artifact_upload/action.yml @@ -26,9 +26,47 @@ runs: uses: ./.github/actions/setup_bazel_nix with: nixTools: | - zip + _7zz - name: Create temporary directory id: tempdir shell: bash run: echo "directory=$(mktemp -d)" >> "$GITHUB_OUTPUT" + + - name: Create archive + shell: bash + run: | + shopt -s extglob + paths="${{ inputs.path }}" + paths=${paths%$'\n'} # Remove trailing newline + # Check if any file matches the given pattern(s). + something_exists=false + for pattern in ${paths} + do + if compgen -G "${pattern}" > /dev/null; then + something_exists=true + fi + done + # Create an archive if files exist. + # Don't create an archive file if no files are found + # and warn. + if ! ${something_exists} + then + echo "::warning:: No files/directories found with the provided path(s): ${paths}. No artifact will be uploaded." + exit 0 + fi + for target in ${paths} + do + pushd "$(dirname "${target}")" || exit 1 + 7zz a -p'${{ inputs.encryptionSecret }}' -t7z -ms=on -mhe=on "${{ steps.tempdir.outputs.directory }}/archive.zip" "$(basename "${target}")" + popd || exit 1 + done + + - name: Upload archive as artifact + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: ${{ inputs.name }} + path: ${{ steps.tempdir.outputs.directory }}/archive.zip + retention-days: ${{ inputs.retention-days }} + if-no-files-found: ignore + overwrite: ${{ inputs.overwrite }}