From 391fe3ed1d279f1033a4af2f7287ec176315ec10 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 6 Dec 2024 22:00:54 +0100 Subject: [PATCH] Handle tar in macOS. --- README.md | 21 +++++++++++++++++++++ action.yml | 15 ++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7fed47..3e137ae 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,33 @@ rcdailey/download-tar-action.yml](https://gist.github.com/rcdailey/cd3437bb2c636 ## Fixed behavior compared to `actions/upload-artifact` +*tbd* + +1. Preserve file permissions +2. Defined root directory from where the content of the tarball is constructed. + +## Limitations of `tar` + +### On Linux + +*tbd* + + +### On macOS + +*tbd* + + +### On Windows + +*tbd* ## Dependencies * [actions/upload-artifact@v4](https://github.com/actions/upload-artifact) + ## Contributors * [Patrick Lehmann](https://GitHub.com/Paebbels) (Maintainer) diff --git a/action.yml b/action.yml index 97a1709..7396a3c 100644 --- a/action.yml +++ b/action.yml @@ -140,8 +140,21 @@ runs: done | sort | uniq } + echo -e "Checking tar ($(which tar)): ${ANSI_CYAN}$(tar --version | head -n 1)${ANSI_NOCOLOR}" + echo -n "Assemble OS specific tar command line options ... " + if [[ "${{ runner.os }}" == "macOS" ]]; then + echo -e "${ANSI_Y}[macOS]${ANSI_NOCOLOR}" + filesFrom=("-T") + elif [[ "${{ runner.os }}" == "Linux" || "${{ runner.os }}" == "Windows" ]]; then + echo -e "${ANSI_LIGHT_GREEN}[${{ runner.os }}]${ANSI_NOCOLOR}" + filesFrom=("--verbatim-files-from" "--files-from") + else + echo -e "${ANSI_LIGHT_RED}[UNSUPPORTED]${ANSI_NOCOLOR}" + exit 1 + fi + echo -n "Creating temporary tarball '${tar_directory}${{ inputs.tarball-name }}' ... " - tar -cf "${tar_directory}${{ inputs.tarball-name }}" --verbatim-files-from --files-from <(print_files_unique "${PATTERNS[@]}") + tar -cf "${tar_directory}${{ inputs.tarball-name }}" "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}") if [[ $? -ne 0 ]]; then echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" exit 1