|
| 1 | +name: Create Source Tarball |
| 2 | +description: Creates a source tarball from a directory with version substitution and configurable exclusions |
| 3 | +author: phlax |
| 4 | + |
| 5 | +inputs: |
| 6 | + debug: |
| 7 | + type: boolean |
| 8 | + default: false |
| 9 | + exclude-patterns: |
| 10 | + type: string |
| 11 | + default: | |
| 12 | + .git* |
| 13 | + output-name: |
| 14 | + type: string |
| 15 | + required: true |
| 16 | + source-path: |
| 17 | + type: string |
| 18 | + required: true |
| 19 | + template-command: |
| 20 | + type: string |
| 21 | + default: | |
| 22 | + export VERSION_FILE=\"\(.version_file)\" |
| 23 | + export OUTPUT_NAME=\"\(.output_name)\" |
| 24 | + export WORKING_DIRECTORY=\"\(.working_directory)\" |
| 25 | + export EXCLUDES=\"\($excludes)\" |
| 26 | + export TRANSFORM_ARG=\"\($transform_arg)\" |
| 27 | + export SOURCE_PATH=\"\(.source_path)\" |
| 28 | + OUTPUT=$(${SOURCE_ACTION_PATH}/source.sh) |
| 29 | + transform: |
| 30 | + type: string |
| 31 | + default: "" |
| 32 | + version-file: |
| 33 | + type: string |
| 34 | + default: VERSION.txt |
| 35 | + working-directory: |
| 36 | + type: string |
| 37 | + default: . |
| 38 | + |
| 39 | +outputs: |
| 40 | + tarball: |
| 41 | + value: ${{ fromJSON(steps.create-tarball.outputs.output).tarball }} |
| 42 | + version: |
| 43 | + value: ${{ fromJSON(steps.create-tarball.outputs.output).version }} |
| 44 | + |
| 45 | + |
| 46 | +runs: |
| 47 | + using: composite |
| 48 | + steps: |
| 49 | + - uses: envoyproxy/toolshed/actions/bson@c73c1b842058331a14008432c0e162b97cccb2f5 |
| 50 | + id: create-tarball |
| 51 | + env: |
| 52 | + SOURCE_ACTION_PATH: ${{ github.action_path }} |
| 53 | + DEBUG: ${{ inputs.debug == 'true' && '1' || '' }} |
| 54 | + with: |
| 55 | + input: | |
| 56 | + version_file: ${{ inputs.version-file }} |
| 57 | + output_name: ${{ inputs.output-name }} |
| 58 | + transform: ${{ inputs.transform }} |
| 59 | + exclude_patterns: ${{ inputs.exclude-patterns }} |
| 60 | + source_path: ${{ inputs.source-path }} |
| 61 | + working_directory: ${{ inputs.working-directory }} |
| 62 | + filter: | |
| 63 | + .version_file as $version_file |
| 64 | + | .output_name as $output_name |
| 65 | + | (.transform // "") as $transform |
| 66 | + | (.exclude_patterns // "") as $exclude_patterns |
| 67 | + | .source_path as $source_path |
| 68 | + | .working_directory as $working_directory |
| 69 | + | ($exclude_patterns | split("\n") | map(select(length > 0)) | map("--exclude=\(.)") | join(" ")) as $excludes |
| 70 | + | (if $transform != "" then "--transform=\($transform)" else "" end) as $transform_arg |
| 71 | + | "${{ inputs.template-command }}" |
| 72 | + | bash::output |
| 73 | + options: -r |
| 74 | + result-filter: | |
| 75 | + . |
| 76 | + | split("\n") |
| 77 | + | map(select(length > 0)) |
| 78 | + | map(split("=") | {key: .[0], value: .[1]}) |
| 79 | + | from_entries |
0 commit comments