Skip to content

Commit 11c957c

Browse files
[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
1 parent 7f47867 commit 11c957c

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
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-24
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,39 @@ object Build {
9999
*/
100100
val referenceVersion = "3.6.0"
101101

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

107136
// LTS or Next
108137
val versionLine = "Next"
@@ -117,7 +146,7 @@ object Build {
117146
/** Minor version against which we check binary compatibility.
118147
*
119148
* This must be the earliest published release in the same versioning line.
120-
* For a baseVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
149+
* For a developedVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
121150
* - `3.M.0` if `P > 0`
122151
* - `3.(M-1).0` if `P = 0`
123152
* 3.6.1 is an exception from this rule - 3.6.0 was a broken release
@@ -144,7 +173,7 @@ object Build {
144173

145174
val compatMode = {
146175
val VersionRE = """^\d+\.(\d+)\.(\d+)""".r
147-
baseVersion match {
176+
developedVersion match {
148177
case VersionRE(_, "0") => CompatMode.BinaryCompatible
149178
case _ => CompatMode.SourceAndBinaryCompatible
150179
}
@@ -174,24 +203,6 @@ object Build {
174203
val dottyGithubUrl = "https://github.com/scala/scala3"
175204
val dottyGithubRawUserContentUrl = "https://raw.githubusercontent.com/scala/scala3"
176205

177-
178-
val isRelease = sys.env.get("RELEASEBUILD") == Some("yes")
179-
180-
val dottyVersion = {
181-
def isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
182-
if (isRelease)
183-
baseVersion
184-
else if (isNightly)
185-
baseVersion + "-RC1-bin-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY"
186-
else
187-
baseVersion + "-RC1-bin-SNAPSHOT"
188-
}
189-
val dottyNonBootstrappedVersion = {
190-
// Make sure sbt always computes the scalaBinaryVersion correctly
191-
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
192-
dottyVersion + bin + "-nonbootstrapped"
193-
}
194-
195206
val sbtCommunityBuildVersion = "0.1.0-SNAPSHOT"
196207

197208
val agentOptions = List(
@@ -2274,6 +2285,9 @@ object Build {
22742285
)
22752286
.settings(
22762287
Windows / name := "scala",
2288+
// Windows/version is used to create ProductInfo - it requires a version without any -RC suffixes
2289+
// If not explicitly overriden it would try to use `dottyVersion` assigned to `dist-win-x86_64/version`
2290+
Windows / version := developedVersion,
22772291
Windows / mappings := (Universal / mappings).value,
22782292
Windows / packageBin := (Windows / packageBin).dependsOn(republish).value,
22792293
Windows / wixFiles := (Windows / wixFiles).dependsOn(republish).value,

0 commit comments

Comments
 (0)