-
Notifications
You must be signed in to change notification settings - Fork 8
/
create-fastmail-tag.sh
executable file
·56 lines (47 loc) · 1.34 KB
/
create-fastmail-tag.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w
my $tag = shift;
# make sure we're up to date
system('git', 'fetch', '--tags');
system('git', 'submodule', 'init');
system('git', 'submodule', 'update');
unless ($tag) {
# do we already have a tagged version here?
open(FH, "git tag --points-at HEAD |");
while(<FH>) {
next unless m{cyruslibs-fastmail-v(\d+)};
print "ALREADY a tagged version $1\n";
exit 0;
}
close(FH);
# calculate the next version
my $v = 0;
open(FH, "git tag -l |");
while(<FH>) {
next unless m{cyruslibs-fastmail-v(\d+)};
$v = $1 if $v < $1;
}
$v++;
close(FH);
$tag = "cyruslibs-fastmail-v$v";
}
print "TAGGING $tag\n";
my %modules;
open(FH, "git config -f .gitmodules -l |");
while (<FH>) {
next unless m{submodule\.([^\.=]+)\.([^\.=]+)=(.*)};
$modules{$1}{$2} = $3;
}
for my $module (sort keys %modules) {
next unless $modules{$module}{url} =~ m{github.com/cyrusimap/(.*)};
my $name = $1;
$name =~ s/\.git$//;
print "$module $modules{$module}{url}\n";
chdir $modules{$module}{path};
system('git', 'remote', 'add', 'github', "git\@github.com:cyrusimap/$name.git");
system('git', 'tag', '-f', $tag);
system('git', 'push', 'github', $tag);
chdir '..';
}
system('git', 'remote', 'add', 'github', "git\@github.com:cyrusimap/cyruslibs.git");
system('git', 'tag', '-f', $tag);
system('git', 'push', 'github', $tag);