Skip to content

Commit

Permalink
[build] Improve, document and group versioning code in Build.scala (#…
Browse files Browse the repository at this point in the history
…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]
  • Loading branch information
WojciechMazur committed Nov 6, 2024
1 parent 07583a1 commit 148b10f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-msi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ on:
workflow_call:

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

jobs:
build:
Expand Down
61 changes: 38 additions & 23 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,39 @@ object Build {

val referenceVersion = "3.5.2"

val baseVersion = "3.6.2"
// Will be required by some automation later
// val prereleaseVersion = s"$baseVersion-RC1"
/** Version of the Scala compiler targeted in the current release cycle
* Contains a version without RC/SNAPSHOT/NIGHTLY specific suffixes
* Should be updated ONLY after release or cutoff for previous release cycle.
*
* Should only be referred from `dottyVersion` or settings/tasks requiring simplified version string,
* eg. `compatMode` or Windows native distribution version.
*/
val developedVersion = "3.6.2"

/** The version of the compiler including the RC prefix.
* Defined as common base before calculating environment specific suffixes in `dottyVersion`
*
* By default, during development cycle defined as `${developedVersion}-RC1`;
* During release candidate cycle incremented by the release officer before publishing a subsequent RC version;
* During final, stable release is set exactly to `developedVersion`.
*/
val baseVersion = s"$developedVersion-RC1"

/** Final version of Scala compiler, controlled by environment variables. */
val dottyVersion = {
if (isRelease) baseVersion
else if (isNightly) s"${baseVersion}-bin-${VersionUtil.commitDate}-${VersionUtil.gitHash}-NIGHTLY"
else s"${baseVersion}-bin-SNAPSHOT"
}
def isRelease = sys.env.get("RELEASEBUILD").contains("yes")
def isNightly = sys.env.get("NIGHTLYBUILD").contains("yes")

/** Version calculate for `nonbootstrapped` projects */
val dottyNonBootstrappedVersion = {
// Make sure sbt always computes the scalaBinaryVersion correctly
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
dottyVersion + bin + "-nonbootstrapped"
}

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

val compatMode = {
val VersionRE = """^\d+\.(\d+)\.(\d+)""".r
baseVersion match {
developedVersion match {
case VersionRE(_, "0") => CompatMode.BinaryCompatible
case _ => CompatMode.SourceAndBinaryCompatible
}
Expand Down Expand Up @@ -166,24 +196,6 @@ object Build {
val dottyGithubUrl = "https://github.com/scala/scala3"
val dottyGithubRawUserContentUrl = "https://raw.githubusercontent.com/scala/scala3"


val isRelease = sys.env.get("RELEASEBUILD") == Some("yes")

val dottyVersion = {
def isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
if (isRelease)
baseVersion
else if (isNightly)
baseVersion + "-RC1-bin-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY"
else
baseVersion + "-RC1-bin-SNAPSHOT"
}
val dottyNonBootstrappedVersion = {
// Make sure sbt always computes the scalaBinaryVersion correctly
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
dottyVersion + bin + "-nonbootstrapped"
}

val sbtCommunityBuildVersion = "0.1.0-SNAPSHOT"

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

0 comments on commit 148b10f

Please sign in to comment.