Skip to content

Commit c7053b4

Browse files
Add OIDC orb (#28)
Updated set_env_vars_for_pip to use cloudsmith-oidc orb for auth Updated set_env_vars_for_twine to use cloudsmith-oidc orb for auth Updated upload_python_package to use cloudsmith-oidc orb for auth Removed command authenticate_with_oidc Updated examples and tests --------- Co-authored-by: robertboulton <[email protected]>
1 parent a5f686a commit c7053b4

16 files changed

+41
-157
lines changed

.circleci/test-deploy.yml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,6 @@ release-filters: &release-filters
2020
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
2121

2222
jobs:
23-
# Create jobs to test the commands of your orbs.
24-
# You may want to add additional validation steps to ensure the commands are working as expected.
25-
26-
test-authenticate_with_oidc:
27-
docker:
28-
- image: cimg/base:current
29-
resource_class: small
30-
steps:
31-
- checkout
32-
- cloudsmith-circleci/authenticate_with_oidc:
33-
service_account: "circleci-orb-testing"
34-
- run:
35-
name: Assert environment variables have been set
36-
command: |
37-
if [ $CLOUDSMITH_ORGANISATION != "financial-times" ]
38-
then
39-
echo "Test failed: CLOUDSMITH_ORGANISATION has not been set correctly."
40-
exit 1
41-
fi
42-
if [ $CLOUDSMITH_SERVICE_ACCOUNT != "circleci-orb-testing" ]
43-
then
44-
echo "Test failed: CLOUDSMITH_SERVICE_ACCOUNT has not been set."
45-
exit 1
46-
fi
47-
if [ -z $CLOUDSMITH_OIDC_TOKEN ]
48-
then
49-
echo "Test failed: CLOUDSMITH_OIDC_TOKEN has not been set."
50-
exit 1
51-
fi
52-
echo "All tests passed."
5323

5424
test-set_env_vars_for_pip:
5525
docker:
@@ -59,7 +29,6 @@ jobs:
5929
- checkout
6030
- cloudsmith-circleci/set_env_vars_for_pip:
6131
repository: "circleci-orb-testing"
62-
service_account: "circleci-orb-testing"
6332
- run:
6433
name: Assert environment variables have been set
6534
command: |
@@ -82,7 +51,6 @@ jobs:
8251
- checkout
8352
- cloudsmith-circleci/set_env_vars_for_pip:
8453
repository: "circleci-orb-testing"
85-
service_account: "circleci-orb-testing"
8654
- run: python -m pip install simplepkg==0.0.1 --index-url "$CLOUDSMITH_PIP_INDEX_URL"
8755

8856
test-pip_install_requirements_example:
@@ -93,7 +61,6 @@ jobs:
9361
- run: echo "simplepkg==0.0.1" > requirements.txt
9462
- cloudsmith-circleci/set_env_vars_for_pip:
9563
repository: "circleci-orb-testing"
96-
service_account: "circleci-orb-testing"
9764
- run: python -m pip install -r requirements.txt --index-url "$CLOUDSMITH_PIP_INDEX_URL"
9865

9966
test-configure_pip_example:
@@ -104,7 +71,6 @@ jobs:
10471
- run: echo "simplepkg==0.0.1" > requirements.txt
10572
- cloudsmith-circleci/set_env_vars_for_pip:
10673
repository: "circleci-orb-testing"
107-
service_account: "circleci-orb-testing"
10874
- run: python -m pip config set global.index-url "$CLOUDSMITH_PIP_INDEX_URL"
10975
- run: python -m pip install -r requirements.txt
11076

@@ -116,7 +82,6 @@ jobs:
11682
- checkout
11783
- cloudsmith-circleci/set_env_vars_for_twine:
11884
repository: "circleci-orb-testing"
119-
service_account: "circleci-orb-testing"
12085
- run:
12186
name: Assert environment variables have been set
12287
command: |
@@ -156,7 +121,6 @@ jobs:
156121
python -m pip install twine --upgrade --user
157122
- cloudsmith-circleci/set_env_vars_for_twine:
158123
repository: "circleci-orb-testing"
159-
service_account: "circleci-orb-testing"
160124
- run:
161125
name: twine upload package to Cloudsmith
162126
command: |
@@ -182,17 +146,13 @@ jobs:
182146
working_directory: .circleci/simplepkg-py
183147
- cloudsmith-circleci/upload_python_package:
184148
repository: "circleci-orb-testing"
185-
service_account: "circleci-orb-testing"
186149
dist_dir: .circleci/simplepkg-py/dist
187150

188151
workflows:
189152
test-deploy:
190153
jobs:
191154
# Make sure to include "filters: *filters" in every test job you want to run as part of your deployment.
192155
# Test your orb's commands in a custom job and test your orb's jobs directly as a part of this workflow.
193-
- test-authenticate_with_oidc:
194-
context: circleci-orb-publishing
195-
filters: *filters
196156
- test-set_env_vars_for_pip:
197157
context: circleci-orb-publishing
198158
filters: *filters
@@ -226,7 +186,6 @@ workflows:
226186
# Ensure this job requires all test jobs and the pack job.
227187
requires:
228188
- orb-tools/pack
229-
- test-authenticate_with_oidc
230189
- test-set_env_vars_for_pip
231190
- test-pip_install_package_example
232191
- test-pip_install_requirements_example

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ A CircleCI orb to assist with downloading from and publishing packages to Clouds
88

99
## Getting started
1010

11-
The orb commands need the following parameters:
11+
The orb commands require the following environment variables to be set:
1212

13-
* `repository` : The identity/slug of the Cloudsmith repository
13+
* `CLOUDSMITH_ORGANISATION` : The identity/slug of the Cloudsmith organisation to use when authenticating with OIDC. Defaults to "financial-times" if not set.
14+
* `CLOUDSMITH_SERVICE_ACCOUNT` : The identity/slug of the Cloudsmith service account to use when authenticating with OIDC.
1415

15-
* `service_account` : The identity/slug of the Cloudsmith service account to use when authenticating with OIDC
16+
These are used to authenticate with Cloudsmith using OIDC and can be found in the [Cloudsmith UI](https://cloudsmith.io/).
1617

17-
This can be found in the [Cloudsmith UI](https://cloudsmith.io/orgs/financial-times/).
18-
19-
The orb provides commands to set environment variables for various package managment tools (e.g. pip).
18+
The orb provides commands to set environment variables for various package managment tools (e.g. pip) and to publish
19+
packages using the Cloudsmith CLI.
2020

2121
---
2222

src/@orb.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
version: 2.1
22

3-
description: >
4-
Install packages from and publish packages to Cloudsmith using short-lived OIDC credentials
3+
orbs:
4+
cloudsmith-oidc: ft-circleci-orbs/[email protected]
5+
6+
description: |
7+
Install packages from and publish packages to Cloudsmith using short-lived OIDC credentials.
8+
Note, all commands require the following environment variables to be set:
9+
- CLOUDSMITH_ORGANISATION : The identity/slug of the Cloudsmith organisation to use when authenticating with OIDC. Defaults to "financial-times" if not set.
10+
- CLOUDSMITH_SERVICE_ACCOUNT : The identity/slug of the Cloudsmith service account to use when authenticating with OIDC.
11+
These are used to authenticate with Cloudsmith using OIDC and can be found in the Cloudsmith UI - https://cloudsmith.io/.
12+
513
display:
614
home_url: "https://github.com/ft-circleci-orbs/cloudsmith-circleci-orb"
715
source_url: "https://github.com/ft-circleci-orbs/cloudsmith-circleci-orb"

src/commands/authenticate_with_oidc.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/commands/set_env_vars_for_pip.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@ parameters:
66
repository:
77
description: The identity/slug of the Cloudsmith repository
88
type: string
9-
service_account:
10-
description: The identity/slug of the Cloudsmith service account to use when authenticating with OIDC
11-
type: string
129
steps:
13-
- authenticate_with_oidc:
14-
service_account: <<parameters.service_account>>
15-
- run:
16-
name: Cloudsmith - Configure domains
17-
command: <<include(scripts/configure_cloudsmith_domains.sh)>>
1810
- run:
19-
name: Cloudsmith - Configure repository
20-
command: |
21-
echo "export CLOUDSMITH_REPOSITORY=\"<<parameters.repository>>\"" >> $BASH_ENV
22-
echo "CLOUDSMITH_REPOSITORY=<<parameters.repository>>"
11+
name: Cloudsmith - Configure defaults
12+
command: <<include(scripts/configure_cloudsmith_defaults.sh)>>
13+
- cloudsmith-oidc/authenticate_with_oidc
2314
- run:
2415
name: Cloudsmith - Set CLOUDSMITH_PIP_INDEX_URL environment variable
2516
command: <<include(scripts/set_env_vars_for_pip.sh)>>
17+
environment:
18+
CLOUDSMITH_REPOSITORY: <<parameters.repository>>

src/commands/set_env_vars_for_twine.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@ parameters:
66
repository:
77
description: The identity/slug of the Cloudsmith repository
88
type: string
9-
service_account:
10-
description: The identity/slug of the Cloudsmith service account to use when authenticating with OIDC
11-
type: string
129
steps:
13-
- authenticate_with_oidc:
14-
service_account: <<parameters.service_account>>
15-
- run:
16-
name: Cloudsmith - Configure domains
17-
command: <<include(scripts/configure_cloudsmith_domains.sh)>>
1810
- run:
19-
name: Cloudsmith - Configure repository
20-
command: |
21-
echo "export CLOUDSMITH_REPOSITORY=\"<<parameters.repository>>\"" >> $BASH_ENV
22-
echo "CLOUDSMITH_REPOSITORY=<<parameters.repository>>"
11+
name: Cloudsmith - Configure defaults
12+
command: <<include(scripts/configure_cloudsmith_defaults.sh)>>
13+
- cloudsmith-oidc/authenticate_with_oidc
2314
- run:
2415
name: Cloudsmith - Set CLOUDSMITH_TWINE environment variables
2516
command: <<include(scripts/set_env_vars_for_twine.sh)>>
17+
environment:
18+
CLOUDSMITH_REPOSITORY: <<parameters.repository>>

src/commands/upload_python_package.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ parameters:
55
repository:
66
description: The identity/slug of the Cloudsmith repository
77
type: string
8-
service_account:
9-
description: The identity/slug of the Cloudsmith service account to use when authenticating
10-
type: string
118
dist_dir:
129
description: The distribution directory where package source distribution and wheel files are located
1310
type: string
1411
default: "dist"
1512
steps:
13+
- run:
14+
name: Cloudsmith - Configure defaults
15+
command: <<include(scripts/configure_cloudsmith_defaults.sh)>>
16+
- cloudsmith-oidc/authenticate_with_oidc
1617
- run:
1718
name: Cloudsmith - Install CLI
1819
command: |
@@ -26,16 +27,10 @@ steps:
2627
echo "Cloudsmith CLI installed OK."
2728
2829
cloudsmith --version
29-
- authenticate_with_oidc:
30-
service_account: <<parameters.service_account>>
31-
- run:
32-
name: Cloudsmith - Configure repository and dist_dir
33-
command: |
34-
echo "export CLOUDSMITH_REPOSITORY=\"<<parameters.repository>>\"" >> $BASH_ENV
35-
echo "CLOUDSMITH_REPOSITORY=<<parameters.repository>>"
36-
37-
echo "export DIST_DIR=\"<<parameters.dist_dir>>\"" >> $BASH_ENV
38-
echo "DIST_DIR=<<parameters.dist_dir>>"
3930
- run:
4031
name: Cloudsmith - Upload python package file(s)
4132
command: <<include(scripts/upload_python_package.sh)>>
33+
environment:
34+
CLOUDSMITH_REPOSITORY: <<parameters.repository>>
35+
DIST_DIR: <<parameters.dist_dir>>
36+

src/examples/configure_pip_index_url.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ usage:
1313
- run: python -m ensurepip --upgrade
1414
- ft-cloudsmith/set_env_vars_for_pip:
1515
repository: "your-repository-id"
16-
service_account: "your-service-account-id"
1716
- run: python -m pip config set global.index-url "$CLOUDSMITH_PIP_INDEX_URL"
1817
- run: python -m pip install -r requirements.txt
1918
workflows:

src/examples/pip_install_package.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ usage:
1313
- run: python -m ensurepip --upgrade
1414
- ft-cloudsmith/set_env_vars_for_pip:
1515
repository: "your-repository-id"
16-
service_account: "your-service-account-id"
1716
- run: python -m pip install your-package==0.0.0 --index-url "$CLOUDSMITH_PIP_INDEX_URL"
1817
workflows:
1918
main:

src/examples/pip_install_requirements.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ usage:
1313
- run: python -m ensurepip --upgrade
1414
- ft-cloudsmith/set_env_vars_for_pip:
1515
repository: "your-repository-id"
16-
service_account: "your-service-account-id"
1716
- run: python -m pip install -r requirements.txt --index-url "$CLOUDSMITH_PIP_INDEX_URL"
1817
workflows:
1918
main:

0 commit comments

Comments
 (0)