From 61727f9ed6b5a3f1af6ef211f2c19ad02e5421c6 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 17 Jan 2025 15:36:15 +0100 Subject: [PATCH 1/4] Added badges. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 64af52f..dbbedea 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![GitHub Workflow - Build and Test Status](https://img.shields.io/github/actions/workflow/status/pyTooling/upload-artifact/.github%2Fworkflows%2FArtifactsUpload.yml?branch=dev&logo=githubactions)](https://GitHub.com/pyTooling/upload-artifact/actions/workflows/ArtifactsUpload.yml) +[![Sourcecode License](https://img.shields.io/badge/code-MIT%20License-green?longCache=true&style=flat-square&logoColor=fff)](LICENSE.md) + # Artifact Upload Action with File Permission Preservation This composite action, based on [`actions/upload-artifact`](https://github.com/actions/upload-artifact) and packaging From 4be35d63c7942595b6178510a03de0be7ecf3e4d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 17 Jan 2025 15:36:25 +0100 Subject: [PATCH 2/4] Improved YAML coding style. --- action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 45ba715..67bab4c 100644 --- a/action.yml +++ b/action.yml @@ -14,7 +14,7 @@ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -name: Upload Artifact (Preserve File Permissions) +name: 📤 Upload Artifact (Preserve File Permissions) branding: icon: upload color: yellow @@ -153,7 +153,7 @@ runs: tarDirectory="../${tarDirectory}" dir=$(dirname -- "${dir}") done - printf "%s\n" " tarDirectory: ${tarDirectory}" + printf " %s\n" "tarDirectory: ${tarDirectory}" fi else printf "%s\n" "echo ${ANSI_LIGHT_RED}[NO DIRECTORY]${ANSI_NOCOLOR}" @@ -299,10 +299,10 @@ runs: printf "::endgroup::\n" # https://github.com/actions/upload-artifact - - name: Upload artifact (tarball) + - name: 📤 Upload artifact (tarball) + uses: actions/upload-artifact@v4 id: upload if: inputs.mode == 'tar' - uses: actions/upload-artifact@v4 with: name: ${{ inputs.name }} path: ${{ inputs.tarball-name }} @@ -336,10 +336,10 @@ runs: printf "%s\n" "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" fi - - name: Upload artifact (legacy) + - name: 📤 Upload artifact (legacy) + uses: actions/upload-artifact@v4 id: upload-legacy if: inputs.mode == 'legacy' - uses: actions/upload-artifact@v4 with: name: ${{ inputs.name }} path: ${{ inputs.path }} From 7d245147004cc2158d84705447dbaf580a3f6928 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 20 Jan 2025 22:41:53 +0100 Subject: [PATCH 3/4] Enhanced YAMl coding style. Marked one macOS case as known-issue. --- .github/workflows/ArtifactsUpload.yml | 130 ++++++++++++++------------ 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ArtifactsUpload.yml b/.github/workflows/ArtifactsUpload.yml index 96cd1a3..716b991 100644 --- a/.github/workflows/ArtifactsUpload.yml +++ b/.github/workflows/ArtifactsUpload.yml @@ -28,9 +28,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -92,9 +92,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -127,9 +127,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -162,9 +162,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -199,9 +199,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -238,9 +238,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -275,9 +275,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -310,9 +310,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -348,9 +348,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -387,9 +387,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} defaults: run: shell: bash @@ -426,9 +426,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } steps: - name: ⏬ Checkout repository to use local actions @@ -469,9 +469,15 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} - - {'icon': '🍏', 'name': 'macOS', 'image': 'macos-14' } - - {'icon': '🪟', 'name': 'Windows', 'image': 'windows-2022'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🪟', name: 'Windows', image: 'windows-2022'} + option: + - {can-fail: false} + include: + - {os: {icon: '🍏', name: 'macOS', image: 'macos-14'}, option: {can-fail: true}} + + continue-on-error: ${{ matrix.option.can-fail }} + defaults: run: shell: bash @@ -543,10 +549,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -597,10 +603,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -653,10 +659,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -709,10 +715,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -769,10 +775,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -821,10 +827,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -877,10 +883,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -943,10 +949,10 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'inspect', 'artifact': 'github', 'action': 'actions/upload-artifact'} - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'inspect', artifact: 'github', action: 'actions/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash @@ -1003,9 +1009,9 @@ jobs: fail-fast: false matrix: os: - - {'icon': '🐧', 'name': 'Ubuntu', 'image': 'ubuntu-24.04'} + - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} task: - - {'name': 'verify' , 'artifact': 'pyTooling', 'action': 'pyTooling/upload-artifact'} + - {name: 'verify' , artifact: 'pyTooling', action: 'pyTooling/upload-artifact'} defaults: run: shell: bash From 4658ed8f9d76c9dcde4a51f8d8fd57c20afca770 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 20 Jan 2025 23:31:15 +0100 Subject: [PATCH 4/4] Using gnu-tar on macOS. --- .github/workflows/ArtifactsUpload.yml | 7 +-- README.md | 16 ++++-- action.yml | 81 ++++++++++++++------------- 3 files changed, 55 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ArtifactsUpload.yml b/.github/workflows/ArtifactsUpload.yml index 716b991..feae1bf 100644 --- a/.github/workflows/ArtifactsUpload.yml +++ b/.github/workflows/ArtifactsUpload.yml @@ -470,13 +470,8 @@ jobs: matrix: os: - {icon: '🐧', name: 'Ubuntu', image: 'ubuntu-24.04'} + - {icon: '🍏', name: 'macOS', image: 'macos-14' } - {icon: '🪟', name: 'Windows', image: 'windows-2022'} - option: - - {can-fail: false} - include: - - {os: {icon: '🍏', name: 'macOS', image: 'macos-14'}, option: {can-fail: true}} - - continue-on-error: ${{ matrix.option.can-fail }} defaults: run: diff --git a/README.md b/README.md index dbbedea..6ca4a3c 100644 --- a/README.md +++ b/README.md @@ -98,9 +98,9 @@ jobs: ## Limitations of `tar` -This action uses `tar` as provided by the GitHub runner's operating system images. +This composite action uses `tar`/`gtar` (GNU tar) as provided by the GitHub runner's operating system images. -### On Linux and Windows (GNU tar) +### On Linux, macOS and Windows (GNU tar) To ensure files starting with a dash aren't considered command line options to `tar`, `tar` is called with `--verbatim-files-from` option. @@ -108,9 +108,17 @@ To ensure files starting with a dash aren't considered command line options to ` To ensure files are extracted and assigned to the owner/group of the extracting user, options `--owner=root:0` and `--group=root:0` are used when creating the tarball. +In case, parameter `include-hidden-files` isn't set, hidden files (dot-files) are removed from the tarball in a further +cleanup step using the `--delete` command. This step is needed to ensure compatibility with the original +`actions/upload-artifact` action provided by GitHub. -### On macOS (BSD tar) +### Alternative BSD tar on macOS +BSD tar has even worse limitations than GNU tar and offers fewer features. Thus, this composite action uses GNU tar on +macOS, too. Fortunately, GNU tar (`gtar`) is already preinstalled via homebrew on all macOS runner images provided by +GitHub. For more details on BSD tar expand the following collapsible section. + +
Unused BSD tar on macOS ⚠ BSD tar doesn't support a `--delete` option. Thus, hidden files (dot files) can't be removed (excluded) from tarballs. Removing discovered hidden files afterward from created tarballs is used on runner OS providing GNU tar. This technique can't be applied to BSD tar. [^2] @@ -129,7 +137,7 @@ as a command line option. To ensure files are extracted and assigned to the owner/group of the extracting user, options `--gname=root`, `--gid=0`, `--uname=root` and `--uid=0` are used when creating the tarball. - +
## Dependencies diff --git a/action.yml b/action.yml index 67bab4c..0d6ce75 100644 --- a/action.yml +++ b/action.yml @@ -131,12 +131,23 @@ runs: ANSI_LIGHT_BLUE="\e[94m" ANSI_NOCOLOR=$'\x1b[0m' + if ! [[ "${{ runner.os }}" == "macOS" || "${{ runner.os }}" == "Linux" || "${{ runner.os }}" == "Windows" ]]; then + printf "::error title=%s::%s\n" "pyTooling/upload-artifact" "Unsupported runner OS '${{ runner.os }}'." + exit 1 + fi + if [[ "${{ inputs.investigate }}" == "true" ]]; then - printf "::group::${ANSI_LIGHT_BLUE}List all shell options via 'shopt' ...${ANSI_NOCOLOR}\n" + printf "::group::${ANSI_LIGHT_BLUE}%s${ANSI_NOCOLOR}\n" "List all shell options via 'shopt' ..." shopt printf "::endgroup::\n" fi + if [[ "${{ runner.os }}" == "macOS" ]]; then + tarProg="gtar" + else + tarProg="tar" + fi + if [[ "${{ inputs.working-directory }}" != "" ]]; then printf "%s" "Changing artifact root directory to '${{ inputs.working-directory }}' ... " if [[ -d "${{ inputs.working-directory }}" ]]; then @@ -190,48 +201,32 @@ runs: done | sort | uniq } - printf "::group::${ANSI_LIGHT_BLUE}List all pattern for 'tar' ...${ANSI_NOCOLOR}\n" + printf "::group::${ANSI_LIGHT_BLUE}List all pattern for '${tarProg}' ...${ANSI_NOCOLOR}\n" while IFS=$'\r\n' read -r pattern; do printf " %s\n" "${pattern}" done <<<$(print_files_unique "${PATTERNS[@]}") printf "::endgroup::\n" - printf "%s\n" "Checking tar ($(which tar)): ${ANSI_CYAN}$(tar --version | head -n 1)${ANSI_NOCOLOR}" - printf "%s" "Assemble OS specific tar command line options ... " - if [[ "${{ runner.os }}" == "macOS" ]]; then - printf "%s\n" "${ANSI_LIGHT_YELLOW}[macOS]${ANSI_NOCOLOR}" - - # Options for BSD tar - tarOptions=("--gname=root" "--gid=0" "--uname=root" "--uid=0") - - # Option to read filenames from file - filesFrom=("-T") - elif [[ "${{ runner.os }}" == "Linux" || "${{ runner.os }}" == "Windows" ]]; then - printf "%s\n" "${ANSI_LIGHT_GREEN}[${{ runner.os }}]${ANSI_NOCOLOR}" - - # Options for GNU tar - tarOptions=("--owner=root:0" "--group=root:0") + printf "%s\n" "Checking ${tarProg} ($(which ${tarProg})): ${ANSI_CYAN}$(${tarProg} --version | head -n 1)${ANSI_NOCOLOR}" + printf "%s\n" "Assemble OS specific tar command line options ... ${ANSI_LIGHT_GREEN}[${{ runner.os }}]${ANSI_NOCOLOR}" - # Option to read filenames from file - filesFrom=("--verbatim-files-from" "--files-from") - else - printf "%s\n" "${ANSI_LIGHT_RED}[UNSUPPORTED]${ANSI_NOCOLOR}" - printf "::error title=%s::%s\n" "pyTooling/upload-artifact" "Unsupported runner OS '${{ runner.os }}'." - exit 1 - fi + # Options for GNU tar + tarOptions=("--owner=root:0" "--group=root:0") + # Option to read filenames from file + filesFrom=("--verbatim-files-from" "--files-from") printf "%s" "Creating temporary tarball '${tarDirectory}${{ inputs.tarball-name }}' ... " - msg=$(tar -cf "${tarDirectory}${{ inputs.tarball-name }}" "${tarOptions[@]}" "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}")) + msg=$(${tarProg} -cf "${tarDirectory}${{ inputs.tarball-name }}" "${tarOptions[@]}" "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}")) if [[ $? -ne 0 ]]; then printf "%s\n" "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" - printf "::error title=%s::%s\n" "pyTooling/upload-artifact" "tar: ${msg}" + printf "::error title=%s::%s\n" "pyTooling/upload-artifact" "${tarProg}: ${msg}" exit 1 else printf "%s\n" "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" fi - dirCount=$(tar -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -E '/$' | wc -l) - fileCount=$(tar -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -v -E '/$' | wc -l) + dirCount=$(${tarProg} -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -E '/$' | wc -l) + fileCount=$(${tarProg} -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -v -E '/$' | wc -l) printf "%s\n" "${ANSI_CYAN}Collected items:${ANSI_NOCOLOR}" printf " %s\n" "${ANSI_CYAN}Directories: ${dirCount}${ANSI_NOCOLOR}" printf " %s\n" "${ANSI_CYAN}Files: ${fileCount}${ANSI_NOCOLOR}" @@ -264,17 +259,19 @@ runs: ANSI_LIGHT_BLUE="\e[94m" ANSI_NOCOLOR=$'\x1b[0m' - if [[ "${{ runner.os }}" != "macOS" ]]; then - printf "::group::${ANSI_LIGHT_BLUE}Removing unwanted files from '${{ inputs.tarball-name }}' ...:${ANSI_NOCOLOR}\n" - while IFS=$'\r\n' read -r file; do - printf " %s\n" "${file}" - tar -vf "${{ inputs.tarball-name }}" --delete "${file}" - done <<<$(tar -tf "${{ inputs.tarball-name }}" | grep -E '^\.|/\.') - printf "::endgroup::\n" + if [[ "${{ runner.os }}" == "macOS" ]]; then + tarProg="gtar" else - printf "::warning title=%s::%s\n" "pyTooling/upload-artifact" "macOS doesn't support removing hidden files." + tarProg="tar" fi + printf "::group::${ANSI_LIGHT_BLUE}Removing unwanted files from '${{ inputs.tarball-name }}' ...:${ANSI_NOCOLOR}\n" + while IFS=$'\r\n' read -r file; do + printf " %s\n" "${file}" + ${tarProg} -vf "${{ inputs.tarball-name }}" --delete "${file}" + done <<<$(${tarProg} -tf "${{ inputs.tarball-name }}" | grep -E '^\.|/\.') + printf "::endgroup::\n" + - name: List content of the generated tarball id: investigate if: inputs.mode == 'tar' && inputs.investigate == 'true' @@ -290,11 +287,17 @@ runs: ANSI_LIGHT_BLUE="\e[94m" ANSI_NOCOLOR=$'\x1b[0m' + if [[ "${{ runner.os }}" == "macOS" ]]; then + tarProg="gtar" + else + tarProg="tar" + fi + printf "::group::${ANSI_LIGHT_BLUE}Content of '${{ inputs.tarball-name }}':${ANSI_NOCOLOR}\n" - tar -tvf "${{ inputs.tarball-name }}" + ${tarProg} -tvf "${{ inputs.tarball-name }}" printf "\n" - dirCount=$(tar -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -E '/$' | wc -l) - fileCount=$(tar -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -v -E '/$' | wc -l) + dirCount=$(${tarProg} -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -E '/$' | wc -l) + fileCount=$(${tarProg} -tf "${tarDirectory}${{ inputs.tarball-name }}" | grep -v -E '/$' | wc -l) printf "%s\n" "${ANSI_CYAN}Directories: ${dirCount} Files: ${fileCount}${ANSI_NOCOLOR}" printf "::endgroup::\n"