This repository was archived by the owner on Oct 23, 2025. It is now read-only.
forked from AutoModality/action-cloudsmith
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathaction.yml
More file actions
211 lines (204 loc) · 7.64 KB
/
action.yml
File metadata and controls
211 lines (204 loc) · 7.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# action.yml
name: "Cloudsmith Push"
description: "Push packages easily to your repositories"
author: "Cloudsmith Ltd"
branding:
icon: "box"
color: "blue"
inputs:
api-version:
description: "All: If provided, a specific version of the Cloudsmith API is installed/used."
required: false
default: none
cli-version:
description: "All: If provided, a specific version of the Cloudsmith CLI is installed/used."
required: false
default: none
skip-install-cli:
description: "All: If true, the Cloudsmith CLI will not be installed."
required: false
default: "false"
api-key:
description: "All: The Cloudsmith API Key (can be provided via GitHub secrets), or set as the CLOUDSMITH_API_KEY environment variable."
required: false
default: none
command:
description: "All: The desired action with cloudsmith (push, list, etc)."
required: false
default: "push"
format:
description: "All: The format (deb, npm, maven, etc) for the package."
required: true
default: none
owner:
description: "All: The user/organization that owns the repository, where the package will be pushed to."
required: true
default: none
repo:
description: "All: The repository slug (textual identifier), where the package will be pushed to."
required: true
default: none
file:
description: "All: The primary file for the package (e.g. my-package.deb)."
required: true
default: none
republish:
description: "All: If true, the uploaded package will overwrite any others with the same attributes."
required: false
default: "false"
wait-interval:
description: "All: The time in seconds to between checking synchronization."
required: false
default: none
no-wait-for-sync:
description: "All: If true, don't wait for package synchronization to complete before exiting (faster uploads)."
required: false
default: "false"
extra:
description: "All: Extra arguments passed to the Cloudsmith CLI, in-verbatim."
required: false
default: none
distro:
description: "Alpine/Debian/RedHat: The distribution for the package (e.g. ubuntu)"
required: false
default: none
release:
description: "Alpine/Debian/RedHat: The named version of the release for the package (e.g. xenial)"
required: false
default: none
name:
description: "Raw: The name for the package."
required: false
default: none
scope:
description: "Swift: A scope provides a namespace for related packages within the package registry."
required: false
default: none
summary:
description: "Raw: The one-liner synopsis for the package."
required: false
default: none
description:
description: "Raw: The longer textual description for the package."
required: false
default: none
version:
description: "Raw: The version for the package."
required: false
default: none
pom-file:
description: "Maven: Relevant POM file for the maven package."
required: false
default: none
symbols-file:
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
use-executable:
description: "All: If true, the pre-packaged executable will be used instead of Python install and pip install."
required: false
default: "true"
runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
# Upgrade Bash on macOS - this is required as the default version of Bash on macOS runner is 3.9
- name: Upgrade Bash on macOS
if: runner.os == 'macOS'
run: |
brew install bash
shell: bash
- name: Download Cloudsmith CLI zipapp
if: inputs.use-executable == 'true'
shell: bash
run: |
python << EOF
import os
import urllib.request
import sys
BASE_URL = 'https://dl.cloudsmith.io/public'
NAMESPACE = 'cloudsmith'
REPO_NAME = 'cli-zipapp'
# Use GITHUB_WORKSPACE to ensure compatibility across all operating systems
executable_dir = os.path.join(os.getenv('GITHUB_WORKSPACE'), 'bin')
os.makedirs(executable_dir, exist_ok=True)
EXECUTABLE_PATH = os.path.join(executable_dir, 'cloudsmith')
def download_file(url, path):
with urllib.request.urlopen(url) as response, open(path, 'wb') as out_file:
out_file.write(response.read())
os.chmod(path, os.stat(path).st_mode | 0o755)
def download_latest_release():
try:
download_url = f"{BASE_URL}/{NAMESPACE}/{REPO_NAME}/raw/names/cloudsmith-cli/versions/latest/cloudsmith.pyz"
download_file(download_url, EXECUTABLE_PATH)
print(f"Downloaded latest Cloudsmith CLI to {EXECUTABLE_PATH}")
except Exception as error:
print(f"Failed to download the latest release: {str(error)}")
sys.exit(1)
def download_specific_release(version):
try:
download_url = f"{BASE_URL}/{NAMESPACE}/{REPO_NAME}/raw/names/cloudsmith-cli/versions/{version}/cloudsmith.pyz"
download_file(download_url, EXECUTABLE_PATH)
print(f"Downloaded Cloudsmith CLI version {version} to {EXECUTABLE_PATH}")
except Exception as error:
print(f"Failed to download the specific release: {str(error)}")
sys.exit(1)
cli_version = '${{ inputs.cli-version }}'
if cli_version and cli_version.lower() != 'none':
download_specific_release(cli_version)
else:
download_latest_release()
# Add the directory to GITHUB_PATH
with open(os.environ['GITHUB_PATH'], 'a') as github_path:
github_path.write(f"{executable_dir}\n")
EOF
- name: Install cloudsmith-cli and cloudsmith-api ...
if: inputs.skip-install-cli == 'false' && inputs.use-executable == 'false'
shell: bash
run: |
pip install \
cloudsmith-api${{ inputs.api-version != 'none' && format('=={0}', inputs.api-version) || ''}} \
cloudsmith-cli${{ inputs.cli-version != 'none' && format('=={0}', inputs.cli-version) || ''}} \
- name: Run Entrypoint
shell: bash
env:
USE_EXECUTABLE: ${{ inputs.use-executable }}
run: |
if [ -f "${{ github.action_path }}/entrypoint.sh" ]; then
ENTRYPOINT_PATH="${{ github.action_path }}/entrypoint.sh"
echo "Using entrypoint.sh from ${{ github.action_path }}"
elif [ -f "${GITHUB_ACTION_PATH}/entrypoint.sh" ]; then
ENTRYPOINT_PATH="${GITHUB_ACTION_PATH}/entrypoint.sh"
echo "Using entrypoint.sh from ${GITHUB_ACTION_PATH}"
else
echo "entrypoint.sh not found in either ${{ github.action_path }} or ${GITHUB_ACTION_PATH}"
exit 1
fi
bash $ENTRYPOINT_PATH \
-k ${{ inputs.api-key }} \
-K ${{ inputs.command }} \
-f ${{ inputs.format }} \
-o ${{ inputs.owner }} \
-r ${{ inputs.repo }} \
-F ${{ inputs.file }} \
-P ${{ inputs.republish }} \
-w ${{ inputs.wait-interval }} \
-W ${{ inputs.no-wait-for-sync }} \
-d ${{ inputs.distro }} \
-R ${{ inputs.release }} \
-n ${{ inputs.name }} \
-N ${{ inputs.symbols-file }} \
-S ${{ inputs.scope }} \
-s "${{ inputs.summary }}" \
-t "${{ inputs.tags }}" \
-D "${{ inputs.description }}" \
-V ${{ inputs.version }} \
-p ${{ inputs.pom-file }} \
-- ${{ inputs.extra }}