github.com/olivere/camlistore@v0.0.0-20140121221811-1b7ac2da0199/dev/make-release (about) 1 #!/usr/bin/perl 2 3 use strict; 4 use Getopt::Long; 5 my $opt_force; 6 GetOptions("force" => \$opt_force) or die "Usage: make-release [-f] <version>"; 7 8 my $version = shift or die "Usage: make-release <version>"; 9 10 die "Not being run from root of Camlistore" unless -e ".git" && -e "pkg/blob/ref.go"; 11 12 my $cur_branch = `git rev-parse --abbrev-ref HEAD`; 13 chomp $cur_branch; 14 die "Not on master" unless $cur_branch eq "master"; 15 16 my $new_branch = "releases/$version"; 17 18 if ($opt_force) { 19 system("git", "tag", "-d", $version); 20 system("git", "branch", "-D", $new_branch); 21 } 22 23 system("git", "checkout", "-b", $new_branch) and die "Failed to create branch $new_branch from master. Does it already exist?"; 24 25 open(my $fh, ">VERSION") or die; 26 print $fh "$version\n"; 27 close($fh); 28 29 system("git", "add", "VERSION") and die; 30 foreach my $d (qw{ 31 .hackfests 32 website 33 clients/chrome 34 lib 35 old 36 dev-db 37 }) { 38 system("git", "rm", "-r", $d) and die "Failed to git rm -r $d"; 39 } 40 system("git", "commit", "-m", "Add VERSION file and clean tree for release $version") and die "Failed to commit"; 41 system("git", "tag", $version) and die "Failed to tag"; 42 43 my $commit = do { open(my $f, ".git/refs/tags/$version") or die; local $/; <$f> }; 44 chomp $commit; 45 46 system("git", "checkout", "master") and die; 47 open(my $fh, ">>misc/release-history-tags"); 48 print $fh "$commit\t$version\n"; 49 close($fh); 50 51 print "Created branch $new_branch from master, cleaned it and wrote VERSION file, & tagged $version.\n"; 52 print "\n"; 53 print "Push with:\n"; 54 print "\$ git push github refs/tags/$version:refs/tags/$version\n"; 55 print "\$ git push github $new_branch:$new_branch\n";