How to publish your charm to Charmhub

See also:

You’ve packed your charm. You’ve also prepared a nice README file for your charm. You are now ready to share it with the world! You can of course share it privately, but it’s more effective to share it publicly. And you can share it on your own website, but you can probably reach more people faster if you share it in a more public forum. This document demonstrates how to publish your charm to the official repository of charms, Charmhub.

Just like initialising and building your charm, publishing your charm can also be easily done using Charmcraft.

Contents:

Log into Charmhub

See also: charmcraft login

To log into Charmhub, use the login command:

$ charmcraft login
Opening an authorization web page in your browser.
If it does not open, please open this URL:
...

Your charmcraft session will expire automatically, but you’ll be prompted to re-authenticate automatically next time you try to access a feature that requires interaction with Charmhub.

Register your charm’s name

See also: charmcraft register, Charm naming guidelines, charmcraft names

To register your charm’s name to your account, use the register command follow by your desired charm name:

$ charmcraft register my-awesome-charm
Congrats! You are now the publisher of 'my-awesome-charm'

You only need to register the name if you haven’t already registered it before. You can check which names you have already registered by running charmcraft names.

Upload the charm

See also: charmcraft upload

To upload the charm, use the upload command followed by the your charm’s filepath.

charmcraft upload my-awesome-charm.charm
Revision 1 of my-awesome-charm created

Every time a new binary is uploaded for a charm, a new revision is created on Charmhub. We can verify its current status easily by running charmcraft revisions <charm-name>.

Release the charm

See also: charmcraft release, charmcraft status

Finally, release your charm into a channel so it can become available for downloading:

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

Only once the charm is released (to any channel) will Charmhub display the charm’s information at charmhub.io/charm-name. The default information displayed is obtained from the most stable channel.

Just in case, also check your charm’s status:

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

If your charm is designed to work on Kubernetes, or otherwise requires the use of additional resources, there are additional steps required to upload the resources and attach them to a release. To find out more, see How to publish your charm’s resources.

We need more information about the permission model in charmhub, for example:

  • How are teams created? Are they tied to Launchpad?
  • How to list/grant/revoke permissions?
  • How to upload a version of a charm under my own namespace like I would do with charm push <charm-name> cs:~alejdg/<charm-name>?

Hi Alexandre,

The final details of all this is still be worked out and there are a few missing bits currently, or things that need manual intervention from the charmhub team. Some of this is by design (e.g. some charm names have been reserved and need discussion if you want it assigned to you), but the tools could do with updates to make it more obvious when this is the case.

I can talk you through more of the detail next week, but I see you’ve also filed a bunch of issues against charmhub.io and charmcraft already.

Thanks, Tom

1 Like

Hey, looks like @mthaddon mostly got you covered here. One other point to note is that there are no user namespaces on Charmhub.

1 Like

Hi and thanks for this useful doc! This advertises publishing to the beta channel instead of stable, which is good but led to an unexpected behavior in my case: when editing metadata.yaml (e.g. changing the charm’s summary) and re-publishing, the changes aren’t reflected on the charm store. I clarified with people from the charmhub: once a charm has been published once, new changes will be reflected only when publishing to the stable channel, even if nothing has ever been published to that channel yet.

I’m wondering if there should be a warning here, or if this should be improved on the charmhub? Maybe the charmhub should reflect changes when publishing to the “currently most stable” channel, not only stable.

Hi Jon,

One thing I believe is missing from the publishing doc is how to add an icon to your charm. This is somewhat described at Creating icons for charms ; I think we should link to that post and be explicit about the filename requirements (i.e. an icon.svg file in the charm root - I believe).

Hi, thanks! Have put a note into the docs.

Thanks, I’ve added a section under charm anatomy to include a icon.svg and a link to that article.

Hi,

This document mentions “tracks”, and “versions” for a charm. Further charmcraft help release also mentions “branch”. However it is not clear what is the charmcraft command line syntax (with some examples) on how does one release a charm for a specific “version”, “track” and “branch” in addition to “risk”. Some guidelines regarding use of these features may also be useful in the context of this document.

regards

Had exactly the same thought, so I added a note to that effect in the creating-icons-for-charms article.