Skip to content

Commit

Permalink
Merge pull request #2 from chrisjenx/cj/fixes
Browse files Browse the repository at this point in the history
Cj/fixes
  • Loading branch information
chrisjenx authored Jul 26, 2024
2 parents aa0f44c + a7d7c2c commit 38c2ba7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get tags
run: git fetch --tags origin
- name: Setup Java JDK
uses: actions/[email protected]
with:
Expand All @@ -38,6 +40,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get tags
run: git fetch --tags origin
- name: Setup Java JDK
uses: actions/[email protected]
with:
Expand All @@ -60,6 +64,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get tags
run: git fetch --tags origin
- name: Setup Java JDK
uses: actions/[email protected]
with:
Expand Down
21 changes: 16 additions & 5 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,29 @@ publishing {
}

@Suppress("UnstableApiUsage")
val gitCurrentTag = providers.exec { commandLine("git", "describe", "--abbrev=0", "--tags") }
.standardOutput.asText.map { it.trim() }
private val gitRevListTags = providers.exec {
commandLine("git", "rev-list", "--tags", "--max-count=1")
}.standardOutput.asText.map { it.trim() }

@Suppress("UnstableApiUsage")
private val gitCurrentTag = providers.exec {
commandLine("git", "describe", "--tags", gitRevListTags.get())
}.standardOutput.asText.map { it.trim() }

// get git shortSha for version
@Suppress("UnstableApiUsage")
val gitSha = providers.exec { commandLine("git", "rev-parse", "--short", "HEAD") }
private val gitSha = providers.exec { commandLine("git", "rev-parse", "--short", "HEAD") }
.standardOutput.asText.map { it.trim() }

mavenPublishing {
// If gradle property release true remove sha from version
version = if (project.hasProperty("release")) gitCurrentTag.get()
else "${gitCurrentTag.get()}-${gitSha.get()}"
version = if (
providers.systemProperty("release").isPresent || providers.gradleProperty("release").isPresent
) {
gitCurrentTag.get()
} else {
"${gitCurrentTag.get()}-${gitSha.get()}"
}
coordinates("com.chrisjenx.yakcov", "library", version = version.toString())
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
Expand Down

0 comments on commit 38c2ba7

Please sign in to comment.