sdkcraft (CLI)

The sdkcraft utility exposes the following commands, each with its own set of options, and also has a number of global flags:

-h, --help

Print the help message for the command.

sdkcraft clean

Remove a part’s assets

Usage

$ sdkcraft clean [--destructive-mode] [--platform name] [part-name ...]

Description

Clean up artifacts belonging to parts. If no parts are specified, remove the packing environment.

Flags

--destructive-mode

Build in the current host Default: False

--platform

Platform to clean

Examples

Clean build artifacts:

$ sdkcraft clean

Clean specific parts:

$ sdkcraft clean my-part

Clean in destructive mode:

$ sdkcraft clean --destructive-mode

sdkcraft pull

Download or retrieve artifacts defined for a part

Usage

$ sdkcraft pull [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                  [--platform name | --build-for arch]
                  [part-name ...]

Description

Download or retrieve artifacts defined for a part. If part names are specified only those parts will be pulled, otherwise all parts will be pulled.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft build

Build artifacts defined for a part

Usage

$ sdkcraft build [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                   [--platform name | --build-for arch]
                   [part-name ...]

Description

Build artifacts defined for a part. If part names are specified only those parts will be built, otherwise all parts will be built.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft stage

Stage built artifacts into a common staging area

Usage

$ sdkcraft stage [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                   [--platform name | --build-for arch]
                   [part-name ...]

Description

Stage built artifacts into a common staging area. If part names are specified only those parts will be staged. The default is to stage all parts.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft prime

Prime artifacts defined for a part

Usage

$ sdkcraft prime [--destructive-mode | --use-lxd] [--shell | --shell-after] [--debug]
                   [--platform name | --build-for arch]
                   [part-name ...]

Description

Prepare the final payload to be packed, performing additional processing and adding metadata files. If part names are specified only those parts will be primed. The default is to prime all parts.

Flags

--destructive-mode

Build in the current host Default: False

--use-lxd

Build in a LXD container. Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

sdkcraft pack

Create the final artifact

Usage

$ sdkcraft pack [--destructive-mode] [--shell | --shell-after] [--debug]
                  [--platform name | --build-for arch] [--output OUTPUT]

Description

Process parts and create the final artifact.

Flags

--destructive-mode

Build in the current host Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

--output

Output directory for created packages. Default: .

Examples

Pack the project:

$ sdkcraft pack

Pack to a specific output directory:

$ sdkcraft pack --output dist/

sdkcraft test

Run SDK tests

Usage

$ sdkcraft test [--destructive-mode] [--shell | --shell-after] [--debug] [--platform name]
                  [--list]
                  [test_expressions ...]

Description

Tests are defined and run using spread (https://github.com/canonical/spread).

Compared to running spread manually, sdkcraft test also: - Packs SDKs for all platforms matching the current architecture. - Copies the packed SDKs into the test environment using sdkcraft try. - Installs Workshop in the test environment. - Skips spread variants for bases that weren’t packed.

Flags

--destructive-mode

Build in the current host Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--list

Just show list of jobs that would run. Default: False

Examples

Test the project:

$ sdkcraft test

List the jobs that would run:

$ sdkcraft test --list

Run a specific test suite:

$ sdkcraft test my-suite/

sdkcraft try

Try SDKs before publishing

Usage

$ sdkcraft try [--destructive-mode] [--shell | --shell-after] [--debug]
                 [--platform name | --build-for arch] [--output OUTPUT]
                 [SDKs ...]

Description

Pack the SDK and copy it to the Workshop try area.

Flags

--destructive-mode

Build in the current host Default: False

--shell

Shell into the environment in lieu of the step to run. Default: False

--shell-after

Shell into the environment after the step has run. Default: False

--debug

Shell into the environment if the build fails. Default: False

--platform

Set platform to build for

--build-for

Set architecture to build for

--output

Output directory for created packages. Default: .

Examples

Try the built artifact:

$ sdkcraft try

sdkcraft init

Initialize an SDKcraft project

Usage

$ sdkcraft init [--name NAME] [--profile {simple}] [project_dir]

Description

Initialize an SDKcraft project by creating an ‘sdkcraft.yaml’ file together with hooks and tests.

Flags

--name

The name of project; defaults to the name of <project_dir>

--profile

Use the specified project profile (default is simple, choices are ‘simple’) Default: simple

Examples

Initialize a new project:

$ sdkcraft init

sdkcraft version

Show the application version and exit

Usage

$ sdkcraft version

Description

Show the application version and exit

sdkcraft create-track

Create one or more tracks for an SDK on the SDK Store

Usage

$ sdkcraft create-track --track TRACKS SDK

Description

Create one or more tracks for an SDK on the SDK Store.

The command lists all tracks it created. Tracks must match an existing guardrail for this SDK.

Flags

--track

The track name to create (can be repeated)

Examples

Create two tracks for the “go” SDK:

$ sdkcraft create-track go --track 1.26 --track 1.25

sdkcraft register

Register an SDK name on the store

Usage

$ sdkcraft register SDK

Description

Register an SDK name on the SDK Store.

This reserves the SDK name for your account, allowing you to upload revisions under that name. SDK names must be registered before uploading.

sdkcraft release

Release an SDK revision to store channels

Usage

$ sdkcraft release SDK REVISION CHANNELS

Description

Release <sdk> at <revision> to the selected store <channels>. <channels> is a comma-separated list of valid channels on the store.

The <revision> must exist on the store; to see available revisions, run sdkcraft revisions <sdk>.

The channel map is displayed after the operation.

The format for a channel is [<track>/]<risk>[/<branch>], where:

  • <track> is used to have long-term release channels.

  • <risk> can only be stable, candidate, beta, or edge.

  • <branch> is optional and dynamically creates a channel with a one-month expiration.

Examples

Release revision 8 to stable:

$ sdkcraft release my-sdk 8 stable

Release revision 8 to latest/stable:

$ sdkcraft release my-sdk 8 latest/stable

Release revision 9 to multiple channels:

$ sdkcraft release my-sdk 9 beta,edge

sdkcraft upload

Upload an SDK artifact to the store

Usage

$ sdkcraft upload [--release CHANNELS] SDK

Description

Upload an SDK artifact to the SDK Store.

The artifact must be a .sdk file created by the pack command. Optionally, the uploaded revision can be released to specified channels.

Flags

--release

Comma-separated list of channels to release to after upload

sdkcraft login

Log in to the SDK Store

Usage

$ sdkcraft login

Description

Log in to the SDK Store.

The login command requires a working keyring on the system it is used on. As an alternative, export ‘SDKCRAFT_STORE_CREDENTIALS’ with the exported credentials.

Examples

Log in interactively:

$ sdkcraft login

sdkcraft whoami

Display login information

Usage

$ sdkcraft whoami

Description

Display information about the currently authenticated user.

Examples

Show current login:

$ sdkcraft whoami

See also

Explanation:

Reference:

Tutorial: