Skip to content

Commit

Permalink
Merge pull request #4168 from ZacSharp/pr/build/1.19.4/improvedVersio…
Browse files Browse the repository at this point in the history
…nDetection

Improve version detection
  • Loading branch information
leijurv authored Oct 31, 2023
2 parents 1409c92 + 9accb2b commit ea964a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -Pmod_version="$(git describe --always --tags | cut -c2-)"
run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)"

- name: Archive Artifacts
uses: actions/upload-artifact@v3
Expand Down
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ allprojects {
apply plugin: "maven-publish"

archivesBaseName = rootProject.archives_base_name
def vers = 'git describe --always --tags --dirty'.execute().text.trim()
def vers = ""
try {
vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim()
} catch (Exception e) {
println "Version detection failed: " + e
}
if (!vers.startsWith("v")) {
println "git doesn't appear to be installed!"
println "using version number: " + rootProject.mod_version
version = rootProject.mod_version
} else {
version = vers.substring(1)
println "Detected version " + version
}
group = rootProject.maven_group

Expand Down

0 comments on commit ea964a9

Please sign in to comment.