-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Use commit-and-tag-version for Release Management
- Loading branch information
Showing
10 changed files
with
775 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"bumpFiles": [ | ||
{ | ||
"filename": "version", | ||
"type": "plain-text" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
buildSrc/src/main/kotlin/org/eclipse/kuksa/util/Version.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package org.eclipse.kuksa.util | ||
|
||
import java.util.Locale | ||
|
||
class Version(semanticVersion: String) { | ||
|
||
val major: Int | ||
|
||
val minor: Int | ||
|
||
val patch: Int | ||
|
||
var suffix: String = "" | ||
|
||
val version: String | ||
get() { | ||
var version = "$major.$minor.$patch" | ||
if (suffix.isNotEmpty()) { | ||
version += "-$suffix" | ||
} | ||
return version | ||
} | ||
|
||
val versionCode: Int | ||
get() { | ||
val decorator = "10" | ||
val paddedMajorVersion = String.format(Locale.ROOT, "%02d", major) | ||
val paddedMinorVersion = String.format(Locale.ROOT, "%02d", minor) | ||
val paddedPatchVersion = String.format(Locale.ROOT, "%02d", patch) | ||
|
||
return "$decorator$paddedMajorVersion$paddedMinorVersion$paddedPatchVersion".toInt() | ||
} | ||
|
||
init { | ||
val versions = semanticVersion.trim().split(".") | ||
major = versions[0].toInt() | ||
minor = versions[1].toInt() | ||
patch = versions[2].toInt() | ||
} | ||
} |
102 changes: 0 additions & 102 deletions
102
buildSrc/src/main/kotlin/org/eclipse/kuksa/util/VersionProperties.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,42 @@ | ||
import org.eclipse.kuksa.util.VersionProperties | ||
import org.eclipse.kuksa.util.Version | ||
|
||
val properties = VersionProperties("$rootDir/version.properties") | ||
properties.load() | ||
val file = File("$rootDir/version") | ||
val semanticVersion = file.readText() | ||
val version = Version(semanticVersion) | ||
|
||
rootProject.extra["projectVersion"] = properties.version | ||
rootProject.extra["projectVersionCode"] = properties.versionCode | ||
|
||
tasks.register("increaseMajorVersion") { | ||
group = "version" | ||
doLast { | ||
properties.major += 1 | ||
properties.minor = 0 | ||
properties.patch = 0 | ||
properties.store() | ||
} | ||
} | ||
|
||
tasks.register("increaseMinorVersion") { | ||
group = "version" | ||
doLast { | ||
properties.minor += 1 | ||
properties.patch = 0 | ||
properties.store() | ||
} | ||
} | ||
|
||
tasks.register("increasePatchVersion") { | ||
group = "version" | ||
doLast { | ||
properties.patch += 1 | ||
properties.store() | ||
} | ||
} | ||
updateExtras() | ||
|
||
tasks.register("setReleaseVersion") { | ||
group = "version" | ||
doLast { | ||
properties.suffix = "" | ||
properties.store() | ||
version.suffix = "" | ||
|
||
updateExtras() | ||
} | ||
} | ||
|
||
tasks.register("setSnapshotVersion") { | ||
group = "version" | ||
doLast { | ||
properties.suffix = "SNAPSHOT" | ||
properties.store() | ||
version.suffix = "SNAPSHOT" | ||
|
||
updateExtras() | ||
} | ||
} | ||
|
||
tasks.register("printVersion") { | ||
group = "version" | ||
doLast { | ||
val version = properties.version | ||
val version = version.version | ||
|
||
println("VERSION=$version") | ||
} | ||
|
||
mustRunAfter("setReleaseVersion", "setSnapshotVersion") | ||
} | ||
|
||
tasks.register("printVersionCode") { | ||
group = "version" | ||
doLast { | ||
val versionCode = properties.versionCode | ||
|
||
println("VERSION_CODE=$versionCode") | ||
} | ||
fun updateExtras() { | ||
rootProject.extra["projectVersion"] = version.version | ||
rootProject.extra["projectVersionCode"] = version.versionCode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// standard-version-updater.js | ||
const stringifyPackage = require('stringify-package') | ||
const detectIndent = require('detect-indent') | ||
const detectNewline = require('detect-newline') | ||
|
||
module.exports.readVersion = function (contents) { | ||
return JSON.parse(contents).tracker.package.version; | ||
} | ||
|
||
module.exports.writeVersion = function (contents, version) { | ||
const versions = version.split(".") | ||
const major = versions[0] | ||
const minor = versions[1] | ||
const patch = versions[2] | ||
|
||
return `MAJOR=${major} | ||
MINOR=${minor} | ||
PATCH=${PATCH}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.