Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve, document and group versioning code in Build.scala #21837

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine since the payload in the reusable workflow is inherited from the caller (See https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_call)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested it in a custom repo, it worked as expected


jobs:
build:
Expand Down
62 changes: 38 additions & 24 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,39 @@ object Build {
*/
val referenceVersion = "3.6.0"

val baseVersion = "3.6.2"
// Will be required by some automation later
// TODO: Introduce automation and handling for RC versions before 3.6.2-RC1
// 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 @@ -117,7 +146,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`
* 3.6.1 is an exception from this rule - 3.6.0 was a broken release
Expand All @@ -144,7 +173,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 @@ -174,24 +203,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 @@ -2264,6 +2275,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
Loading