Skip to content

Commit 54a8f4f

Browse files
author
Aaron Roller
authored
Merge pull request #3 from AutoModality/BB-763
BB-763 cloudsmith now pushing raw Forcing merge because I think it is a tag race that is causing the failure.
2 parents 5aace01 + eea2312 commit 54a8f4f

7 files changed

Lines changed: 201 additions & 29 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: Cloudsmith Push
1+
name: Push Debian
22
on: push
33
jobs:
44
push:
55
runs-on: ubuntu-latest
6-
name: Push demo
6+
name: Debian Push Demo
77
steps:
8+
- uses: actions/checkout@v1
89
- name: Push
910
id: push
10-
uses: AutoModality/action-cloudsmith@0.1.0
11+
uses: AutoModality/action-cloudsmith@0.2.0
1112
with:
1213
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
1314
command: 'push'
@@ -16,5 +17,6 @@ jobs:
1617
repo: 'trial'
1718
distro: 'ubuntu'
1819
release: 'xenial'
19-
file: '/bin/bash' #real file, but wrong format
20+
republish: 'true' # needed since version is not changing
21+
file: 'test/fixture/aruco_3.1.0-1_amd64.deb' #real file that will repeat versions
2022

.github/workflows/push-raw.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Push Raw
2+
on: push
3+
jobs:
4+
push:
5+
runs-on: ubuntu-latest
6+
name: Raw File Push Test
7+
steps:
8+
- uses: actions/checkout@v1
9+
- name: Push
10+
id: push
11+
uses: AutoModality/action-cloudsmith@0.2.0
12+
with:
13+
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
14+
command: 'push'
15+
format: 'raw'
16+
owner: 'automodality'
17+
repo: 'trial'
18+
file: 'test/fixture/raw-file.txt'
19+
name: 'Raw Test'
20+
summary: 'Github Action test of raw pushes'
21+
description: 'See https://github.com/AutoModality/action-cloudsmith/actions'
22+
version: ${{ github.sha}}
23+
24+

README.md

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,90 @@ to its structure and terminology as possible.
88

