Once you have built your charm, you should publish it to Charmhub. This section will guide you through the process.

Build your charm

Before your charm can be published, it needs to be built. The build process will fetch any dependencies you’ve specified in your requirements.txt and package them up with your charm code in a .charm package:

$ charmcraft pack
Done, charm left in 'hello-operator.charm'

A .charm file is just a zip file, and can be unzipped and examined as such.

When the charm is packed, a series of analysis and lintings will happen, you may receive warnings and even errors to help improving the quality of the charm. You can read more about this here.

Register a name

Before you can interact with Charmhub using charmcraft you’ll need to login:

$ charmcraft login
Opening an authorization web page in your browser; if it does not open, please open this URL:<id>
Login successful.

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

If you’re publishing your charm for the first time, you’ll need to register the name to your account:

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

You can check the charm names registered to your account at any time:

$ charmcraft names
Name                  Visibility    Status
# ...
my-awesome-charm      public        registered
# ...

Upload and Release

The charm is now ready to be uploaded, which is achieved by invoking charmcraft upload and passing the filename of the built charm:

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:

$ charmcraft revisions my-awesome-charm
Revision    Version    Created at    Status
1           0.1        2020-07-23    approved

Uploaded charms are not automatically released and made available for download. Once a charm is uploaded, it must be released into a channel before it can be consumed:

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

Note that Charmhub uses information from the stable channel to populate the information on a charm’s homepage by default.

Finally, we can see the overall 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 Charm Resources, there are additional steps required to upload the resources and attach them to a release. Read more in the Publishing Resources section.

Last updated a month ago.