Skip to content

*craft#

craft-parts#

Ref.

graph TD

subgraph Part
$CRAFT_PART_SRC
$CRAFT_PART_BUILD
$CRAFT_PART_INSTALL
end

$CRAFT_PROJECT_DIR
--->|pull| $CRAFT_PART_SRC
--->|build| $CRAFT_PART_BUILD
--->|build| $CRAFT_PART_INSTALL
--->|stage| $CRAFT_STAGE
--->|prime| $CRAFT_PRIME

$CRAFT_PROJECT_DIR
--->|overlay| $CRAFT_OVERLAY
--->|stage| $CRAFT_STAGE

$CRAFT_PART_INSTALL
--->|organize| $CRAFT_PART_INSTALL

Snapcraft#

Charmcraft#

Publish a charm to charmhub#

Publishing to charmhub is straightforward: all you need to do is follow the register-upload-release workflow.

Note: in headless environments (e.g. multipass), use this:

dbus-run-session -- bash -c "echo password | gnome-keyring-daemon --unlock; charmcraft <args>"

Register a new charm's name under your account#

charmcraft names
charmcraft register karma-k8s

Pack and upload charm#

charmcraft pack
charmcraft upload karma-k8s_ubuntu-20.04-amd64.charm
charmcraft revisions karam-k8s

Upload resource (e.g. OCI image)#

charmcraft resources karma-k8s
charmcraft status karma-k8s
docker pull ghcr.io/prymitive/karma:v0.92
IMAGE_ID=$(docker images -q ghcr.io/prymitive/karma:v0.92)
charmcraft upload-resource karma-k8s karma-image --image=$IMAGE_ID
charmcraft resource-revisions karma-k8s karma-image
IMAGE="docker://ghcr.io/prymitive/karma:v0.114"
DIGEST=$(skopeo inspect $IMAGE | jq -r '.Digest')

CHARM="karma-k8s"
RESOURCE="karma-image"
charmcraft upload-resource $CHARM $RESOURCE --image=$DIGEST

Release#

charmcraft release karma-k8s --channel=edge --revision=1 --resource=karma-image:1
charmcraft status karma-k8s

Publish a bundle to charmhub#

charmcraft names
charmcraft register lma-light
charmcraft revisions lma-light

charmcraft pack
charmcraft upload lma-light.zip
charmcraft revisions lma-light

charmcraft release lma-light --channel=edge --revision=1
charmcraft status lma-light

Publish a library#

charmcraft list-lib alertmanager-k8s

# The next command may overwrite existing files, so backup first
charmcraft create-lib alertmanager_remote_configuration

charmcraft publish-lib charms.alertmanager_k8s.v0.alertmanager_remote_configuration

See official docs.