-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy-release.pl
executable file
·78 lines (72 loc) · 1.58 KB
/
deploy-release.pl
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
my $script = __FILE__;
my $dir = dirname($script);
chdir $dir || die "cant cd to $dir";
$dir = `pwd`;
chomp($dir);
print "dir is $dir\n";
my $codeineDir = "$dir";
print "codeineDir is $codeineDir\n";
print "deploy codeine...\n";
my $propertiesFile = "$codeineDir/src/common/codeine/version.properties";
my $deployDir = "$ARGV[0]";
print "deploy dir: $deployDir\n";
exit(1) unless (-d $deployDir);
my $version = getVersionFull();
my $tar = "codeine_".getVersionNoDate().".tar.gz";
print "deploying to $deployDir/$tar\n";
es("cp $tar $deployDir/$tar");
es("cp $tar codeine.latest.tar.gz");
es("rm $deployDir/codeine.latest.tar.gz");
es("ln -s $tar $deployDir/codeine.latest.tar.gz");
print "deployed\n";
sub es
{
e(shift);
my $status = $?;
if ($status != 0)
{
print "error on execution, will exit.\n";
exit $status >> 8;
}
}
sub e
{
my $cmd = shift;
print "executing $cmd\n";
system($cmd);
}
sub r
{
my $cmd = shift;
print "executing $cmd\n";
return `$cmd`;
}
sub getVersionFull
{
my $major = getVersion('major');
my $minor = getVersion('minor');
my $build = getVersion('build');
my $date = getVersion('date');
my $version = "$major.$minor.$build.$date";
return $version;
}
sub getVersionNoDate
{
my $major = getVersion('major');
my $minor = getVersion('minor');
my $build = getVersion('build');
my $date = getVersion('date');
my $version = "$major.$minor.$build";
return $version;
}
sub getVersion
{
my $key = shift;
my $value = `cat $propertiesFile | grep $key | awk -F= '{print \$2}'`;
chomp($value);
return $value;
}