Skip to content

Commit e8bb221

Browse files
committed
Set version from changelog
1 parent 5c1000e commit e8bb221

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

build.gradle.kts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,23 @@ plugins {
4343
id("org.jetbrains.changelog") version "2.2.0" // Gradle Changelog Plugin
4444
}
4545

46-
var flutterPluginVersion = providers.gradleProperty("flutterPluginVersion").get()
47-
if (project.hasProperty("dev")) {
46+
// By default (e.g. when we call `runIde` during development), the plugin version is SNAPSHOT
47+
var flutterPluginVersion = "SNAPSHOT"
48+
49+
// Otherwise, we will decide on the proper semver-formatted version from the CHANGELOG.
50+
// Note: The CHANGELOG follows the style from https://keepachangelog.com/en/1.0.0/ so that we can use the gradle changelog plugin.
51+
if (project.hasProperty("release")) {
52+
// If we are building for a release, the changelog should be updated with the latest version.
53+
flutterPluginVersion = changelog.getLatest().version
54+
} else if (project.hasProperty("dev")) {
55+
// If we are building the dev version, the version label will increment the latest version from the changelog and append the date.
4856
val latestVersion = changelog.getLatest().version
4957
val majorVersion = latestVersion.substringBefore('.').toInt()
5058
val nextMajorVersion = majorVersion + 1
5159
val datestamp = DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now())
5260
flutterPluginVersion = "$nextMajorVersion.0.0-dev.$datestamp"
5361
}
62+
5463
val ideaVersion = providers.gradleProperty("ideaVersion").get()
5564
val dartPluginVersion = providers.gradleProperty("dartPluginVersion").get()
5665
val sinceBuildInput = providers.gradleProperty("sinceBuild").get()

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# found in the LICENSE file.
55
#
66

7-
# Change to version when releasing, e.g.
8-
#flutterPluginVersion=87.0.1
9-
flutterPluginVersion=SNAPSHOT
107
ideaVersion=2025.1.3.4
118
dartPluginVersion= 251.27623.5
129
sinceBuild=243

0 commit comments

Comments
 (0)