Skip to content

Commit 6172cee

Browse files
authored
v1.3.1
2 parents 2538984 + ca867f8 commit 6172cee

File tree

7 files changed

+218
-29
lines changed

7 files changed

+218
-29
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
# end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = tab
9+
indent_size = 2
10+
tab_width = 2
11+
12+
[*.{yml,yaml}]
13+
indent_style = space
14+
indent_size = 2
15+
16+
[*.md]
17+
trim_trailing_whitespace = false

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
# Maintain GitHub Action runners
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
target-branch: dev
7+
commit-message:
8+
prefix: "[Dependabot]"
9+
labels:
10+
- Dependencies
11+
assignees:
12+
- Paebbels
13+
reviewers:
14+
- Paebbels
15+
schedule:
16+
interval: "daily" # Checks on Monday trough Friday.

.github/pull_request_template.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# New Features
2+
3+
* tbd
4+
* tbd
5+
6+
# Changes
7+
8+
* tbd
9+
* tbd
10+
11+
# Bug Fixes
12+
13+
* tbd
14+
* tbd
15+
16+
# Documentation
17+
18+
* tbd
19+
* tbd
20+
21+
# Unit Tests
22+
23+
* tbd
24+
* tbd
25+
26+
----------
27+
# Related Issues and Pull-Requests
28+
29+
* tbd
30+
* tbd

.github/workflows/ArtifactsUpload.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright © 2024 The pyTooling Authors
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
7+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
# persons to whom the Software is furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
# Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
117
name: Verification of Preserving Artifact Upload
218

319
on:

