This repository was archived by the owner on Dec 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakeVersionTag.pl
More file actions
executable file
·62 lines (53 loc) · 1.5 KB
/
makeVersionTag.pl
File metadata and controls
executable file
·62 lines (53 loc) · 1.5 KB
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
56
57
58
59
60
61
62
#!/usr/bin/perl --
use strict;
use warnings;
sub cmd($){
print "+ ",$_[0],"\n";
my $rv=system $_[0];
if ($? == -1) {
die "failed to execute: $!\n";
}elsif ($? & 127) {
die "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without';
}else {
my $rv = $? >> 8;
$rv and die "child exited with value $rv\n";
}
}
# ワーキングツリーに変更がないことを確認
open(my $fh,"-|","git status --porcelain --branch")
or die "can't check git status. $!";
my @untrackedFiles;
while(<$fh>){
chomp;
if(/^\?\?\s*(\S+)/){
my $path =$1;
next if $path =~ /\.idea|_Emoji|makeVersionTag.pl/;
push @untrackedFiles,$path
}elsif( /^##\s*(\S+?)(?:\.\.|$)/ ){
my $branch=$1;
print "# branch=$branch\n";
$branch eq 'master'
or die "current branch is not master.\n";
}else{
warn "working tree is not clean.\n";
cmd "git status";
exit 1;
}
}
close($fh)
or die "can't check git status. $!";
@untrackedFiles and die "forgot git add?\n",map{ "- $_\n"} @untrackedFiles;
# 現在のバージョン番号を取得
my $buildFile = 'app/build.gradle';
`cat $buildFile` =~ /versionName\s+["']([\d\.]+)["']/
or die "missing versionName in $buildFile\n";
my($tag)="v$1";
print "# version=$tag\n";
# すでにタグがあるなら何もしない
if( `git tag -l $tag` =~ /$tag/ ){
print "# tag $tag is already exists.\n";
}else{
cmd "git tag -a $tag -m $tag";
}
cmd "git push";
cmd "git push --tags";