Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Cloudsmith CLI Setup Action

Test statusGitHub MarketplaceLatest releaseLicense

Install the standalone Cloudsmith CLI, add it to PATH, and configure authentication for the rest of a GitHub Actions job. The action does not require Python or Node.js on the runner.

Quick start · Configuration · Outputs · Migration guide · Contributing

At a glance

CapabilitySupport
AuthenticationOpenID Connect (OIDC) or API key
RunnersLinux, macOS, and Windows
Architecturesx86-64, plus Linux and macOS ARM64
Runtime dependenciesNo Python or Node.js; export-auth-token additionally uses jq on Linux and macOS
Version selectionLatest release or a specific CLI version

Quick start

Authenticate with OIDC

OIDC is the recommended option for CI/CD because it uses short-lived credentials instead of a stored API key. Before using this example, configure a Cloudsmith service account and an OIDC provider by following the Cloudsmith OIDC documentation.

Important

The workflow or job must grant id-token: write. Without this permission, GitHub cannot issue the OIDC token used to authenticate with Cloudsmith.

permissions:
id-token: writecontents: readsteps:
- uses: cloudsmith-io/cloudsmith-cli-action@v3with:
oidc-namespace: "YOUR-NAMESPACE"oidc-service-slug: "YOUR-SERVICE-ACCOUNT"
- run: cloudsmith whoami

Authenticate with an API key

Store the API key as a GitHub Actions secret and pass it to the action. For automated workflows, use a Cloudsmith service account rather than a personal API key.

steps:
- uses: cloudsmith-io/cloudsmith-cli-action@v3with:
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
- run: cloudsmith whoami

Personal API keys are available from Cloudsmith API settings.

Authentication

Choose one of the following authentication methods:

MethodInputsCredential handlingBest suited to
OIDCoidc-namespace and oidc-service-slugThe CLI exchanges a GitHub OIDC token on its first authenticated commandCI/CD workflows
API keyapi-keyThe action masks and exports the key for later stepsWorkflows that cannot use OIDC

With OIDC, the action exports the service account context needed by the CLI. The Cloudsmith access token is requested only when the CLI first needs to authenticate and is not exposed by default. If a later step needs the effective credential itself — for example to configure npm, pip, or docker login against a Cloudsmith registry — set export-auth-token: "true". The action runs cloudsmith credential-helper generic once, validates its versioned response, masks and exports its password as CLOUDSMITH_API_KEY, exports its package-manager username (token) as CLOUDSMITH_USERNAME, and sets the compatibility oidc-token output. This requires Cloudsmith CLI 1.21.0 or later. On a self-hosted Linux or macOS runner, jq must also be available on PATH.

- uses: cloudsmith-io/cloudsmith-cli-action@v3with:
oidc-namespace: "YOUR-NAMESPACE"oidc-service-slug: "YOUR-SERVICE-ACCOUNT"export-auth-token: "true"
- name: Authenticate npm against Cloudsmithrun: npm config set //npm.cloudsmith.io/YOUR-NAMESPACE/YOUR-REPOSITORY/:_authToken "$CLOUDSMITH_API_KEY"
flowchart LR
A[Setup action] -->|Installs CLI and exports OIDC settings| B[Cloudsmith CLI command]
B -->|Requests identity token| C[GitHub OIDC]
C -->|Exchanges identity| D[Cloudsmith]
Loading

Set verify-auth: "true" to run cloudsmith whoami during setup and fail early if authentication is not configured correctly.

Configuration

An authentication method is required: provide api-key, or provide both oidc-namespace and oidc-service-slug.

Installation inputs

InputDescriptionRequiredDefault
cli-versionCLI version to install, such as 1.20.0Nolatest
install-directoryRoot directory for versioned CLI installationsNoRUNNER_TEMP/cloudsmith-cli
verify-authRun cloudsmith whoami after setupNofalse

Authentication inputs

InputDescriptionRequiredDefault
api-keyCloudsmith API keyFor API-key authentication
oidc-namespaceCloudsmith organisation or namespaceFor OIDC authentication
oidc-service-slugCloudsmith service account slugFor OIDC authentication
oidc-audienceAudience requested for the GitHub OIDC tokenNohttps://github.com/{repository-owner}
export-auth-tokenResolve the effective credential through cloudsmith credential-helper generic, export its password as CLOUDSMITH_API_KEY, and export its username as CLOUDSMITH_USERNAME (requires CLI 1.21.0+)Nofalse
oidc-auth-onlyDeprecated alias for export-auth-token; when true, it enables the same credential-helper flowNofalse

