<a id="ref-sdkcraft-cli"></a>

# sdkcraft (CLI)

<!-- @artefact sdkcraft (CLI) -->

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

<a id="ref-sdkcraft-clean"></a>

## sdkcraft clean

<!-- @artefact sdkcraft clean -->

Remove a part’s assets

### Usage

```console
$ 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

### Examples

Clean build artifacts:

```console
$ sdkcraft clean
```

Clean specific parts:

```console
$ sdkcraft clean my-part
```

Clean in destructive mode:

```console
$ sdkcraft clean --destructive-mode
```

<a id="ref-sdkcraft-pull"></a>

## sdkcraft pull

<!-- @artefact sdkcraft pull -->

Download or retrieve artifacts defined for a part

### Usage

```console
$ 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

<a id="ref-sdkcraft-build"></a>

## sdkcraft build

<!-- @artefact sdkcraft build -->

Build artifacts defined for a part

### Usage

```console
$ 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

<a id="ref-sdkcraft-stage"></a>

## sdkcraft stage

<!-- @artefact sdkcraft stage -->

Stage built artifacts into a common staging area

### Usage

```console
$ 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

<a id="ref-sdkcraft-prime"></a>

## sdkcraft prime

<!-- @artefact sdkcraft prime -->

Prime artifacts defined for a part

### Usage

```console
$ 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

<a id="ref-sdkcraft-pack"></a>

## sdkcraft pack

<!-- @artefact sdkcraft pack -->

Create the final artifact

### Usage

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

### Description

Process parts and create the final artifact.

### Flags

### Examples

Pack the project:

```console
$ sdkcraft pack
```

Pack to a specific output directory:

```console
$ sdkcraft pack --output dist/
```

<a id="ref-sdkcraft-test"></a>

## sdkcraft test

<!-- @artefact sdkcraft test -->

Run SDK tests

### Usage

```console
$ 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](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

### Examples

Test the project:

```console
$ sdkcraft test
```

List the jobs that would run:

```console
$ sdkcraft test --list
```

Run a specific test suite:

```console
$ sdkcraft test my-suite/
```

<a id="ref-sdkcraft-try"></a>

## sdkcraft try

<!-- @artefact sdkcraft try -->

Try SDKs before publishing

### Usage

```console
$ 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

### Examples

Try the built artifact:

```console
$ sdkcraft try
```

<a id="ref-sdkcraft-init"></a>

## sdkcraft init

<!-- @artefact sdkcraft init -->

Initialize an SDKcraft project

### Usage

```console
$ 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

### Examples

Initialize a new project:

```console
$ sdkcraft init
```

<a id="ref-sdkcraft-version"></a>

## sdkcraft version

<!-- @artefact sdkcraft version -->

Show the application version and exit

### Usage

```console
$ sdkcraft version
```

### Description

Show the application version and exit

<a id="ref-sdkcraft-create-track"></a>

## sdkcraft create-track

<!-- @artefact sdkcraft create-track -->

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

### Usage

```console
$ 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

### Examples

Create two tracks for the “go” SDK:

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

<a id="ref-sdkcraft-register"></a>

## sdkcraft register

<!-- @artefact sdkcraft register -->

Register an SDK name on the store

### Usage

```console
$ 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.

<a id="ref-sdkcraft-release"></a>

## sdkcraft release

<!-- @artefact sdkcraft release -->

Release an SDK revision to store channels

### Usage

```console
$ 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:

```console
$ sdkcraft release my-sdk 8 stable
```

Release revision 8 to latest/stable:

```console
$ sdkcraft release my-sdk 8 latest/stable
```

Release revision 9 to multiple channels:

```console
$ sdkcraft release my-sdk 9 beta,edge
```

<a id="ref-sdkcraft-revisions"></a>

## sdkcraft revisions

<!-- @artefact sdkcraft revisions -->

List SDK revisions available on the store

### Usage

```console
$ sdkcraft revisions SDK
```

### Description

List all available channels and revisions for <sdk> from the store.

Use this command to find the revision number to pass to
sdkcraft release <sdk> <revision> <channels>.

### Examples

List revisions for an SDK:

```console
$ sdkcraft revisions my-sdk
```

<a id="ref-sdkcraft-upload"></a>

## sdkcraft upload

<!-- @artefact sdkcraft upload -->

Upload an SDK artifact to the store

### Usage

```console
$ 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

<a id="ref-sdkcraft-login"></a>

## sdkcraft login

<!-- @artefact sdkcraft login -->

Log in to the SDK Store

### Usage

```console
$ 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:

```console
$ sdkcraft login
```

<a id="ref-sdkcraft-whoami"></a>

## sdkcraft whoami

<!-- @artefact sdkcraft whoami -->

Display login information

### Usage

```console
$ sdkcraft whoami
```

### Description

Display information about the currently authenticated user.

### Examples

Show current login:

```console
$ sdkcraft whoami
```

## See also

Explanation:

- [SDK concepts](https://ubuntu.com/workshop/docs//explanation/sdks/concepts.md#exp-sdk-concepts)

Reference:

- [SDK definition](https://ubuntu.com/workshop/docs//reference/definition-files/sdk-definition.md#ref-sdk-definition)
- [SDK internals](https://ubuntu.com/workshop/docs//reference/sdks.md#ref-sdk-internals)

Tutorial:

- [Craft SDKs with SDKcraft](https://ubuntu.com/workshop/docs//tutorial/part-4-craft-sdks.md#tut-craft-sdks)
