Skip to content

Commit d77167d

Browse files
authored
GitHub Actions config: avoid duplicating Scala version numbers (#546)
by using new sbt 1.7 feature
1 parent 33feb8d commit d77167d

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
java: [8, 11, 17]
14-
scala: [2.11.12, 2.12.15, 2.13.8, 3.0.2]
14+
scala: [2.11.x, 2.12.x, 2.13.x, 3.0.x]
1515
platform: [jvm, js, native]
1616
mode: [normal]
1717
exclude:
18-
- scala: 3.0.2
18+
- scala: 3.0.x
1919
platform: native
2020
- java: 11
2121
platform: js
@@ -27,27 +27,27 @@ jobs:
2727
platform: native
2828
include:
2929
- java: 8
30-
scala: 2.12.15
30+
scala: 2.12.x
3131
mode: testScalafix
3232
platform: jvm
3333
- java: 8
34-
scala: 2.12.15
34+
scala: 2.12.x
3535
mode: testBinaryCompat
3636
platform: jvm
3737
- java: 8
38-
scala: 2.12.15
38+
scala: 2.12.x
3939
mode: testScalafmt
4040
platform: jvm
4141
- java: 8
42-
scala: 2.12.15
42+
scala: 2.12.x
4343
mode: headerCheck
4444
platform: jvm
4545
- java: 11
46-
scala: 2.12.15
46+
scala: 2.12.x
4747
mode: normal
4848
platform: jvm
4949
- java: 17
50-
scala: 2.12.15
50+
scala: 2.12.x
5151
mode: normal
5252
platform: jvm
5353
runs-on: ubuntu-latest

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ inThisBuild {
372372

373373
val platformSuffix = if (isScalaJs) "JS" else if (isScalaNative) "Native" else ""
374374

375-
val compatProject = "compat" + ciScalaVersion.get.binary + platformSuffix
375+
val compatProject = s"compat${ciScalaVersion.get}$platformSuffix"
376376
val binaryCompatProject = "binaryCompat"
377377

378378
val testProjectPrefix =
@@ -394,7 +394,7 @@ inThisBuild {
394394
}
395395

396396
Seq(
397-
List(s"""++${sys.env.get("CI_SCALA_VERSION").get}!"""),
397+
List(s"""++${sys.env.get("CI_SCALA_VERSION").get}"""),
398398
List(s"$projectPrefix/clean"),
399399
List(s"$testProjectPrefix/test"),
400400
List(s"$projectPrefix/publishLocal"),

project/Version.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
case class Version(major: Int, minor: Int, patch: Int) {
2-
def binary: String = s"${major}${minor}"
3-
override def toString: String = s"${major}.${minor}.${patch}"
1+
case class Version(major: Int, minor: Int) {
2+
override def toString = s"${major}${minor}"
43
}
54

65
object Version {
7-
// the (#.+)? part allows republishing for a new Scala version
8-
private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:#.+)?".r
9-
private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.+)(?:#.+)?".r
6+
// `(#.+)?` allows republishing for a new Scala version
7+
// `|x` allows the sbt 1.7 style ".x" versions
8+
private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+|x)(?:#.+)?".r
9+
private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+|x)-(.+)(?:#.+)?".r
1010
private val versionRegex2 = "([0-9]+)\\.([0-9]+)(?:#.+)?".r
1111
private val versionRegex3 = "([0-9]+)(?:#.+)?".r
1212
def parse(raw: String): Option[Version] = {
1313
raw match {
14-
case versionRegex0(major, minor, patch) =>
15-
Some(Version(major.toInt, minor.toInt, patch.toInt))
16-
case versionRegex1(major, minor, patch, _) =>
17-
Some(Version(major.toInt, minor.toInt, patch.toInt))
14+
case versionRegex0(major, minor, _) =>
15+
Some(Version(major.toInt, minor.toInt))
16+
case versionRegex1(major, minor, _, _) =>
17+
Some(Version(major.toInt, minor.toInt))
1818
case versionRegex2(major, minor) =>
19-
Some(Version(major.toInt, minor.toInt, 0))
19+
Some(Version(major.toInt, minor.toInt))
2020
case versionRegex3(major) =>
21-
Some(Version(major.toInt, 0, 0))
21+
Some(Version(major.toInt, 0))
2222
case _ =>
2323
None
2424
}

0 commit comments

Comments
 (0)