diff --git a/README.md b/README.md index d823a2d..8218ba9 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ is not implemented by GitHub until now (requested on [05.12.2019](https://github and still delayed and/or refused? to be implemented in the future. According to GitHub, the internal API doesn't allow the implementation of such a feature, but this actions is demonstrating a working solution. +See [pyTooling/download-artifact](https://github.com/pyTooling/download-artifact) for the matching download action. + ## Usage @@ -53,7 +55,7 @@ jobs: | Parameter | Description | |----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `artifact-id` | GitHub ID of an Artifact, can be used by the REST API | +| `artifact-id` | GitHub ID of an Artifact, can be used by the REST API. | | `artifact-url` | URL to download an Artifact. Can be used in many scenarios such as linking to artifacts in issues or pull requests. Users must be logged-in in order for this URL to work. This URL is valid as long as the artifact has not expired or the artifact, run or repository have not been deleted. | @@ -78,6 +80,9 @@ This action uses `tar` as provided by the GitHub runner's operating system image To ensure files starting with a dash aren't considered command line options to `tar`, `tar` is called with `--verbatim-files-from` option. +To ensure files are extracted and assigned to the owner/group of the extracting user, options `--owner=0` and +`--group=0` are used when creating the tarball. + ### On macOS (BSD tar) @@ -93,18 +98,30 @@ as a command line option. > > Source: https://man.freebsd.org/cgi/man.cgi?tar(1) +⚠ BSD tar doesn't support a `--owner=0` and `--group=0` option. + ### On 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. +To ensure files are extracted and assigned to the owner/group of the extracting user, options `--owner=0` and +`--group=0` are used when creating the tarball. + ## Dependencies * [actions/upload-artifact@v4](https://github.com/actions/upload-artifact) +## Competing Actions + +* [eviden-actions/upload-artifact](https://github.com/eviden-actions/upload-artifact) +* [nmerget/upload-gzip-artifact](https://github.com/nmerget/upload-gzip-artifact) +* [alehechka/upload-tartifact](https://github.com/alehechka/upload-tartifact) + + ## Contributors * [Patrick Lehmann](https://GitHub.com/Paebbels) (Maintainer) diff --git a/action.yml b/action.yml index 0695273..8802e4a 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,7 @@ author: Patrick Lehmann (@Paebbels) inputs: name: - description: | + description: | Name of the artifact to upload. type: string required: false @@ -120,7 +120,7 @@ runs: exit 1 else echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" - + dir="${{ inputs.working-directory }}" tarDirectory="" while [[ "${dir}" != "." ]]; do @@ -146,35 +146,45 @@ runs: PATTERNS+=("$pattern") done <<<'${{ inputs.path }}' echo -e "${ANSI_LIGHT_GREEN}[DONE]${ANSI_NOCOLOR}" - + print_files_unique() { for i in "$@"; do compgen -G "$i" || true 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}" + + # Options for BSD tar + tarOptions=() + + # Option to read filenames from file filesFrom=("-T") elif [[ "${{ runner.os }}" == "Linux" || "${{ runner.os }}" == "Windows" ]]; then echo -e "${ANSI_LIGHT_GREEN}[${{ runner.os }}]${ANSI_NOCOLOR}" + + # Options for GNU tar + tarOptions=("--owner=0" "--group=0") + + # Option to read filenames from file filesFrom=("--verbatim-files-from" "--files-from") else echo -e "${ANSI_LIGHT_RED}[UNSUPPORTED]${ANSI_NOCOLOR}" exit 1 fi - + echo -n "Creating temporary tarball '${tarDirectory}${{ inputs.tarball-name }}' ... " - tar -cf "${tarDirectory}${{ inputs.tarball-name }}" --owner=0 --group=0 "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}") + tar -cf "${tarDirectory}${{ inputs.tarball-name }}" "${tarOptions[@]}" "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}") if [[ $? -ne 0 ]]; then echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" exit 1 else echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" fi - + echo -e "${ANSI_CYAN}Files collected: $(tar -tf "${tarDirectory}${{ inputs.tarball-name }}" | wc -l)${ANSI_NOCOLOR}" # https://github.com/actions/upload-artifact @@ -199,7 +209,7 @@ runs: ANSI_LIGHT_RED="\e[91m" ANSI_LIGHT_GREEN="\e[92m" ANSI_NOCOLOR="\e[0m" - + echo -n "Removing temporary tarball ... " rm -f "${{ inputs.tarball-name }}" if [[ $? -ne 0 ]]; then