Skip to content

Commit a69649b

Browse files
authored
Merge pull request #39 from mzuehlke/update-using-string-replace
2 parents 8d658e0 + fbd7bb2 commit a69649b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

build.sbt

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
import java.util.regex.Pattern
2+
13
TaskKey[Unit]("updateYml") := {
2-
import scala.sys.process.Process
34

4-
Process("yq", Seq("e", "-i", s""".inputs.sbt-runner-version.default = "${sbtVersion.value}"""", "action.yml")).!
5+
val location = baseDirectory.value / "action.yml"
6+
val oldContent = IO.read(location)
7+
8+
val matcher = Pattern.compile("default: (.+)$", Pattern.MULTILINE).matcher(oldContent)
9+
if (matcher.find) {
10+
val oldVersion = matcher.group(1)
11+
val updatedContent = oldContent.replace(s"default: $oldVersion", s"default: ${sbtVersion.value}")
12+
IO.write(location, updatedContent)
13+
}
514
}

0 commit comments

Comments
 (0)