Integrations
Integrating Travis-CI
How to integrate Travis-CI with Cloudsmith.
Travis CI is a cloud-based continuous integration (CI) and continuous delivery platform that enables open source and private projects on GitHub and other providers to automate the build, test, and deployment processes of your software.
Using the Cloudsmith CLI
Here you can find a template to start building your own. This Travis pipeline example uses a Python build environment on Ubuntu jammy to:
- Build your Python project into a wheel (.whl) file for distribution with
python -m build, and store it in thedist/directory. - Install the standalone Cloudsmith CLI using the install script. The CLI is a self-contained binary, so no extra runtime is required. The install script prints the installation result as
key=valuelines; thebefore_deploycommands parsebin_dirfrom that output and add it toPATH. - And finally use the Cloudsmith CLI to upload a Python package to your
WORKSPACE/REPOSITORYonly when new changes are pushed to themainbranch in the associated GitHub repository.
Before running the pipeline, provide Cloudsmith credentials: Add a protected CLOUDSMITH_API_KEY environment variable in your Travis repository settings, or set the CLOUDSMITH_OIDC_TOKEN, CLOUDSMITH_ORG, and CLOUDSMITH_SERVICE_SLUG OpenID Connect (OIDC) variables. For more information, see OpenID Connect.
yaml
language: python
python: "3.12"
dist: jammy
install:
- pip install build
script:
- python -m build --wheel
before_deploy:
- install_output="$(curl -fsSL https://install.cloudsmith.com/raw/versions/latest/cli.sh | sh -s -- --version 1.20.1)"
- bin_dir="$(printf '%s\n' "$install_output" | sed -n 's/^bin_dir=//p')"
- export PATH="$bin_dir:$PATH"
deploy:
provider: script
script: cloudsmith push python --republish WORKSPACE/REPOSITORY dist/cloudsmith_python_example-100-py2.py3-none-any.whl
on:
branch: main