12 use List
::Util qw
/ min /;
16 # parse and validate command line args
24 my $cmd_string = join(' ', map {$_ =~ /\s/ ?
"'$_'" : $_} @_);
26 print "DO: $cmd_string\n" if $opt{v
} || $opt{x
};
29 $?
and die "command failed: $cmd_string\nAborting.\n";
33 getopts
('c:nMmr:V:vpx',\
%opt) or pod2usage
(1);
35 $opt{M
} || $opt{m
} || $opt{V
}
36 or pod2usage
('must specify either -M, -m, or -V');
37 #@ARGV == 1 || @ARGV == 2 or pod2usage('must provide component name, and optionally remote name');
39 my ($component_name,$remote) = @ARGV;
40 $component_name = basename
( getcwd
() ) unless defined $component_name;
41 $remote = 'origin' unless defined $remote;
44 vprint
("fetching tags from $remote ...\n");
45 fsystem
('git','fetch','--tags',
46 ($opt{v
} ?
() : '-q'),
50 my @previous_releases = previous_releases
($component_name);
52 #figure out the next major version number
54 defined( $opt{V
} ) ?
$opt{V
} :
55 @previous_releases ?
$opt{M
} ?
$previous_releases[0][0]+1 :
56 $opt{m
} ?
$previous_releases[0][0] :
57 pod2usage
('must specify either -M, -m, or -V')
61 #figure out the next minor version number
62 my $minor_version = do {
63 if(my @other_rels = grep {$major_version == $_->[0]} @previous_releases) {
70 my $release_ref = $opt{r
} || 'master';
72 my $comment = $opt{c
} ?
$opt{c
} : "";
73 my $new_release_tag = "$component_name-$major_version.$minor_version";
76 fsystem
( 'git', 'tag',
77 -m
=> $new_release_tag,
78 -m
=> "$FindBin::Script: tagging $release_ref as release $new_release_tag",
85 tagged
$release_ref as release
$new_release_tag
89 vprint
("pushing tags to $remote ...\n");
90 fsystem
(qw( git push --tags ),
91 ($opt{v
} ?
() : '-q'),
94 print "-p not passed, skipping auto-push. You may want to run: git push --tags\n";
102 # args: git remote base, component name (e.g. 'cxgn-corelibs')
103 # returns: a list as ([major,minor],[major,minor]) of
104 # previous revisions that are present in the repos,
105 # in descending order by major and minor revision number
106 sub previous_releases
{
107 my ($component_name) = @_;
110 sort { $b->[0] <=> $a->[0] || $b->[1] <=> $a->[1] }
112 if(m
|^$component_name-(\d
+)\
.(\d
+)(?
=\s
)|) {
119 vprint
("last few $component_name releases:\n");
120 vprint
(" $_->[2]\n") for reverse grep $_, @releases[0 .. min
(2,$#releases)];
126 $r = `git rev-parse $r`;
134 $tag =~ /(v?[\d\.]+)$/
136 return version
->new($1);
143 make_release_tag.pl - make a new release tag for the given software component name.
147 cd my_component; make_release_tag.pl [options] [component_name] [remote_name]
149 Must specify one of -M, -m, or -V. Must be run from a working
150 directory inside the git repository in question.
152 The default component name is the name of the current working
155 The default remote name is 'origin'.
160 do not run 'git fetch --tags' before making a new release tag.
161 good for making a tag without network access, but be sure someone
162 has not already done it!
165 run a git push --tags <remote> after creating the tag to push the
166 tag to the given remote. be careful with this!
169 make this a major release. equivalent to '-V <num+1>', where
170 num is the current major release.
173 number this as a minor release. equivalent to '-V <num>', where
174 num is the current major release.
177 the rev (branch, commit, or other tag) to take as this release,
181 major version number for this release, like '4'
182 defaults to the next major number in the sequence
185 -v be verbose about what you're doing
187 -x just do a dry run, printing what you _would_ do
191 =head2 Without autopush
193 =head3 make a new release tag for the Phenome component
195 cd Phenome; make_release_tag.pl -M Phenome
197 =head3 make sure the tag it just made is correct, then send it to github
201 =head2 With autopush (be careful!)
203 cd Phenome; make_release_tag.pl -pM Phenome
207 Robert Buels, E<lt>rmb32@cornell.eduE<gt>
209 =head1 COPYRIGHT & LICENSE
211 Copyright 2010 Boyce Thompson Institute for Plant Research
213 This program is free software; you can redistribute it and/or modify
214 it under the same terms as Perl itself.