@@ -11,19 +11,15 @@ case class PublishHelper()(using
11
11
publishConfig : Option [PublishConfig ]
12
12
) extends Helpers :
13
13
14
+ import PublishHelper .*
15
+
14
16
def publish (version : String ): Unit =
15
17
println(s " Publishing BPF Package: $version" )
16
- // TODO uncomment: verifySnapshots()
18
+ verifyVersion(version)
19
+ verifySnapshots()
17
20
verifyChangelog(version)
18
21
pushDevelop()
19
22
setApiVersion(version)
20
-
21
- val releaseVersion = """ ^(\d+)\.(\d+)\.(\d+)(-.*)?$"""
22
- if ! version.matches(releaseVersion) then
23
- throw new IllegalArgumentException (
24
- " Your Version has not the expected format (2.1.2(-SNAPSHOT))"
25
- )
26
-
27
23
replaceVersion(version)
28
24
29
25
lazy val sbtProcs = Seq (
@@ -49,27 +45,8 @@ case class PublishHelper()(using
49
45
val isSnapshot = version.contains(" -" )
50
46
if ! isSnapshot then
51
47
publishToWebserver()
48
+ git(version, replaceVersion)
52
49
53
- os.proc(" git" , " fetch" , " --all" ).callOnConsole()
54
- os.proc(" git" , " commit" , " -a" , " -m" , s " Released Version $version" )
55
- .callOnConsole()
56
- os.proc(" git" , " tag" , " -a" , " --no-sign" , s " v $version" , " -m" , s " Version $version" )
57
- .callOnConsole()
58
- os.proc(" git" , " checkout" , " master" ).callOnConsole()
59
- os.proc(" git" , " merge" , branch).callOnConsole()
60
- os.proc(" git" , " push" , " --tags" ).callOnConsole()
61
- os.proc(" git" , " checkout" , branch).callOnConsole()
62
- val Pattern = """ ^(\d+)\.(\d+)\.(\d+)$""" .r
63
-
64
- val newVersion = version match
65
- case Pattern (major, minor, _) =>
66
- s " $major. ${minor.toInt + 1 }.0-SNAPSHOT "
67
- replaceVersion(newVersion)
68
-
69
- os.proc(" git" , " commit" , " -a" , " -m" , s " Init new Version $newVersion" )
70
- .callOnConsole()
71
- os.proc(" git" , " push" , " --all" ).callOnConsole()
72
- println(s " Published Version: $version" )
73
50
end if
74
51
end publish
75
52
@@ -86,29 +63,38 @@ case class PublishHelper()(using
86
63
87
64
os.write.over(apiFile, updatedFile)
88
65
89
- private val projectFile : os.Path = workDir / " project" / " ProjectDef.scala"
90
-
91
66
private def replaceVersion (newVersion : String ): Unit =
92
- replaceVersion(newVersion, projectFile)
93
- replaceVersion(newVersion, apiConfig.projectConfPath)
94
- end replaceVersion
95
-
96
- private def replaceVersion (newVersion : String , versionFile : os.Path ): Unit =
97
- val versionFileStr = os.read(versionFile)
98
-
99
- val regexPattern = """ version = "(\d+\.\d+\.\d+(-.+)?)""""
100
- val updatedFile = versionFileStr
101
- .replaceAll(regexPattern, s """ version = " $newVersion" """ ) + " \n "
102
-
103
- os.write.over(versionFile, updatedFile)
67
+ PublishHelper .replaceVersion(newVersion, projectFile)
68
+ PublishHelper .replaceVersion(newVersion, apiConfig.projectConfPath)
104
69
end replaceVersion
105
70
106
71
private def publishToWebserver (): Unit =
107
72
// push it to Documentation Webserver
108
73
publishConfig.foreach:
109
74
ProjectWebDAV (devConfig.projectName, _).upload()
110
75
111
- private def verifySnapshots (): Unit =
76
+ end PublishHelper
77
+
78
+ object PublishHelper extends Helpers :
79
+ val projectFile : os.Path = workDir / " project" / " ProjectDef.scala"
80
+
81
+ def verifyVersion (newVersion : String ): Unit =
82
+ val releaseVersion = """ ^(\d+)\.(\d+)\.(\d+)(-.*)?$"""
83
+ if ! newVersion.matches(releaseVersion) then
84
+ throw new IllegalArgumentException (
85
+ " Your Version has not the expected format (2.1.2(-SNAPSHOT))"
86
+ )
87
+ end verifyVersion
88
+
89
+ def verifyChangelog (newVersion : String ): Unit =
90
+ ChangeLogUpdater .verifyChangelog(
91
+ newVersion,
92
+ commitsAddress = _.replace(" .git" , " /commit/" ) // git
93
+ .replace(" ssh://git@" , " https://" ) // ssh protocol
94
+ .replace(" :2222" , " " ) // ssh port
95
+ )
96
+
97
+ def verifySnapshots (): Unit =
112
98
hasSnapshots(" Settings" )
113
99
hasSnapshots(" ProjectDef" )
114
100
@@ -120,16 +106,42 @@ case class PublishHelper()(using
120
106
s " There are SNAPSHOT dependencies in `project/ $fileName.scala` "
121
107
)
122
108
123
- private def verifyChangelog (newVersion : String ): Unit =
124
- ChangeLogUpdater .verifyChangelog(
125
- newVersion,
126
- commitsAddress = _.replace(" .git" , " /commit/" ) // git
127
- .replace(" ssh://git@" , " https://" ) // ssh protocol
128
- .replace(" :2222" , " " ) // ssh port
129
- )
130
- // as projectUpdate for reference creation gets the newest changes from remote
131
- private def pushDevelop (): Unit =
109
+ // as projectUpdate for reference creation gets the newest changes from remote
110
+ def pushDevelop (): Unit =
132
111
os.proc(" git" , " push" ).callOnConsole()
133
112
134
- private lazy val branch = " develop"
113
+ def replaceVersion (newVersion : String , versionFile : os.Path ): Unit =
114
+ val versionFileStr = os.read(versionFile)
115
+
116
+ val regexPattern = """ version = "(\d+\.\d+\.\d+(-.+)?)""""
117
+ val updatedFile = versionFileStr
118
+ .replaceAll(regexPattern, s """ version = " $newVersion" """ ) + " \n "
119
+
120
+ os.write.over(versionFile, updatedFile)
121
+ end replaceVersion
122
+
123
+ def git (version : String , replaceVersion : String => Unit ): Unit =
124
+ val branch = " develop"
125
+ os.proc(" git" , " fetch" , " --all" ).callOnConsole()
126
+ os.proc(" git" , " commit" , " -a" , " -m" , s " Released Version $version" )
127
+ .callOnConsole()
128
+ os.proc(" git" , " tag" , " -a" , " --no-sign" , s " v $version" , " -m" , s " Version $version" )
129
+ .callOnConsole()
130
+ os.proc(" git" , " checkout" , " master" ).callOnConsole()
131
+ os.proc(" git" , " merge" , branch).callOnConsole()
132
+ os.proc(" git" , " push" , " --tags" ).callOnConsole()
133
+ os.proc(" git" , " checkout" , branch).callOnConsole()
134
+ val Pattern = """ ^(\d+)\.(\d+)\.(\d+)$""" .r
135
+
136
+ val newVersion = version match
137
+ case Pattern (major, minor, _) =>
138
+ s " $major. ${minor.toInt + 1 }.0-SNAPSHOT "
139
+ replaceVersion(newVersion)
140
+
141
+ os.proc(" git" , " commit" , " -a" , " -m" , s " Init new Version $newVersion" )
142
+ .callOnConsole()
143
+ os.proc(" git" , " push" , " --all" ).callOnConsole()
144
+ println(s " Published Version: $version" )
145
+ end git
146
+
135
147
end PublishHelper
0 commit comments