Skip to content

Commit

Permalink
Set correct library version
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wong committed Oct 9, 2024
1 parent 0154416 commit 95ca064
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-central-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew closeAndReleaseRepository -PmavenCentralUsername=$OSSRH_USERNAME -PmavenCentralPassword=$OSSRH_PASSWORD
run: ./gradlew releaseRepository -PmavenCentralUsername=$OSSRH_USERNAME -PmavenCentralPassword=$OSSRH_PASSWORD
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,34 @@ task clean(type: Delete) {
}

allprojects {
group = property("GROUP").toString()
version = getProjectVersion()

plugins.withId("com.vanniktech.maven.publish") {
mavenPublishing {
pom {
group = project.group
version = project.version
}
}
}


// https://github.com/Kotlin/dokka/issues/2956
tasks.matching { task ->
task.name.contains("javaDocReleaseGeneration")
}.configureEach {
enabled = false
}
}

private String getProjectVersion() {
def versionFromGradleProperties = property("VERSION").toString()
def versionFromWorkflow = null
try {
versionFromWorkflow = property("githubRefName").toString().replaceFirst("^v", "")
} catch (MissingPropertyException ignored) {
// Ignore exception and continue
}
return versionFromWorkflow ?: versionFromGradleProperties
}
4 changes: 2 additions & 2 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "ch.ubique.qrscanner.example"
minSdk 23
targetSdk 34
versionCode 1
versionName "1.0.0"
versionCode project.version.toString().split('-')[0].replace(".", "").toInteger()
versionName project.version.toString()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ android.enableR8.fullMode=false

# Artifact metadata
GROUP=ch.ubique.android
VERSION_NAME=1.0.0
# VERSION will only be used if no property "githubRefName" is set (which the release workflow does)
VERSION=0.0.1

# POM metadata
POM_PACKAGING=aar
Expand Down

0 comments on commit 95ca064

Please sign in to comment.