def release(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 \b - <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. \b 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 """ snapcraft.release(snap_name, revision, channels.split(","))
def release(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 \b - <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. \b 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 """ snapcraft.release(snap_name, revision, channels.split(','))
def _run_store_command(args): if args['register']: snapcraft.register(args['<snap-name>']) elif args['upload']: snapcraft.upload(args['<snap-file>']) elif args['release']: snapcraft.release( args['<snap-name>'], args['<revision>'], args['<channel>'])
def release( snap_name, revision, channels, progressive_percentage: Optional[int], progressive_key: Optional[str], ) -> None: """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 \b - <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. \b 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 """ progressive_options = [progressive_percentage, progressive_key] if any(progressive_options) and not all(progressive_options): raise click.UsageError( "--progressive-percentage and --progressive-key must be used together." ) snapcraft.release( snap_name, revision, channels.split(","), progressive_percentage=progressive_percentage, progressive_key=progressive_key, )
def _run_store_command(args): if args['register']: snapcraft.register(args['<snap-name>'], args['--private']) elif args['upload']: logger.warning('DEPRECATED: Use `push` instead of `upload`') snapcraft.push(args['<snap-file>']) elif args['push']: if args['--release']: release_channels = args['--release'].split(',') else: release_channels = [] snapcraft.push(args['<snap-file>'], release_channels) elif args['release']: snapcraft.release(args['<snap-name>'], args['<revision>'], [args['<channel>']])
def _run_store_command(args): if args['register']: snapcraft.register(args['<snap-name>'], args['--private']) elif args['upload']: logger.warning('DEPRECATED: Use `push` instead of `upload`') snapcraft.push(args['<snap-file>']) elif args['push']: if args['--release']: release_channels = args['--release'].split(',') else: release_channels = [] snapcraft.push(args['<snap-file>'], release_channels) elif args['release']: snapcraft.release( args['<snap-name>'], args['<revision>'], [args['<channel>']])
def _run_store_command(args): # noqa: C901 if args['list-registered'] or args['registered']: snapcraft.list_registered() elif args['list-keys'] or args['keys']: snapcraft.list_keys() elif args['create-key']: snapcraft.create_key(args['<key-name>']) elif args['register-key']: snapcraft.register_key(args['<key-name>']) elif args['register']: snapcraft.register(args['<snap-name>'], args['--private']) elif args['sign-build']: snapcraft.sign_build( args['<snap-file>'], args['--key-name'], args['--local']) elif args['upload']: logger.warning('DEPRECATED: Use `push` instead of `upload`') snapcraft.push(args['<snap-file>']) elif args['push']: if args['--release']: release_channels = args['--release'].split(',') else: release_channels = [] snapcraft.push(args['<snap-file>'], release_channels) elif args['release']: snapcraft.release( args['<snap-name>'], args['<revision>'], [args['<channel>']]) elif args['validate']: snapcraft.validate(args['<snap-name>'], args['<validation>'], key=args['--key-name']) elif args['gated']: snapcraft.gated(args['<snap-name>']) elif args['status']: snapcraft.status( args['<snap-name>'], args['--series'], args['--arch']) elif args['revisions'] or args['list-revisions'] or args['history']: if args['history']: deprecations.handle_deprecation_notice('dn4') snapcraft.revisions( args['<snap-name>'], args['--series'], args['--arch']) elif args['close']: snapcraft.close(args['<snap-name>'], args['<channel_names>']) elif args['collaborate']: snapcraft.collaborate(args['<snap-name>'], key=args['--key-name'])
def _run_store_command(args): # noqa: C901 if args['list-registered'] or args['registered']: snapcraft.list_registered() elif args['list-keys'] or args['keys']: snapcraft.list_keys() elif args['create-key']: snapcraft.create_key(args['<key-name>']) elif args['register-key']: snapcraft.register_key(args['<key-name>']) elif args['register']: snapcraft.register(args['<snap-name>'], args['--private']) elif args['sign-build']: snapcraft.sign_build( args['<snap-file>'], args['--key-name'], args['--local']) elif args['upload']: logger.warning('DEPRECATED: Use `push` instead of `upload`') snapcraft.push(args['<snap-file>']) elif args['push']: if args['--release']: release_channels = args['--release'].split(',') else: release_channels = [] snapcraft.push(args['<snap-file>'], release_channels) elif args['release']: snapcraft.release( args['<snap-name>'], args['<revision>'], [args['<channel>']]) elif args['validate']: snapcraft.validate(args['<snap-name>'], args['<validation>'], key=args['--key-name']) elif args['gated']: snapcraft.gated(args['<snap-name>']) elif args['status']: snapcraft.status( args['<snap-name>'], args['--series'], args['--arch']) elif args['revisions'] or args['list-revisions'] or args['history']: if args['history']: deprecations.handle_deprecation_notice('dn4') snapcraft.revisions( args['<snap-name>'], args['--series'], args['--arch']) elif args['close']: snapcraft.close(args['<snap-name>'], args['<channel_names>'])
def promote(snap_name, from_channel, to_channel, yes): """Promote a build set from to a channel. A build set is a set of commonly tagged revisions, the most simple form of a build set is a set of revisions released to a channel. Currently, only channels are supported to release from (<from-channel>) Prior to releasing, visual confirmation shall be required. The format for channels is `[<track>/]<risk>[/<branch>]` where \b - <track> is used to have long term release channels. It is implicitly set to the default. - <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. \b Examples: snapcraft promote my-snap --from-channel candidate --to-channel stable snapcraft promote my-snap --from-channel lts/candidate --to-channel lts/stable snapcraft promote my-snap --from-channel stable/patch --to-channel stable snapcraft promote my-snap --from-channel experimental/stable --to-channel stable """ echo.warning( "snapcraft promote does not have a stable CLI interface. Use with caution in scripts." ) parsed_from_channel = storeapi.channels.Channel(from_channel) parsed_to_channel = storeapi.channels.Channel(to_channel) if parsed_from_channel == parsed_to_channel: raise click.BadOptionUsage( "--from-channel and --to-channel cannot be the same.") elif parsed_from_channel.risk == "edge" and parsed_from_channel.branch is None: raise click.BadOptionUsage( "{!r} is not a valid set value for --from-channel.".format( parsed_from_channel)) store = storeapi.StoreClient() with _requires_login(): status_payload = store.get_snap_status(snap_name) snap_status = storeapi.status.SnapStatus(snap_name=snap_name, payload=status_payload) from_channel_set = snap_status.get_channel_set(parsed_from_channel) echo.info("Build set information for {!r}".format(parsed_from_channel)) click.echo( tabulate( sorted(from_channel_set, key=operator.attrgetter("arch")), headers=["Arch", "Revision", "Version"], tablefmt="plain", )) if yes or echo.confirm( "Do you want to promote the current set to the {!r} channel?". format(parsed_to_channel)): for c in from_channel_set: snapcraft.release(snap_name, str(c.revision), [str(parsed_to_channel)]) else: echo.wrapped("Channel promotion cancelled")