#!/usr/bin/perl
# A simple script for making releases of LibUCW
# (c) 2012--2014 Martin Mares <mj@ucw.cz>

use strict;
use warnings;
require "maint/release.pm";

my $r = new UCW::Release("libucw");
$r->{"test_compile"} = "./configure && make -j4";
$r->{"archive_dir"} = $ENV{"HOME"} . "/archives/sw/libucw";
push @{$r->{"uploads"}}, { "url" => "scp://ftp.ucw.cz/~ftp/pub/libucw/" };

$r->ParseOptions;
$r->GetVersionFromGit;
$r->InitDist("maint/tmp");
my $reldir = $r->GenPackage;
$r->GenFile("README");
$r->Test;
$r->MakeArchive;
$r->Upload;

if ($r->{"do_upload"}) {
	my $tdir = $r->{"TESTDIR"};
	if (defined $tdir) {
		print "Generating documentation\n";
		`cd $tdir && make docs`;
		die if $?;
		print "Upload of documentation\n";
		$r->Confirm;
		`cd $tdir && maint/upload-doc`;
		die if $@;
	} else {
		print "WARNING: With --notest, no documentation is published!\n";
	}

	print "Updating version at MJ's web\n";
	$r->Confirm;
	my $wv = $r->{"VERSION"};
	`ssh jw "cd web && bin/release-prog libucw $wv"`;
	die if $?;
}