Publish your operator in Charmhub

Key Value
Summary Use charmcraft to build charms, upload them to Charmhub and publish them for easy consumption.
Categories using-charmhub
Difficulty 2
Author Facundo Batista facundo.batista@canonical.com

Overview

Duration: 0:10

In this tutorial we’ll show you how to publish your operator in Charmhub.

You should already have completed a previous tutorial, to create a minimal operator, or already have one of your own that builds with charmcraft build. You will need charmcraft installed.

If you don’t have a charm and don’t want to go through that tutorial to make one, then you will not be able to work with Charmhub, but you can watch this tutorial on Youtube to get the idea.

We build the charm with charmcraft. This will fetch any dependencies, compile any modules, check that all the key files are in place, and produce a compressed archive with the operator code and metadata as the charm.

$ charmcraft build
Done, charm left in 'hello-world.charm'

Login to Charmhub

Duration: 2:00

You will need to log in to Charmhub in order to upload and release charms.

$ charmcraft login
Opening an authorization web page in your browser; if it does not open, please open this URL: https://api.staging.jujucharms.com/identity/login?did=2cfdcd9bf73014bad4e875
Login successful.

If this is our first time with this charm, we will need to register this name in the Store:

$ charmcraft register storestory
Congrats! You are now the publisher of 'storestory'

NOTE: All commands to the Store needs for us to be authenticated. This is handled automatically by charmcraft: if the credentials expired or not found a browser page will open for us to authenticate against the Store as we usually do in the web. We can always check how is our authentication status by issuing charmcraft whoami.

If in doubt, we can easily check all our registered names:

$ charmcraft names
Name            Visibility    Status
...
storestory      public        registered
...

Uploading

Duration: 1:00

Now we’re ready to upload the binary. We just need to specify the path to it:

charmcraft upload hello-world.charm
Revision 1 of 'storestory' created

Every time we upload a new binary for the charm we get a new revision in the Store. We can verify its current status easily:

$ charmcraft revisions storestory
Revision    Version    Created at    Status
1           0.1        2020-07-23    approved

Now it’s time to release!

$ charmcraft release storestory --revision=1 --channel=beta
Revision 1 of charm 'storestory' released to beta

Finally, we can see the overall status:

$ charmcraft status storestory
Track    Channel    Version    Revision
latest   stable     -          -
         candidate  -          -
         beta       0.1        1
         edge       ↑          ↑

Enjoy.

3 Likes

Can you change the title of the post to [Tutorial] xxxxx? This is great for spotting them out here in the forum. Sane thing with the referenced “how to build a charm using modern tools”.

2 Likes

I would love to know also about private namespaces for charms and how to remove charms if that’s possible?

1 Like

Hello Erik, sorry for the delay in the response, this was lost in my ToDo.

What exactly do you mean with “private namespaces”? We have private charms (read/write capabilities for the owner, and potentially collaborators), but nothing like “namespaces”…

Regarding the removing charm capability, is not a feature we have planned. You could close all the channels and effectively having it not released, but nothing like removing the charm itself.

Please let me know if I can help you with more detail in any of these responses.

Regards,

Private charms is what I use for charms that I don’t want to make public. I use it with Launchpad teams.

Removing charms is a needed feature as I have some times pushed charms under wrong names and namespaces/teams which gets very confusing when using the ‘charm list’ etc. It then shows all the charms even those I wish I never added (by mistakes). My namespace becomes very bloated and messy.

1 Like

This is something that depends on the store itself, which is still a ongoing work, probably we’ll have features like this in the future.

1 Like