Publish your operator in Charmhub

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.

NOTE: currently the Store support is under development, so all these actions are done against staging, there are no guarantees over the stored information.

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. As we’re in our project’s directory the command is very simple (otherwise we would need to use the --charm-file option to specify the binary’s location):

charmcraft upload
Revision 1 of 'storestory' created

Everytime 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
Revision    Version    Created at    Status
1           0.1        2020-07-23    approved

Note that we didn’t specify the charm’s name: this is because we’re in the project’s directory, so the name is retrieved automatically; if you want to ask for any other charm you can use the --name option.

Now it’s time to release!

$ charmcraft release beta
Revision 1 of charm 'storestory' released to beta

As before, release uses current project for the naming (you can override it with --name) and releases the last uploaded revision (you can specify a different one with --revision).

Finally, we can see the overall status:

$ charmcraft status
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”.

1 Like

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

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.

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