Skip to content

Commit adafab4

Browse files
authored
Pull project version from latest Git tag (#24)
Since overhauling Pioneer's Shipkit configuration, the file `version.properties` no longer exists and so we can't use it to determine the project version. Instead, we use Git tags (latest tag by date, to be precise). Issue: 🙈 PR: #24
1 parent 404c623 commit adafab4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

build.gradle

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// SETUP
33
// -----
44

5+
plugins {
6+
id 'org.ajoberstar.grgit' version '4.1.0'
7+
}
8+
59
ext {
610
onCi = System.getenv("CI")
711
}
@@ -115,10 +119,18 @@ task insertVersion() {
115119
}
116120
}
117121

122+
import org.ajoberstar.grgit.Tag
118123
def insertProjectVersion(String project, String abbreviation) {
119-
Properties properties = new Properties()
120-
file("${project}/version.properties").withInputStream { properties.load(it) }
121-
String version = properties.previousVersion
124+
String latestTagName = grgit
125+
.open(dir: project)
126+
.tag.list()
127+
.sort { it.commit.dateTime }
128+
.last()
129+
.name
130+
if (!latestTagName?.startsWith("v"))
131+
throw new IllegalStateException("Could not determine version of @${project}.")
132+
String version = latestTagName.substring(1)
133+
122134
File about = file("site-source/_pages/${abbreviation}.adoc")
123135
String aboutText = about.getText()
124136
String aboutTextWithVersion = aboutText.replaceAll("@${abbreviation}:version", version)

0 commit comments

Comments
 (0)