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
131
132
133
134
135
136
137
138
139
140
141
142
|
#!/usr/bin/perl -w
use strict;
#
# NOTE: tested only with Jani Laakso's environment
#
# working directory to make releases
my $WORKDIR = "/home/jani/crypt/tk";
# directory prefix where release package zip file is stored
my $SVN_ROOT = "https://svn.itmill.com/svn/itmill-toolkit";
my $SVN_URL_BUILDS = $SVN_ROOT."/builds";
my $usage =
"Usage: $0 <branch> <version> <dir>\n".
" <branch> is new major.minor version, e.g. 4.0\n".
" <version> is new version, e.g. 4.0.1-rc3\n".
" <target> is directory to store release zip file, e.g. internal/4.0.1-rc/\n";
my $BRANCH = shift(@ARGV) || &failure($usage);
my $VERSION = shift(@ARGV) || &failure($usage);
my $TARGET = shift(@ARGV) || &failure($usage);
my $t = "";
if (!$BRANCH =~ /([4-9]{1}\.[0-9]{1})/) {
&failure ("\n<branch> must be format {x}.{y} where {x}=major (4-9), ".
"{y}=minor (0-9).\n");
}
if (
(!$VERSION =~ /[4-9]{1}\.[0-9]{1,2}.[0-9]{1,3}/) &&
(!$VERSION =~ /[4-9]{1}\.[0-9]{1,2}.[0-9]{1,3}-rc[0-9]{1,2}/)
) {
&failure ("\n<version> must be format {x}.{y}.{z} or x.y.z-rc{m} ".
"where {x}=major (4-9), {y}=minor (0-99), {z}=revision ".
"(0-999) and optional release candidate number {m}=(0-99).\n");
}
if (
(!$TARGET =~ /release\/[4-9]{1}\.[0-9]{1,2}.[0-9]{1,3}/) &&
(!$TARGET =~ /internal\/[4-9]{1}\.[0-9]{1,2}.[0-9]{1,3}-rc[0-9]{1,2}/)
) {
&failure ("\n<target> must be e.g. internal/4.0.1-rc/ or release/4.0.\n");
}
# Open log file
open(LOG, "> $WORKDIR/builds/$TARGET/itmill-toolkit-$VERSION.make.log");
# Make sure $WORKDIR directory exists
&message(
"\n BRANCH [$BRANCH]\n VERSION [$VERSION]\n".
" DIR [$SVN_URL_BUILDS/$TARGET]\n"
);
&message(" Initializing repositories ");
# go to directory where repository working copies (WC) are
chdir($WORKDIR) || &failure("Could not chdir to $WORKDIR.\n");
# delete old repo
&execute("rm -rf $BRANCH");
# checkout (if missing) build repository
&execute("svn co $SVN_ROOT/builds | grep \"Checked out\"");
# it's safest to replace 4.0 from trunk (but you could use also merging)
&execute(
"svn rm $SVN_ROOT/branches/$BRANCH ".
"-m \"Recreating $BRANCH branch from trunk. Removing old $BRANCH.\""
);
&execute(
"svn copy $SVN_ROOT/trunk $SVN_ROOT/branches/$BRANCH ".
"-m \"Recreating $BRANCH branch from trunk. Copying new $BRANCH.\""
);
# checkout $BRANCH
&execute("svn co $SVN_ROOT/branches/$BRANCH | grep \"Checked out\"");
&message(" Changing VERSION");
# go to $BRANCH directory
chdir("$WORKDIR/$BRANCH");
# fix links as VERSION changes
&execute(
"sed s/`cat build/VERSION | cut -f2 -d'='`/$VERSION/ ".
"index.html >/tmp/index.html"
);
&execute("diff index.html /tmp/index.html");
&execute("cp /tmp/index.html index.html");
# increment VERSION
&execute("echo \"version=$VERSION\" >build/VERSION");
&message(" Commit changes ");
# commit changes
&execute("svn ci -m \"Building $VERSION release.\"");
&message(" Executing ant ");
# execute build script, takes 5-40 minutes depending on hw
chdir("$WORKDIR/$BRANCH/build");
&execute("ant");
&message(" Copying branch 4.0 under tags branch");
# copy branch 4.0 into tags directory (some may interpret this as tagging)
&execute(
"svn copy $SVN_ROOT/branches/4.0 $SVN_ROOT/tags/$VERSION ".
"-m \"Copying $VERSION release into tags.\""
);
&message(" Committing release package zip file to builds dir ");
# commit release package zip to SVN
&execute("cp result/itmill-toolkit-$VERSION.zip $WORKDIR/builds/$TARGET");
chdir("$WORKDIR/builds/$TARGET");
&execute("svn add itmill-toolkit-$VERSION.zip");
&execute(
"svn ci itmill-toolkit-$VERSION.zip ".
"-m \"Added $VERSION release package.\""
);
&message(" Done ");
# store log to SVN
close(LOG);
`svn add $WORKDIR/builds/$TARGET/itmill-toolkit-$VERSION.make.log`;
`svn ci $WORKDIR/builds/$TARGET/itmill-toolkit-$VERSION.make.log -m \"Added $VERSION toolkit-release-make log file.\"`;
exit;
sub message() {
my $msg = shift;
$msg = "\n***".$msg."***\n";
print $msg;
print LOG $msg;
}
sub execute() {
my $cmd = shift;
print " $cmd\n";
print LOG " $cmd\n";
my $result = `$cmd`;
print $result."\n";
print LOG $result."\n";
}
sub failure() {
my $msg = shift;
print $msg."\n";
exit;
}
|