99
**Implemented**
1010
* Push
11-
* Debian format
11+
* [Debian format](https://cloudsmith.io/l/deb-repository/)
12+
* [Raw format](https://cloudsmith.io/f/raw_file_repositories/)
1213

1314
**Not Implemented**
1415
* Everything else
1516

1617
## Cloudsmith API Key
1718

1819
The API key is required for the cloudsmith-cli to work.
19-
Add a secret in the settings of your repository named `CLOUDSMITH_API_KEY`.
2020

21-
## Example usage
21+
Obtain the API Key from [Cloudsmith user settings](https://cloudsmith.io/user/settings/api/). You should use a less priveleged and generic account for Continuous Integration.
22+
23+
Add a secret named `CLOUDSMITH_API_KEY` and a value of the API Key obtained from cloudsmith. Secrets are maintained in the settings of each repository.
24+
25+
Pass your secret to the Action as seen in the Example usage.
26+
27+
28+
# Examples
29+
30+
## Raw File Push
31+
32+
[
33+
![Package Workflow Status](https://github.com/AutoModality/action-cloudsmith/workflows/Push%20Raw/badge.svg)](https://github.com/AutoModality/action-cloudsmith/actions?query=workflow%3A%22Push+Raw%22)
34+
35+
36+
[![Latest Version @ Cloudsmith](https://api-prd.cloudsmith.io/badges/version/automodality/trial/raw/Raw%20Test/latest/x/?render=true&badge_token=gAAAAABeClEKOQZCVujPlMzTyVCuImA8NXf-MnlI5GvpESmdpZBDK59OsgPrQlkyYqpbM60QvPeFLOVyJNuG7KW2AS756ghSurzX_5bSA3p28fbDVb31k6I%3D)](https://cloudsmith.io/~automodality/repos/trial/packages/detail/raw/Raw%2520Test/latest/)
37+
38+
See [push-raw.yml](.github/workflows/push-raw.yml)
39+
```
40+
name: Push Raw
41+
on: push
42+
jobs:
43+
push:
44+
runs-on: ubuntu-latest
45+
name: Raw File Push Test
46+
steps:
47+
- uses: actions/checkout@v1
48+
- name: Push
49+
id: push
50+
uses: AutoModality/action-cloudsmith@0.2.0
51+
with:
52+
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
53+
command: 'push'
54+
format: 'raw'
55+
owner: 'automodality'
56+
repo: 'trial'
57+
file: 'test/fixture/raw-file.txt'
58+
name: 'Raw Test'
59+
summary: 'Github Action test of raw pushes'
60+
description: 'See https://github.com/AutoModality/action-cloudsmith/actions'
61+
version: ${{ github.sha}}
2262
2363
```
24-
name: Cloudsmith Push
64+
65+
## Debian Package Push
66+
67+
[
68+
![Package Workflow Status](https://github.com/AutoModality/action-cloudsmith/workflows/Push%20Debian/badge.svg)](https://github.com/AutoModality/action-cloudsmith/actions?query=workflow%3A%22Push+Debian%22)
69+
70+
71+
[![Latest Version @ Cloudsmith](https://api-prd.cloudsmith.io/badges/version/automodality/trial/deb/aruco/latest/d=ubuntu%252Fxenial;t=1/?render=true&badge_token=gAAAAABeCm2C111HnG6P0q-4-hrU04M1vFbkeIiChmj6Rb7_pVR_dT_e3726dStLG8QjBMQM2U09KKEv96pemcC61lgbqW6TTW8leqmLUjx3CT5_pPNaA0I%3D)](https://cloudsmith.io/~automodality/repos/trial/packages/detail/deb/aruco/latest/d=ubuntu%252Fxenial;t=1/)
72+
73+
See [push-debian.yml](.github/workflows/push-debian.yml)
74+
```
75+
name: Push Debian
2576
on: push
2677
jobs:
2778
push:
2879
runs-on: ubuntu-latest
29-
name: Push demo
80+
name: Debian Push Demo
3081
steps:
82+
- uses: actions/checkout@v1
3183
- name: Push
3284
id: push
33-
uses: AutoModality/action-cloudsmith@0.1.0
85+
uses: AutoModality/action-cloudsmith@0.2.0
3486
with:
87+
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
3588
command: 'push'
3689
format: 'deb'
3790
owner: 'automodality'
3891
repo: 'trial'
3992
distro: 'ubuntu'
4093
release: 'xenial'
41-
file: 'cool-lib_1.0.1_amd64.deb'
94+
republish: 'true'
95+
file: 'test/fixture/aruco_3.1.0-1_amd64.deb' #real file, but will fail due to repeat versions
96+
4297
```

action.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,52 @@ inputs:
55
api-key:
66
description: 'The Cloudsmith API Key in the Github Secrets repository settings.'
77
required: true
8+
default: none
89
command:
910
description: 'The desired action with cloudsmith (push, list, etc)'
1011
required: true
1112
default: help
1213
format:
1314
description: 'The package format (deb,npm,maven, etc)'
1415
required: true
16+
default: none
1517
owner:
1618
description: 'The organization that owns the repository'
1719
required: true
20+
default: none
1821
repo:
1922
description: 'The repository slug'
2023
required: true
24+
default: none
2125
file:
2226
description: 'The package file to be pushed'
2327
required: true
28+
default: none
2429
distro:
2530
description: 'Debian: The distribution (ubuntu)'
2631
required: false
32+
default: none
2733
release:
2834
description: 'Debian: The named version of the release (xenial)'
2935
required: false
30-
36+
default: none
37+
name:
38+
description: '--name TEXT: The name of this package.'
39+
required: false
40+
default: none
41+
summary:
42+
description: '--summary TEXT: A one-liner synopsis of this package.'
43+
required: false
44+
default: none
45+
description:
46+
description: '--description TEXT: A textual description of this package.'
47+
required: false
48+
default: none
49+
republish:
50+
description: '--republish: If true, the uploaded package will overwrite
51+
any others with the same attributes.'
52+
required: false
53+
default: "false"
3154
runs:
3255
using: 'docker'
3356
image: 'Dockerfile'
@@ -39,4 +62,10 @@ runs:
3962
- ${{ inputs.repo }}
4063
- ${{ inputs.file }}
4164
- ${{ inputs.distro }}
42-
- ${{ inputs.release }}
65+
- ${{ inputs.release }}
66+
- ${{ inputs.version }}
67+
- ${{ inputs.name }}
68+
- ${{ inputs.summary }}
69+
- ${{ inputs.description }}
70+
- ${{ inputs.republish }}
71+

entrypoint.sh

Lines changed: 77 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,96 @@
22

33
set -e #exit on error
44

5-
api_key=$1
6-
command=$2
7-
format=$3
8-
org=$4
9-
repo=$5
10-
file=$6
11-
distro=$7
12-
release=$8
5+
DEFAULT="none" # a way to handle ordered empty arguments of bash
136

7+
api_key=${1}
8+
command=${2}
9+
format=${3}
10+
owner=${4}
11+
repo=${5}
12+
file=${6}
13+
distro=${7}
14+
release=${8}
15+
version=${9}
16+
name=${10}
17+
summary=${11}
18+
description=${12}
19+
republish=${13}
1420

1521
# requires a CLOUDSMITH_API_KEY env variable to push
16-
if [[ -z $api_key ]]; then
22+
if [[ -z $api_key || $api_key == $DEFAULT ]]; then
1723
echo "CLOUDSMITH_API_KEY is required"
1824
exit 1
1925
fi
2026

21-
export CLOUDSMITH_API_KEY=$api_key
27+
if [[ -z $command || $command == $DEFAULT ]]; then
28+
echo "command is required"
29+
exit 1
30+
fi
31+
if [[ -z $format || $format == $DEFAULT ]]; then
32+
echo "format is required"
33+
exit 1
34+
fi
35+
if [[ -z $owner || $owner == $DEFAULT ]]; then
36+
echo "owner is required"
37+
exit 1
38+
fi
39+
if [[ -z $repo || $repo == $DEFAULT ]]; then
40+
echo "repo is required"
41+
exit 1
42+
fi
43+
if [[ -z "$file" || $file == $DEFAULT ]]; then
44+
echo "file is required."
45+
exit 3
46+
fi
2247

2348
if [[ "$command" != "push" ]]; then
24-
echo "command $comand not yet implemented."
49+
echo "command $command not yet implemented."
2550
exit 3
2651
fi
2752

28-
pip install cloudsmith-cli
2953

3054

31-
if [[ "$format" == "deb" ]]; then
32-
cloudsmith push $action $format $org/$repo/$distro/$release $file
33-
else
55+
case "$format" in
56+
"deb"|"raw")
57+
58+
if [[ -n "$distro" && "$distro" != $DEFAULT ]]; then
59+
distro_path="/$distro"
60+
if [[ -n "$release" && $release != $DEFAULT ]]; then
61+
distro_path="$distro_path/$release"
62+
fi
63+
fi
64+
65+
# these optional args provided only if valid
66+
# notice the spaces are built into the args
67+
if [[ -n "$version" && "$version" != $DEFAULT ]]; then
68+
version_arg=" --version=\"$version\""
69+
fi
70+
if [[ -n "$name" && "$name" != "$DEFAULT" ]]; then
71+
name_arg=" --name=\"$name\""
72+
fi
73+
if [[ -n "$summary" && "$summary" != $DEFAULT ]]; then
74+
summary_arg=" --summary=\"$summary\""
75+
fi
76+
if [[ -n "$description" && "$description" != $DEFAULT ]]; then
77+
description_arg=" --description=\"$description\""
78+
fi
79+
if [[ "$republish" == "true" || $republish == true ]]; then
80+
republish_arg=" --republish"
81+
fi
82+
;;
83+
*)
3484
echo "format $format not yet implemented."
3585
exit 2
36-
fi
86+
;;
87+
esac
88+
89+
export CLOUDSMITH_API_KEY=$api_key
90+
91+
pip install cloudsmith-cli
92+
93+
request="cloudsmith push $action $format $owner/$repo$distro_path$version_arg$name_arg$summary_arg$description_arg$republish_arg $file"
94+
95+
echo $request
96+
97+
eval $request
579 KB
Binary file not shown.

test/fixture/raw-file.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test file for https://github.com/AutoModality/action-cloudsmith/actions

0 commit comments

Comments
 (0)