github.com/slspeek/camlistore_namedsearch@v0.0.0-20140519202248-ed6f70f7721a/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 system("git", "commit", "-m", "Add VERSION file on the $new_branch branch.") and die "Failed to commit"; 31 system("git", "tag", $version) and die "Failed to tag"; 32 33 my $commit = do { open(my $f, ".git/refs/tags/$version") or die; local $/; <$f> }; 34 chomp $commit; 35 36 system("git", "checkout", "master") and die; 37 open(my $fh, ">>misc/release-history-tags"); 38 print $fh "$commit\t$version\n"; 39 close($fh); 40 41 print "Created branch $new_branch from master, cleaned it and wrote VERSION file, & tagged $version.\n"; 42 print "\n"; 43 print "Push with:\n"; 44 print "\$ git push github refs/tags/$version:refs/tags/$version\n"; 45 print "\$ git push github $new_branch:$new_branch\n";