Skip to content

Commit 148b10f

Browse files
committed
[build] Improve, document and group versioning code in Build.scala (#21837)
* Introduce `developedVersion` describing the target for the current release cycle * Adapt `baseVersion` to the effectively revert #21011 changes * Adapt .msi packager to use `developedVersion` as a workaround to MSI ProductInfo limitations (version without RC suffix required) * Group and document versioning related code [Cherry-picked 11c957c][modified]
1 parent 07583a1 commit 148b10f

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

.github/workflows/build-msi.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414
workflow_call:
1515

1616
env:
17-
# NECESSARY FLAG TO CORRECTLY CONFIGURE THE VERSION FOR SCALA
18-
RELEASEBUILD: yes
17+
# Release only happends when triggering CI by pushing tag
18+
RELEASEBUILD: ${{ startsWith(github.event.ref, 'refs/tags/') && 'yes' || 'no' }}
1919

2020
jobs:
2121
build:

project/Build.scala

+38-23
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,39 @@ object Build {
9393

9494
val referenceVersion = "3.5.2"
9595

96-
val baseVersion = "3.6.2"
97-
// Will be required by some automation later
98-
// val prereleaseVersion = s"$baseVersion-RC1"
96+
/** Version of the Scala compiler targeted in the current release cycle
97+
* Contains a version without RC/SNAPSHOT/NIGHTLY specific suffixes
98+
* Should be updated ONLY after release or cutoff for previous release cycle.
99+
*
100+
* Should only be referred from `dottyVersion` or settings/tasks requiring simplified version string,
101+
* eg. `compatMode` or Windows native distribution version.
102+
*/
103+
val developedVersion = "3.6.2"
104+
105+
/** The version of the compiler including the RC prefix.
106+
* Defined as common base before calculating environment specific suffixes in `dottyVersion`
107+
*
108+
* By default, during development cycle defined as `${developedVersion}-RC1`;
109+
* During release candidate cycle incremented by the release officer before publishing a subsequent RC version;
110+
* During final, stable release is set exactly to `developedVersion`.
111+
*/
112+
val baseVersion = s"$developedVersion-RC1"
113+
114+
/** Final version of Scala compiler, controlled by environment variables. */
115+
val dottyVersion = {
116+
if (isRelease) baseVersion
117+
else if (isNightly) s"${baseVersion}-bin-${VersionUtil.commitDate}-${VersionUtil.gitHash}-NIGHTLY"
118+
else s"${baseVersion}-bin-SNAPSHOT"
119+
}
120+
def isRelease = sys.env.get("RELEASEBUILD").contains("yes")
121+
def isNightly = sys.env.get("NIGHTLYBUILD").contains("yes")
122+
123+
/** Version calculate for `nonbootstrapped` projects */
124+
val dottyNonBootstrappedVersion = {
125+
// Make sure sbt always computes the scalaBinaryVersion correctly
126+
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
127+
dottyVersion + bin + "-nonbootstrapped"
128+
}
99129

100130
// LTS or Next
101131
val versionLine = "Next"
@@ -110,7 +140,7 @@ object Build {
110140
/** Minor version against which we check binary compatibility.
111141
*
112142
* This must be the earliest published release in the same versioning line.
113-
* For a baseVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
143+
* For a developedVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
114144
* - `3.M.0` if `P > 0`
115145
* - `3.(M-1).0` if `P = 0`
116146
*/
@@ -136,7 +166,7 @@ object Build {
136166

137167
val compatMode = {
138168
val VersionRE = """^\d+\.(\d+)\.(\d+)""".r
139-
baseVersion match {
169+
developedVersion match {
140170
case VersionRE(_, "0") => CompatMode.BinaryCompatible
141171
case _ => CompatMode.SourceAndBinaryCompatible
142172
}
@@ -166,24 +196,6 @@ object Build {
166196
val dottyGithubUrl = "https://github.com/scala/scala3"
167197
val dottyGithubRawUserContentUrl = "https://raw.githubusercontent.com/scala/scala3"
168198

169-
170-
val isRelease = sys.env.get("RELEASEBUILD") == Some("yes")
171-
172-
val dottyVersion = {
173-
def isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
174-
if (isRelease)
175-
baseVersion
176-
else if (isNightly)
177-
baseVersion + "-RC1-bin-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY"
178-
else
179-
baseVersion + "-RC1-bin-SNAPSHOT"
180-
}
181-
val dottyNonBootstrappedVersion = {
182-
// Make sure sbt always computes the scalaBinaryVersion correctly
183-
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
184-
dottyVersion + bin + "-nonbootstrapped"
185-
}
186-
187199
val sbtCommunityBuildVersion = "0.1.0-SNAPSHOT"
188200

189201
val agentOptions = List(
@@ -2235,6 +2247,9 @@ object Build {
22352247
)
22362248
.settings(
22372249
Windows / name := "scala",
2250+
// Windows/version is used to create ProductInfo - it requires a version without any -RC suffixes
2251+
// If not explicitly overriden it would try to use `dottyVersion` assigned to `dist-win-x86_64/version`
2252+
Windows / version := developedVersion,
22382253
Windows / mappings := (Universal / mappings).value,
22392254
Windows / packageBin := (Windows / packageBin).dependsOn(republish).value,
22402255
Windows / wixFiles := (Windows / wixFiles).dependsOn(republish).value,

0 commit comments

Comments
 (0)