def release(name, channel, version, dry_run): """ Release the most current revision snap to channel """ latest_release = snapapi.latest(name, version) click.echo(latest_release) if dry_run: click.echo("dry-run only:") click.echo(f" > snapcraft release {name} {latest_release['rev']} {channel}") else: click.echo( sh.snapcraft.release(name, latest_release["rev"], channel, _err_to_out=True) )
def _promote_snaps(snap_list, arch, from_track, to_track, exclude_pre, dry_run): """ Promotes snaps from latest revision of version on architecture """ snap_list = Path(snap_list) if snap_list.exists(): snap_list = yaml.safe_load(snap_list.read_text(encoding="utf8")) else: snap_list = [] for snap in snap_list: out = snapapi.latest(snap, from_track.split("/")[0], arch, exclude_pre) if out: rev, uploaded, arch, version, channels = out for track in to_track: click.echo(f"Promoting ({rev}) {snap} {version} -> {track}") try: sh.snapcraft.release(snap, rev, track) except sh.ErrorReturnCode as error: click.echo(f"Problem: {error}") sys.exit(1)