Skip to content

Commit

Permalink
v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels authored Dec 11, 2024
2 parents 6172cee + 11bc8c5 commit 9d7ae3b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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. |


Expand All @@ -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)

Expand All @@ -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)
Expand Down
26 changes: 18 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ author: Patrick Lehmann (@Paebbels)

inputs:
name:
description: |
description: |
Name of the artifact to upload.
type: string
required: false
Expand Down Expand Up @@ -120,7 +120,7 @@ runs:
exit 1
else
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}"
dir="${{ inputs.working-directory }}"
tarDirectory=""
while [[ "${dir}" != "." ]]; do
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9d7ae3b

Please sign in to comment.