Skip to content

Commit 5e95275

Browse files
update(no-ticket): Update CircleCi docs to reflect new v2.0.0 release (#381)
* update(no-ticket): Update CircleCi docs to reflect new v2.0.0 release
1 parent 591eb03 commit 5e95275

File tree

4 files changed

+74
-131
lines changed

4 files changed

+74
-131
lines changed

src/content/authentication/openid-connect.mdx

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -184,69 +184,40 @@ pipelines:
184184
185185
#### CircleCI Example
186186
187+
Using the [Cloudsmith CircleCI orb](https://circleci.com/developer/orbs/orb/cloudsmith/cloudsmith), the `authenticate-with-oidc` command handles the token exchange automatically and exports the result as `CLOUDSMITH_API_KEY`:
188+
187189
```yaml
188190
version: 2.1
189191
190-
commands:
191-
make_oidc_request:
192-
steps:
193-
- run: |
194-
echo "Testing CircleCI OIDC."
195-
jwt=$(curl -X POST -H "Content-Type: application/json" -d "{\"oidc_token\":\"$CIRCLE_OIDC_TOKEN_V2\", \"service_slug\":\"{SERVICE_SLUG}"}" https://api.cloudsmith.io/openid/{ACCOUNT}/ | jq -r '.token')
196-
echo "OIDC token from Cloudsmith: $jwt"
192+
orbs:
193+
cloudsmith: cloudsmith/cloudsmith@2.0.0
197194
198-
jobs:
199-
build:
200-
docker:
201-
- image: cimg/base:current
202-
steps:
203-
- make_oidc_request
204-
205195
workflows:
206-
test-workflow:
196+
cloudsmith_oidc_publish:
207197
jobs:
208-
- build:
209-
context:
210-
- circle-oidc-test
211-
```
212-
213-
If successful, this will give a JWT token to be used as an API key.
214-
215-
If unsuccessful, you will receive an error message that is intentionally quite generic. This is by design so that we do not leak any information (such as whether OIDC is configured, which claim failed, whether a service account is associated with the provider, etc.).
216-
217-
Additionally, as of version `1.0.6` of the Cloudsmith orb, you can use the `authenticate-with-oidc` command to perform this step automatically.
218-
219-
```yaml
220-
version: 2.1
221-
222-
orbs:
223-
cloudsmith: cloudsmith/cloudsmith@1.0.6
224-
python: circleci/python@2.1.1
198+
- publish
225199
226200
jobs:
227201
publish:
228-
executor: python/default
202+
executor: cloudsmith/default
229203
steps:
230204
- checkout
231205
- cloudsmith/authenticate-with-oidc:
232-
organization: <your organization slug>
233-
service-account: <service account slug>
234-
- cloudsmith/ensure-api-key
206+
organization: my-org
207+
service-account: my-service-account
235208
- cloudsmith/install-cli
236209
- run:
237-
name: Build Python package
238-
command: python setup.py sdist
239-
- cloudsmith/publish:
240-
cloudsmith-repository: <organization_slug>/<repository_slug>
241-
package-path: dist/*.tar.gz
242-
package-format: python
243-
244-
workflows:
245-
cloudsmith_publish:
246-
jobs:
247-
- publish
210+
name: Build and publish Python package
211+
command: |
212+
pip install build
213+
python -m build --wheel
214+
cloudsmith push python my-org/my-repo dist/*.whl
248215
```
249216

217+
Ensure OIDC is enabled in your CircleCI project settings (Project Settings → Advanced → Enable OpenID Connect Tokens).
218+
219+
If successful, `CLOUDSMITH_API_KEY` will be set for all subsequent steps. If unsuccessful, you will receive an error message that is intentionally quite generic. This is by design so that we do not leak any information (such as whether OIDC is configured, which claim failed, whether a service account is associated with the provider, etc.).
220+
250221
#### GitHub Actions Example
251222

252223
```yaml
@@ -266,7 +237,7 @@ jobs:
266237
uses: actions/checkout@v4
267238
268239
- name: Authenticate with Cloudsmith via OIDC
269-
uses: cloudsmith-io/cloudsmith-cli-action@v1.0.3
240+
uses: cloudsmith-io/cloudsmith-cli-action@v2
270241
with:
271242
oidc-namespace: 'your-oidc-workspace' # Replace with your Cloudsmith workspace
272243
oidc-service-slug: 'your-service-account-slug' # Replace with the slug of your Cloudsmith service account

src/content/authentication/setup-cloudsmith-to-authenticate-with-oidc-in-github-actions.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ permissions:
7070
7171
```yaml
7272
- name: Authenticate with Cloudsmith via OIDC
73-
uses: cloudsmith-io/cloudsmith-cli-action@v1.0.3
73+
uses: cloudsmith-io/cloudsmith-cli-action@v2
7474
with:
7575
oidc-namespace: 'your-workspace' # Your Cloudsmith Workspace
7676
oidc-service-slug: 'your-service-account-slug' # Your Cloudsmith service account slug
@@ -104,7 +104,7 @@ jobs:
104104
# This step handles the entire OIDC authentication flow automatically.
105105
# It gets a token from GitHub and exchanges it for a Cloudsmith token.
106106
- name: Authenticate with Cloudsmith via OIDC
107-
uses: cloudsmith-io/cloudsmith-cli-action@v1.0.3
107+
uses: cloudsmith-io/cloudsmith-cli-action@v2
108108
with:
109109
oidc-namespace: 'WORKSPACE' # Replace with your Cloudsmith workspace
110110
oidc-service-slug: 'SERVICE_ACCOUNT_SLUG' # Replace with your service account slug

src/content/integrations/integrating-with-circleci.mdx

Lines changed: 49 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -37,129 +37,101 @@ And then include the orb:
3737
3838
```yaml
3939
orbs:
40-
cloudsmith: cloudsmith/cloudsmith@1.0.6
40+
cloudsmith: cloudsmith/cloudsmith@2.0.0
4141
```
4242
43-
Note that you can check the [releases page on github](https://github.com/cloudsmith-io/orb/releases) for our orb, [or the orb page](https://circleci.com/developer/orbs/orb/cloudsmith/cloudsmith) on CircleCI itself to find the latest version to use.
43+
Note that you can check the [releases page on GitHub](https://github.com/cloudsmith-io/orb/releases) for our orb, [or the orb page](https://circleci.com/developer/orbs/orb/cloudsmith/cloudsmith) on CircleCI itself to find the latest version to use.
4444
45-
You'll need to configure authentication credentials for the orb if you're not planning to use OIDC to authenticate with. To do so, you can add an environment variable named `CLOUDSMITH_API_KEY` within the CircleCI settings page for your project:
45+
### OIDC Authentication (recommended)
4646
47-
<BlockImage src={envVarimage} alt=""></BlockImage>
48-
49-
The orb (for now) requires that you have already built the package you wish to publish. Assuming you're publishing a Python library (though the same process applies to any package type), you'll want to run `setup.py sdist` as a step in your job:
47+
The recommended approach is to authenticate via OIDC, install the CLI, and invoke it directly in your run steps. This uses short-lived tokens and avoids storing long-lived API keys:
5048
5149
```yaml
52-
jobs:
53-
publish:
54-
executor: circleci/python:3.7
55-
steps:
56-
- checkout
57-
- run:
58-
name: Build Python package
59-
command: python setup.py sdist
50+
version: 2.1
51+
52+
orbs:
53+
cloudsmith: cloudsmith/cloudsmith@2.0.0
6054

6155
workflows:
62-
cloudsmith_publish:
56+
cloudsmith_oidc_publish:
6357
jobs:
6458
- publish
65-
```
66-
67-
Once built, we can use the orb to easily publish the package. The orb provides a number of commands to make this process simpler. We'll first ensure the Cloudsmith CLi is configured and installed, then after we've built the package, publish it:
6859

69-
```yaml
7060
jobs:
7161
publish:
72-
executor: circleci/python:3.7
62+
executor: cloudsmith/default
7363
steps:
7464
- checkout
75-
- cloudsmith/ensure-api-key
65+
- cloudsmith/authenticate-with-oidc:
66+
organization: my-org
67+
service-account: my-service-account
7668
- cloudsmith/install-cli
7769
- run:
78-
name: Build Python package
79-
command: python setup.py sdist
80-
- cloudsmith/publish:
81-
cloudsmith-repository: myorg/myrepo
82-
package-path: dist/package-*.tar.gz
83-
package-format: python
70+
name: Build and publish Python package
71+
command: |
72+
pip install build
73+
python -m build --wheel
74+
cloudsmith push python my-org/my-repo dist/*.whl
8475
```
8576
86-
If using OIDC for authentication, ensure you're using at least version `1.0.6` of the Cloudsmith orb and add an extra step calling `authenticate-with-oidc` e.g.
77+
The `authenticate-with-oidc` command exchanges a CircleCI OIDC token for a short-lived Cloudsmith API token, exported as `CLOUDSMITH_API_KEY`. Ensure OIDC is enabled in your CircleCI project settings (Project Settings → Advanced → Enable OpenID Connect Tokens).
8778

88-
```
89-
...
79+
If you only need the API token and don't need to install the CLI, you can use `authenticate-with-oidc` on its own:
80+
81+
```yaml
9082
jobs:
91-
publish:
92-
executor: circleci/python:3.7
83+
authenticate:
84+
executor: cloudsmith/default
9385
steps:
9486
- checkout
9587
- cloudsmith/authenticate-with-oidc:
96-
organization: <organization slug>
97-
service-account: <service account slug>
98-
- cloudsmith/ensure-api-key
99-
...
88+
organization: my-org
89+
service-account: my-service-account
90+
- run:
91+
name: Call Cloudsmith API
92+
command: |
93+
curl -H "X-Api-Key: $CLOUDSMITH_API_KEY" \
94+
https://api.cloudsmith.io/user/self/
10095
```
10196

102-
Putting this all together, we end up with a `.circleci/config.yaml` file which looks like so:
97+
### API Key Authentication
98+
99+
If OIDC is not available in your environment, you can authenticate with a static API key. Add an environment variable named `CLOUDSMITH_API_KEY` in your CircleCI project settings:
100+
101+
<BlockImage src={envVarimage} alt="Screenshot of CircleCI project environment variable settings showing CLOUDSMITH_API_KEY configured."></BlockImage>
102+
103+
Then use `ensure-api-key` to validate the key is set before running CLI commands:
103104

104105
```yaml
105106
version: 2.1
106107
107108
orbs:
108-
cloudsmith: cloudsmith/cloudsmith@1.0.4
109-
110-
jobs:
111-
publish:
112-
executor: circleci/python:3.7
113-
steps:
114-
- checkout
115-
- cloudsmith/ensure-api-key
116-
- cloudsmith/install-cli
117-
- run:
118-
name: Build Python package
119-
command: python setup.py sdist
120-
- cloudsmith/publish:
121-
cloudsmith-repository: myorg/myrepo
122-
package-path: dist/package-*.tar.gz
123-
package-format: python
109+
cloudsmith: cloudsmith/cloudsmith@2.0.0
124110
125111
workflows:
126112
cloudsmith_publish:
127113
jobs:
128114
- publish
129-
```
130-
131-
## Manual integration
132-
133-
Our official Orb provides simple integration for the majority of standard CI usecases, but we know that it won't fit every purpose. For additional flexibility users can mix and match commands provided by the orb and/or use the Cloudsmith CLI directly.
134-
135-
For example, to use the orb to install and configure the CLI, but then use the CLI directly to publish to Cloudsmith, your configuration might look like so:
136-
137-
```yaml
138-
version: 2.1
139-
140-
orbs:
141-
cloudsmith: cloudsmith/cloudsmith@1.0.4
142115
143116
jobs:
144117
publish:
145-
executor: circleci/python:3.7
118+
executor: cloudsmith/default
146119
steps:
147120
- checkout
148121
- cloudsmith/ensure-api-key
149122
- cloudsmith/install-cli
150123
- run:
151-
name: Build Python package
152-
command: python setup.py bdist_wheel
153-
- run:
154-
name: Publish Python package
155-
command: cloudsmith push python myorg/myrepo dist/my-package-0.1.0.whl
156-
157-
workflows:
158-
cloudsmith_publish:
159-
jobs:
160-
- publish
124+
name: Build and publish Python package
125+
command: |
126+
pip install build
127+
python -m build --wheel
128+
cloudsmith push python my-org/my-repo dist/*.whl
161129
```
162130

131+
<Note variant="note">
132+
The `cloudsmith/default` executor uses the `cimg/python` convenience image. If you need a different base image, you can specify your own executor and the orb commands will work in any environment that has the required dependencies (Python, curl, jq).
133+
</Note>
134+
163135
## Support
164136

165137
As always, if you have any questions about integration or would like some general advice, please [contact support](https://cloudsmith.com/company/contact-us).

src/content/integrations/integrating-with-github-actions.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ permissions:
3131
steps:
3232
- uses: actions/checkout@v4
3333
- name: Authenticate & Install Cloudsmith CLI (OIDC)
34-
uses: cloudsmith-io/cloudsmith-cli-action@v1
34+
uses: cloudsmith-io/cloudsmith-cli-action@v2
3535
with:
3636
oidc-namespace: your-oidc-namespace
3737
oidc-service-slug: your-service-account-slug
@@ -47,7 +47,7 @@ Use when you only need the token for API calls:
4747

4848
```yaml
4949
steps:
50-
- uses: cloudsmith-io/cloudsmith-cli-action@v1
50+
- uses: cloudsmith-io/cloudsmith-cli-action@v2
5151
with:
5252
oidc-namespace: your-oidc-namespace
5353
oidc-service-slug: your-service-account-slug
@@ -64,7 +64,7 @@ Use for quick tests or legacy setups when OIDC isn’t available.
6464
steps:
6565
- uses: actions/checkout@v4
6666
- name: Install Cloudsmith CLI (API Key)
67-
uses: cloudsmith-io/cloudsmith-cli-action@v1
67+
uses: cloudsmith-io/cloudsmith-cli-action@v2
6868
with:
6969
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
7070
```
@@ -113,7 +113,7 @@ jobs:
113113
python -m pip install build
114114
python -m build
115115
- name: Install Cloudsmith CLI (OIDC)
116-
uses: cloudsmith-io/cloudsmith-cli-action@v1
116+
uses: cloudsmith-io/cloudsmith-cli-action@v2
117117
with:
118118
oidc-namespace: your-oidc-namespace
119119
oidc-service-slug: your-service-account-slug

0 commit comments

Comments
 (0)