forked from asterisk-java/asterisk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriggerRelease.dart
More file actions
executable file
·76 lines (66 loc) · 1.7 KB
/
triggerRelease.dart
File metadata and controls
executable file
·76 lines (66 loc) · 1.7 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /usr/bin/env dcli
import 'dart:io';
import 'package:dcli/dcli.dart';
/// comment
void main() {
int major = 0;
int minor = 0;
int rev = 0;
var dir = dirname(Script.current.pathToScript);
print(dir);
read(join(dir, "pom.xml")).forEach((line) {
if (line.contains("<releaseVersion>")) {
line = line.replaceFirst("-SNAPSHOT", "");
line = line.replaceFirst("-nj", "");
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 = "-nj";
rev = 0;
minor++;
String version = "$major.$minor.$rev$postFix";
replacePomVersion(join(dir, "pom.xml"), version);
replaceReadMeVersion(join(dir, "README.md"), 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 replaceReadMeVersion(String path, String version) {
var tmp = '$path.tmp';
if (exists(tmp)) {
delete(tmp);
}
read(path).forEach((line) {
if (line.contains("<version>")) {
line = " <version>$version</version>";
}
tmp.append(line);
});
move(path, '$path.bak');
move(tmp, path);
delete('$path.bak');
}
void replacePomVersion(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');
}