Skip to content

Commit

Permalink
ceng-228: Add "tag" option for uploading packages (#55)
Browse files Browse the repository at this point in the history
* Add "tags" to list of options
  • Loading branch information
BartoszBlizniak authored May 21, 2024
1 parent f04b4de commit 468883c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The following examples use static files located within `test/fixtures`. When rep

To pin to a specific release of this Github Action, replace `use: cloudsmith-io/action@master` with the version you require e.g. `uses: cloudsmith-io/action@0.4.0`.

You can also add "tags" to your upload process by specifying `tags` in your workflow, this is a comma separated string. (Some special characters like `:` are not allowed).

### Alpine Package Push

```yaml
Expand All @@ -74,6 +76,7 @@ jobs:
release: "v3.9"
republish: "true" # needed ONLY if version is not changing
file: "test/fixture/cloudsmith-alpine-example-1.0.0-r0.apk"
tags: "tag1, tag2, tag3"
```
### Cargo Crate Push
Expand Down Expand Up @@ -120,6 +123,7 @@ jobs:
repo: "actions"
republish: "true" # needed ONLY if version is not changing
file: "test/fixture/cloudsmith-composer-package-archive-0.1.0.zip"
tags: "tag1, tag2, tag3"
```
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ inputs:
description: "Nuget: Relevant Symbols file for the nuget package."
required: false
default: none
tags:
description: "The tags for the package, comma seperated"
required: false
default: none
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -125,6 +129,7 @@ runs:
-N ${{ inputs.symbols-file }} \
-S ${{ inputs.scope }} \
-s "${{ inputs.summary }}" \
-t "${{ inputs.tags }}" \
-D "${{ inputs.description }}" \
-V ${{ inputs.version }} \
-p ${{ inputs.pom-file }} \
Expand Down
10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ function setup_options {
options["pom_file"]=$DEFAULT
options["symbols_file"]=$DEFAULT
options["extra"]=$DEFAULT
options["tags"]=$DEFAULT

local raw_opts="$@"
local OPTIND OPT

while getopts ":k:K:f:o:r:F:P:w:W:d:R:n:N:S:s:D:V:p:" OPT; do
while getopts ":k:K:f:o:r:F:P:w:W:d:R:n:N:S:s:t:D:V:p:" OPT; do
case $OPT in
k) options["api_key"]="$OPTARG" ;;
K) options["command"]="$OPTARG" ;;
Expand All @@ -63,6 +64,7 @@ function setup_options {
N) options["symbols_file"]="$OPTARG" ;;
S) options["scope"]="$OPTARG" ;;
s) options["summary"]="$OPTARG" ;;
t) options["tags"]="$OPTARG" ;;
D) options["description"]="$OPTARG" ;;
V) options["version"]="$OPTARG" ;;
p) options["pom_file"]="$OPTARG" ;;
Expand Down Expand Up @@ -180,12 +182,16 @@ function execute_push {
export CLOUDSMITH_API_KEY="${options["api_key"]}"
}

check_option_set "${options["tags"]}" && {
params+=" --tags='${options["tags"]}'"
}

local extra=""
check_option_set "${options["extra"]}" && {
extra="${options["extra"]}"
}

local request="cloudsmith push ${options["action"]} ${options["format"]} $context ${options["file"]} $params $extra"
local request="cloudsmith push ${options["action"]} ${options["format"]} $context ${options["file"]} $params $extra $tags"
echo $request
eval $request
}
Expand Down

0 comments on commit 468883c

Please sign in to comment.