forked from asterisk-java/asterisk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
triggerRelease.dart
executable file
·62 lines (54 loc) · 1.35 KB
/
triggerRelease.dart
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/env dshell
import 'dart:io';
import 'package:dshell/dshell.dart';
/// comment
void main() {
int major;
int minor;
int rev = 0;
var dir = dirname(Settings().scriptPath);
print(dir);
read(join(dir, "pom.xml")).forEach((line) {
if (line.contains("<releaseVersion>")) {
line = line.replaceFirst("-SNAPSHOT", "");
var parts = line.split(".");
if (parts.length != 3) {
exit(1);
}
major = int.parse(parts[0].split(">")[1]);
minor = int.parse(parts[1]);
rev = int.parse(parts[2].split("<")[0]);
}
});
var postFix = "";
if (confirm(prompt: "Is this a SNAPSHOT release (y/n)?")) {
postFix = "-SNAPSHOT";
rev++;
} else {
rev = 0;
minor++;
}
String version = "$major.$minor.$rev$postFix";
replace(join(dir, "pom.xml"), version);
'git pull'.run;
'git add .'.run;
'git commit -m "for version $version"'.run;
'git tag -a $version -m "$version"'.run;
'git push origin'.run;
'git push origin tag $version'.run;
}
void replace(String path, String version) {
var tmp = '$path.tmp';
if (exists(tmp)) {
delete(tmp);
}
read(path).forEach((line) {
if (line.contains("<releaseVersion>")) {
line = " <releaseVersion>$version</releaseVersion>";
}
tmp.append(line);
});
move(path, '$path.bak');
move(tmp, path);
delete('$path.bak');
}