### ----------------------------------------------------
### -- App::Mi6
### -- Licenses: Artistic-2.0
### -- Authors: Shoichi Kaji
### -- File: lib/App/Mi6/Release/UploadToZef.rakumod
### ----------------------------------------------------
unit class App::Mi6::Release::UploadToZef;

use App::Mi6::Util;
use App::Mi6::Fez;

method run(*%opt) {
    if %*ENV<FAKE_RELEASE> {
        note "Skip UploadToZef because FAKE_RELEASE is set.";
        return;
    }
    my $tarball = %opt<tarball>;
    if !%opt<yes> {
        loop {
            my $answer = prompt("Are you sure you want to upload $tarball to Zef ecosystem? (y/N)");
            if $answer ~~ rx:i/^y(es)?$/ {
                last;
            } elsif $answer ~~ rx:i/^n(o)?$/ {
                die "Abort.\n";
            } else {
                say "Please type Yes or No.";
            }
        };
    }
    App::Mi6::Fez.upload($tarball);
    say "It will appear in https://360.zef.pm/";
}


