Skip to content

Commit

Permalink
Hotfix for reckon snapshot releases (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
orchestr7 authored Nov 11, 2024
1 parent fbbb770 commit f44b943
Showing 1 changed file with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ fun Project.configureVersioning() {

val isSnapshot = hasProperty("reckon.stage") && property("reckon.stage") == "snapshot"
configure<ReckonExtension> {
scopeFromProp()
setDefaultInferredScope("patch")
if (isSnapshot) {
// we should build snapshots only for snapshot publishing, so it requires explicit parameter
snapshotFromProp()
snapshots()
} else {
stageFromProp("alpha", "rc", "final")
stages("alpha", "rc", "final")
}
setScopeCalc(calcScopeFromProp().or(calcScopeFromCommitMessages()))
setStageCalc(calcStageFromProp())
}

// to activate release, provide `-Prelease` or `-Prelease=true`. To deactivate, either omit the property, or set `-Prelease=false`.
Expand All @@ -44,17 +45,4 @@ fun Project.configureVersioning() {
)
}
}
if (isSnapshot) {
val grgit = project.findProperty("grgit") as Grgit // grgit property is added by reckon plugin
// A terrible hack to remove all pre-release tags. Because in semver `0.1.0-SNAPSHOT` < `0.1.0-alpha`, in snapshot mode
// we remove tags like `0.1.0-alpha`, and then reckoned version will still be `0.1.0-SNAPSHOT` and it will be compliant.
val preReleaseTagNames = grgit.tag.list()
.sortedByDescending { it.commit.dateTime }
.takeWhile {
// take latest tags that are pre-release
!it.name.matches(Regex("""^v\d+\.\d+\.\d+$"""))
}
.map { it.name }
grgit.tag.remove { this.names = preReleaseTagNames }
}
}

0 comments on commit f44b943

Please sign in to comment.