How to create channel branches

Are branches actually supported today? How do I create one? How do I install from one?

@sergiusens You’re the best person to answer this question I think.

Branch support is all done (modulo a bug about the behaviour when the branch is closed).

However, the support in snapcraft for branches will be released in 2.30, so maybe you should wait for it to use it.

You can release into branches today, but it will not show them properly in the Store responses.

To release into a branch or close a branch you just include it in the channel, example:

snapcraft release mysnap 123 stable/hotfix

To install from a branch, it’s similar (also working now):

snap install mysnap --channel=stable/hotfix

Thanks @facundobatista! I see this PR, but it doesn’t seem to cover actually creating branches. Or does one simply need to release into them to create them?

Right! That PR is to properly show the responses. You don’t need any specific step to “create” a branch, just release into them…

If you (with currently released snapcraft) release into a branch, and then do snapcraft status mysnap it will fail to show the information properly for the snap.

1 Like

Very nice. This will solve so a lot of issues for me, thanks for the hard work!

Wait sorry, one more question: how about the expiration time?

it’s a month after the release, currently hardcoded. But note that:

  • you can always close it anytime (just as any other channel)
  • you can release again into it and the month will be reset (you can even release the same revision, if you want)

To release to a branch

snapcraft release <snap-name> <revision> <channel>

Where <channel> is any 2.0 channel form, let me paste the snapcraft --help output for the release command:

Usage: snapcraft release [OPTIONS] <snap-name> <revision> <channels>

  Release <snap-name> on <revision> to the selected store <channels>.
  <channels> is a comma separated list of valid channels on the store.

  The <revision> must exist on the store, to see available revisions run
  `snapcraft list-revisions <snap_name>`.

  The channel map will be displayed after the operation takes place. To see
  the status map at any other time run `snapcraft status <snap-name>`.

  The format for channels is `[<track>/]<risk>[/<branch>]` where

      - <track> is used to have long term release channels. It is implicitly
        set to `latest`. If this snap requires one, it can be created by
        request by having a conversation on https://forum.snapcraft.io
        under the *store* category.
      - <risk> is mandatory and can be either `stable`, `candidate`, `beta`
        or `edge`.
      - <branch> is optional and dynamically creates a channel with a
        specific expiration date.

  Examples:
      snapcraft release my-snap 8 stable
      snapcraft release my-snap 8 stable/my-branch
      snapcraft release my-snap 9 beta,edge
      snapcraft release my-snap 9 lts-channel/stable
      snapcraft release my-snap 9 lts-channel/stable/my-branch

Options:
  --help  Show this message and exit.

How exactly does one close the branch manually? I read that when you do another release (if I read it correctly) into the channel, it closes it. But weekday is I currently do not have another revision to release at that time? It might also be a good idea to have an example of closing a branch in the “help” output of the snapcraft command. For example, I went through a daisy chain of trading help then searching through the forum to try and find this detail. But maybe I missed it.

Did you try:

snapcraft close snap latest/my-branch

?

1 Like

This is what you get for trying to read the help file from a tiny phone screen in bed, ssh’d into a machine.

/me puts a dunce cap on and sits in the corner.