API configuration inputs

InputDescriptionRequiredDefault
api-hostCloudsmith API host overrideNo
api-proxyProxy used to reach the Cloudsmith APINo
api-ssl-verifyWhether to verify API SSL certificates: true or falseNoCLI default
api-user-agentUser agent override for Cloudsmith API requestsNo

Outputs

OutputDescription
cli-versionResolved Cloudsmith CLI version
targetResolved binary target, such as linux-x86_64-gnu
cli-pathAbsolute path to the Cloudsmith CLI executable
bin-directoryDirectory added to PATH for later steps
oidc-tokenEffective authentication token resolved when export-auth-token or its oidc-auth-only alias is enabled (masked in logs; retained for compatibility)

Access an output through the action step's id:

steps:
- name: Set up Cloudsmith CLIid: cloudsmithuses: cloudsmith-io/cloudsmith-cli-action@v3with:
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
- run: echo "Installed Cloudsmith CLI ${{ steps.cloudsmith.outputs.cli-version }}"

Environment variables

The action configures later steps by exporting the environment variables that correspond to the supplied inputs.

InputEnvironment variable
api-keyCLOUDSMITH_API_KEY
oidc-namespaceCLOUDSMITH_ORG
oidc-service-slugCLOUDSMITH_SERVICE_SLUG
oidc-audienceCLOUDSMITH_OIDC_AUDIENCE
api-hostCLOUDSMITH_API_HOST
api-proxyCLOUDSMITH_API_PROXY
api-user-agentCLOUDSMITH_API_USER_AGENT
api-ssl-verifyCLOUDSMITH_WITHOUT_API_SSL_VERIFY
export-auth-tokenCLOUDSMITH_API_KEY (effective credential) and CLOUDSMITH_USERNAME (token)

Publish a package

The following workflow installs the CLI with OIDC authentication and publishes a Python package:

name: Publish Python packageon:
push:
branches:
- mainpermissions:
id-token: writecontents: readjobs:
publish:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- name: Set up Cloudsmith CLIuses: cloudsmith-io/cloudsmith-cli-action@v3with:
oidc-namespace: "YOUR-NAMESPACE"oidc-service-slug: "YOUR-SERVICE-ACCOUNT"
- name: Publish packagerun: cloudsmith push python YOUR-NAMESPACE/YOUR-REPOSITORY dist/*.tar.gz

See Supported Formats for the upload command and options for each package format.

Migrating from v2

Version 3 installs the standalone CLI instead of the Python package. Existing workflows that use api-key, or the oidc-namespace and oidc-service-slug pair, can keep those authentication inputs and the existing default OIDC audience.

Note

OIDC authentication is now lazy: the CLI exchanges the token on its first authenticated command. Use verify-auth: "true" if the setup step should validate credentials immediately.

View removed inputs, outputs, and migration steps

Removed and deprecated v2 inputs

v2 inputMigration
pip-installRemove it. Version 3 always installs the standalone binary.
oidc-auth-onlyDeprecated alias for export-auth-token; when true, it enables the same cloudsmith credential-helper generic flow.
oidc-auth-retryRemove it. The CLI manages the token exchange and retries.
oidc-token-validateReplace it with verify-auth: "true".
executable-pathUse install-directory to control the installation root. Use the cli-path or bin-directory output for the resolved location.

oidc-token output

By default the action no longer receives or exposes the Cloudsmith access token; authenticate subsequent requests with the CLI. Set export-auth-token: "true" to resolve the effective credential through cloudsmith credential-helper generic, export it as CLOUDSMITH_API_KEY, and restore the oidc-token output. oidc-auth-only: "true" is a deprecated alias that enables the same behavior. Requires Cloudsmith CLI 1.21.0 or later.

API configuration

The action no longer writes a configuration file. Values supplied through api-host, api-proxy, api-ssl-verify, and api-user-agent are exported as CLOUDSMITH_* environment variables for later steps.

Contributing

See the contribution guide for the repository layout, local validation commands, and pull request process.

Support

For help, open a GitHub issue or contact Cloudsmith Support.

License

This project is available under the MIT License.

About

This GitHub repository contains a GitHub Action for installing and pre-authenticating the Cloudsmith CLI using OpenID Connect (OIDC). It simplifies CI/CD workflows by automating the setup and authentication process, enhancing security, and ensuring seamless integration with Cloudsmith's universal package management solution.

Resources

Stars

4 stars

Watchers

13 watching

Forks

Releases

Used by

Contributors

Languages