LICENSE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The MIT License (MIT)
2+
3+
Copyright © 2024 The pyTooling Authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
12+
13+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 101 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,103 @@
1-
# Preserving Artifact Upload Action
1+
# Artifact Upload Action with File Permission Preservation
2+
3+
This composite action, based on [`actions/upload-artifact`](https://github.com/actions/upload-artifact) and packaging
4+
the artifact's content in a tarball, will preserve file attributes like **file permissions**. This essential capability
5+
is not implemented by GitHub until now (requested on [05.12.2019](https://github.com/actions/upload-artifact/issues/38))
6+
and still delayed and/or refused? to be implemented in the future. According to GitHub, the internal API doesn't allow
7+
the implementation of such a feature, but this actions is demonstrating a working solution.
8+
9+
10+
## Usage
11+
12+
```yaml
13+
jobs:
14+
MyJob:
15+
steps:
16+
- name: 📤 Upload artifact 'binaries'
17+
uses: pyTooling/upload-artifact@v4
18+
with:
19+
name: binaries
20+
working-directory: build
21+
path: |
22+
bin
23+
lib
24+
25+
- name: 📤 Upload artifact 'logfiles'
26+
uses: pyTooling/upload-artifact@v4
27+
with:
28+
name: logfiles
29+
path: |
30+
*.report
31+
build/*.log
32+
```
33+
34+
35+
### Input Parameters
36+
37+
| Parameter | Required | Default | Description |
38+
|------------------------|:--------:|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
39+
| `name` | no | `'artifact'` | Name of the artifact to upload. |
40+
| `working-directory` | no | `''` | |
41+
| `path` | yes | | A list of files, directories or wildcard patterns that describes what to upload. |
42+
| `if-no-files-found` | no | `'warn'` | The desired behavior if no files are found using the provided path. <br/> Available Options:<br/>  warn: Output a warning but do not fail the action<br/>  error: Fail the action with an error message<br/>  ignore: Do not output any warnings or errors, the action does not fail |
43+
| `retention-days` | no | repository settings | Duration after which artifact will expire in days. 0 means using default retention. <br/> Minimum 1 day.<br/> Maximum 90 days unless changed from the repository settings page. |
44+
| `compression-level` | no | `6` | The level of compression for Zlib to be applied to the artifact archive.<br/> The value can range from 0 to 9.<br/> For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads. |
45+
| `overwrite` | no | `false` | If true, an artifact with a matching name will be deleted before a new one is uploaded.<br/> If false, the action will fail if an artifact for the given name already exists.<br/> Does not fail if the artifact does not exist. |
46+
| `include-hidden-files` | no | `false` | Whether to include hidden files in the provided path in the artifact.<br/> The file contents of any hidden files in the path should be validated before enabled this to avoid uploading sensitive information. |
47+
| `tarball-name` | no | [^1] | |
48+
49+
[^1]: `'__pyTooling_upload_artifact__.tar'`
50+
51+
52+
### Output Parameters
53+
54+
| Parameter | Description |
55+
|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
56+
| `artifact-id` | GitHub ID of an Artifact, can be used by the REST API |
57+
| `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. |
258

3-
Upload artifacts and preserve file attributes like file permissions.
4-
5-
6-
**Based on:**
7-
* [actions/upload-artifact#38 - upload-artifact does not retain artifact permissions (08. Sep. 2024)](https://github.com/actions/upload-artifact/issues/38#issuecomment-2336484584)
8-
* [Gist:
9-
rcdailey/download-tar-action.yml](https://gist.github.com/rcdailey/cd3437bb2c63647126aa5740824b2a4f)
1059

1160
## Fixed behavior compared to `actions/upload-artifact`
1261

13-
*tbd*
62+
1. **Do preserve file permissions**
63+
The artifact's content is collected in a tarball, which allows preserving file attributes like file permissions.
64+
2. **Don't remove common prefix from files**
65+
`actions/upload-artifact` removes the common prefix from all files before storing in an artifact. This is not a
66+
well-defined behavior. Slightly changing the list of collected files might drastically change the directory structure
67+
of the artifact.
68+
This action defines a root directory from where the content of the tarball is constructed. This is independent of the
69+
list of provided file patterns.
1470

15-
1. Preserve file permissions
16-
2. Defined root directory from where the content of the tarball is constructed.
1771

1872
## Limitations of `tar`
1973

20-
### On Linux
74+
This action uses `tar` as provided by the GitHub runner's operating system images.
2175

22-
*tbd*
76+
### On Linux (GNU tar)
2377

78+
To ensure files starting with a dash aren't considered command line options to `tar`, `tar` is called with
79+
`--verbatim-files-from` option.
2480

25-
### On macOS
2681

27-
*tbd*
82+
### On macOS (BSD tar)
2883

84+
⚠ BSD tar doesn't support a `--verbatim-files-from` option. Thus, files starting with a dash might be interpreted by `tar`
85+
as a command line option.
2986

30-
### On Windows
87+
> **-T filename**, **--files-from filename**
88+
> In `x` or `t` mode, tar will read the list of names to be extracted from filename. In `c` mode, tar will read names to
89+
> be archived from filename. The special name `-C` on a line by itself will cause the current directory to be changed to
90+
> the directory specified on the following line. Names are terminated by newlines unless `--null` is specified. Note
91+
> that `--null` also disables the special handling of lines containing `-C`.
92+
> Note: If you are generating lists of files using `find(1)`, you probably want to use `-n` as well.
93+
>
94+
> Source: https://man.freebsd.org/cgi/man.cgi?tar(1)
3195

32-
*tbd*
96+
97+
### On Windows (GNU tar)
98+
99+
To ensure files starting with a dash aren't considered command line options to `tar`, `tar` is called with
100+
`--verbatim-files-from` option.
33101

34102

35103
## Dependencies
@@ -42,3 +110,19 @@ rcdailey/download-tar-action.yml](https://gist.github.com/rcdailey/cd3437bb2c636
42110
* [Patrick Lehmann](https://GitHub.com/Paebbels) (Maintainer)
43111
* [Sven Köhler](https://GitHub.com/skoehler)
44112
* [and more...](https://GitHub.com/pyTooling/upload-artifact/graphs/contributors)
113+
114+
### Credits
115+
116+
**This action was inspired by and is based on:**
117+
* [actions/upload-artifact#38 - upload-artifact does not retain artifact permissions (08. Sep. 2024)](https://github.com/actions/upload-artifact/issues/38#issuecomment-2336484584)
118+
* [Gist:
119+
rcdailey/download-tar-action.yml](https://gist.github.com/rcdailey/cd3437bb2c63647126aa5740824b2a4f)
120+
121+
122+
## License
123+
124+
This GitHub Composite Action (source code) licensed under [The MIT License](LICENSE.md).
125+
126+
---
127+
128+
SPDX-License-Identifier: MIT

action.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
name: Upload (preserving) Artifact
1+
# The MIT License (MIT)
2+
#
3+
# Copyright © 2024 The pyTooling Authors
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
7+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
# persons to whom the Software is furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
# Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17+
name: Upload Artifact (Preserve File Permissions)
218
branding:
319
icon: upload
420
color: yellow
@@ -9,7 +25,6 @@ inputs:
925
name:
1026
description: |
1127
Name of the artifact to upload.
12-
Optional. Default is 'artifact'
1328
type: string
1429
required: false
1530
default: 'artifact'
@@ -21,7 +36,6 @@ inputs:
2136
path:
2237
description: |
2338
A file, directory or wildcard pattern that describes what to upload
24-
Required.
2539
type: string
2640
required: true
2741
if-no-files-found:
@@ -31,7 +45,6 @@ inputs:
3145
warn: Output a warning but do not fail the action
3246
error: Fail the action with an error message
3347
ignore: Do not output any warnings or errors, the action does not fail
34-
Optional. Default is 'warn'
3548
type: string
3649
required: false
3750
default: 'warn'
@@ -40,24 +53,22 @@ inputs:
4053
Duration after which artifact will expire in days. 0 means using default retention.
4154
Minimum 1 day.
4255
Maximum 90 days unless changed from the repository settings page.
43-
Optional. Defaults to repository settings.
44-
type: integer
56+
Defaults to repository settings.
57+
type: number
4558
required: false
4659
compression-level:
4760
description: |
4861
The level of compression for Zlib to be applied to the artifact archive.
4962
The value can range from 0 to 9.
5063
For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
51-
Optional. Default is '6'
52-
type: integer
64+
type: number
5365
required: false
5466
default: 6
5567
overwrite:
5668
description: |
5769
If true, an artifact with a matching name will be deleted before a new one is uploaded.
5870
If false, the action will fail if an artifact for the given name already exists.
5971
Does not fail if the artifact does not exist.
60-
Optional. Default is 'false'
6172
type: boolean
6273
required: false
6374
default: false
@@ -66,7 +77,6 @@ inputs:
6677
Whether to include hidden files in the provided path in the artifact
6778
The file contents of any hidden files in the path should be validated before
6879
enabled this to avoid uploading sensitive information.
69-
Optional. Default is 'false'
7080
type: boolean
7181
required: false
7282
default: false
@@ -84,7 +94,7 @@ outputs:
8494
URL to download an Artifact. Can be used in many scenarios such as linking to
8595
artifacts in issues or pull requests. Users must be logged-in in order for this
8696
URL to work. This URL is valid as long as the artifact has not expired or the
87-
artifact, run or repository have not been deleted
97+
artifact, run or repository have not been deleted.
8898
value: ${{ steps.upload.outputs.artifact-url }}
8999

90100
runs:
@@ -157,7 +167,7 @@ runs:
157167
fi
158168
159169
echo -n "Creating temporary tarball '${tarDirectory}${{ inputs.tarball-name }}' ... "
160-
tar -cf "${tarDirectory}${{ inputs.tarball-name }}" "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}")
170+
tar -cf "${tarDirectory}${{ inputs.tarball-name }}" --owner=0 --group=0 "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}")
161171
if [[ $? -ne 0 ]]; then
162172
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
163173
exit 1

0 commit comments

Comments
 (0)