]> mj.ucw.cz Git - checkmail.git/commitdiff
release.pm: Added release notifiers
authorMartin Mares <mj@ucw.cz>
Sun, 18 Jul 2010 13:51:53 +0000 (15:51 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 18 Jul 2010 13:51:53 +0000 (15:51 +0200)
maint/release.pm

index cc84bbe3676b5401fb995dee18a5f5dd249763bd..cad091e30c9866c0026c0d4aef480475f0e544c5 100644 (file)
@@ -30,6 +30,8 @@ sub new($$) {
                "archivedir" => "/home/mj/tmp/archives/$basename",
                "uploads" => [
                        ],
                "archivedir" => "/home/mj/tmp/archives/$basename",
                "uploads" => [
                        ],
+               "notifiers" => [
+                       ],
                # Options
                "do_test" => 1,
                "do_patch" => 1,
                # Options
                "do_test" => 1,
                "do_patch" => 1,
@@ -37,6 +39,7 @@ sub new($$) {
                "do_upload" => 1,
                "do_git_tag" => 0,
                "force_git_tag" => 0,
                "do_upload" => 1,
                "do_git_tag" => 0,
                "force_git_tag" => 0,
+               "do_notify" => 0,
        };
        bless $s;
        return $s;
        };
        bless $s;
        return $s;
@@ -231,9 +234,10 @@ Options:
 --[no]upload           Upload released files {do_upload}
 --[no]git-tag          Tag the Git repository with "v<version>" {do_git_tag}
 --force-git-tag                Rewrite the Git tag if it already exists {force_git_tag}
 --[no]upload           Upload released files {do_upload}
 --[no]git-tag          Tag the Git repository with "v<version>" {do_git_tag}
 --force-git-tag                Rewrite the Git tag if it already exists {force_git_tag}
+--[no]notify           Call scripts to notify the world about the release {do_notify}
 FOE
        sub state($) {
 FOE
        sub state($) {
-               return "(default: " . ($_ ? "on" : "off") . ")";
+               return "(default: " . ($_[0] ? "on" : "off") . ")";
        }
        $usage =~ s[{(\w+)}][state($s->{$1})]ge;
        die $usage;
        }
        $usage =~ s[{(\w+)}][state($s->{$1})]ge;
        die $usage;
@@ -242,6 +246,7 @@ FOE
 sub ParseOptions($) {
        my ($s) = @_;
        $s->{"do_git_tag"} = 1 if (-d ".git");
 sub ParseOptions($) {
        my ($s) = @_;
        $s->{"do_git_tag"} = 1 if (-d ".git");
+       $s->{"do_notify"} = 1 if @{$s->{"notifiers"}};
        GetOptions(
                "verbose!" => \$verbose,
                "test!" => \$s->{"do_test"},
        GetOptions(
                "verbose!" => \$verbose,
                "test!" => \$s->{"do_test"},
@@ -250,6 +255,7 @@ sub ParseOptions($) {
                "upload!" => \$s->{"do_upload"},
                'git-tag!' => \$s->{"do_git_tag"},
                'force-git-tag!' => \$s->{"force_git_tag"},
                "upload!" => \$s->{"do_upload"},
                'git-tag!' => \$s->{"do_git_tag"},
                'force-git-tag!' => \$s->{"force_git_tag"},
+               'notify!' => \$s->{"do_notify"},
        ) || $s->Usage;
 }
 
        ) || $s->Usage;
 }
 
@@ -343,12 +349,28 @@ sub GitTag($) {
        `git push --tags`; die if $?;
 }
 
        `git push --tags`; die if $?;
 }
 
+sub AddUcwNotifier($) {
+       my ($r) = @_;
+       push @{$r->{"notifiers"}}, sub {
+               my ($s) = @_;
+               print "Updating web pages\n";
+               my $pkg = $s->{'PACKAGE'};
+               my $ver = $s->{'VERSION'};
+               `ssh jw 'cd www && bin/release-prog $pkg $ver'`; die if $?;
+       };
+};
+
 sub Dispatch($) {
        my ($s) = @_;
        $s->Test if $s->{"do_test"};
        $s->MakePatch if $s->{"do_patch"};
        $s->GitTag if $s->{"do_git_tag"};
        $s->Upload if $s->{"do_upload"};
 sub Dispatch($) {
        my ($s) = @_;
        $s->Test if $s->{"do_test"};
        $s->MakePatch if $s->{"do_patch"};
        $s->GitTag if $s->{"do_git_tag"};
        $s->Upload if $s->{"do_upload"};
+       if ($s->{"do_notify"}) {
+               for my $f (@{$s->{"notifiers"}}) {
+                       &$f($s);
+               }
+       }
 }
 
 1;
 }
 
 1;