-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.pl
executable file
·132 lines (121 loc) · 3.32 KB
/
build.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
print "prepare codeine...\n";
my $propertiesFile = "src/common/codeine/version.properties";
updateVersionFile();
es("rm -rf dist");
es("rm -f codeine_*");
es("mkdir -p dist");
#es("bounce_minor_version.pl");
my $version = getVersionFull();
my $versionNoDate = getVersionNoDate();
unless (defined($ENV{INTEL_INSIDE}))
{
es("echo '{\"directory\": \"app/bower_components\"}' > deployment/http-root/ajs/.bowerrc");
}
$ENV{mvn} = "mvn" unless defined $ENV{mvn};
if (defined($ENV{INTEL_INSIDE}))
{
$ENV{http_proxy} = "http://proxy-chain.intel.com:911/";
$ENV{https_proxy} = "http://proxy-chain.intel.com:911/";
}
print "mvn is $ENV{mvn}\n";
if (defined($ENV{INTEL_INSIDE}))
{
es("$ENV{mvn} clean verify");
}
else
{
es("$ENV{mvn} clean package");
}
my $tar = "codeine_".getVersionNoDate().".tar.gz";
my $zip = "codeine_".getVersionNoDate().".zip";
if (defined($ENV{RELEASE_AREA}))
{
my $link = $ENV{RELEASE_AREA}."/codeine.latest.tar";
es("cp $tar $ENV{RELEASE_AREA}/");
system("rm $link");
es("ln -s $tar $link");
}
es("cp dist/bin/codeine.jar codeine.jar");
es("cp $propertiesFile version.properties");
unless ($ENV{'release-to-github'} eq "true")
{
exit(0);
}
print "Will release new version to Github: $versionNoDate\n";
my $githubUser = $ENV{GITHUB_USER};
my $githubPassword = $ENV{GITHUB_PASSWORD};
my $res = r("curl -k -X POST -u $githubUser:$githubPassword -H \"Content-Type: application/json\" -d '{ \"tag_name\": \"v$versionNoDate\", \"target_commitish\": \"master\", \"name\": \"v$versionNoDate\", \"body\": \"Codeine Release\", \"draft\": false, \"prerelease\": true}' https://api.github.com/repos/codeine-cd/codeine/releases");
print "release returned: $res\n";
$res =~ /\"id\":\s([^,]*)/;
my $id = $1;
print "release id: $id\n";
es("curl -X POST -u $githubUser:$githubPassword -H \"Content-Type: application/zip\" --data-binary \"\@$zip\" \"https://uploads.github.com/repos/codeine-cd/codeine/releases/$id/assets?name=codeine.zip\"");
print "Done!";
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 updateVersionFile
{
my $major = getVersion('major');
my $minor = getVersion('minor');
my $build = $ENV{BUILD_NUMBER};
my $date = getDate();
es("echo 'CodeineVersion.build=$build\nCodeineVersion.major=$major\nCodeineVersion.minor=$minor\n' > $propertiesFile");
}
sub getVersionFull
{
my $major = getVersion('major');
my $minor = getVersion('minor');
my $build = $ENV{BUILD_NUMBER} || getVersion('build');
my $date = getDate();
my $version = "$major.$minor.$build";
return $version;
}
sub getVersionNoDate
{
my $major = getVersion('major');
my $minor = getVersion('minor');
my $build = $ENV{BUILD_NUMBER} || getVersion('build');
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;
}
sub getDate
{
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
$year += 1900;
$mon += 1;
$mon = sprintf( "%02d", $mon );
$mday = sprintf( "%02d", $mday );
my $date = $year.$mon.$mday;
return $date;
}