diff --git a/.github/workflows/UploadReleaseGithub.yml b/.github/workflows/UploadReleaseGithub.yml new file mode 100644 index 0000000..1f626ce --- /dev/null +++ b/.github/workflows/UploadReleaseGithub.yml @@ -0,0 +1,19 @@ +name: Upload release github + +on: + push: + tags: + - release.** + +jobs: + build: + environment: build + env: + GIT_USERNAME: ${{ secrets.GIT_USERNAME }} + GIT_AUTH_TOKEN: ${{ secrets.GIT_AUTH_TOKEN }} + runs-on: + group: Trifork-Android-Frontend-Group + steps: + # Upload aar file to github repo + - name: Upload release github + run: ./gradlew publish diff --git a/kotlin-data-wedge-lib/build.gradle.kts b/kotlin-data-wedge-lib/build.gradle.kts index 3a7660c..b26ea3d 100644 --- a/kotlin-data-wedge-lib/build.gradle.kts +++ b/kotlin-data-wedge-lib/build.gradle.kts @@ -5,7 +5,9 @@ plugins { id("kotlinx-serialization") } -version = "0.0.3" +val libraryGroupId = "dk.gls" +val libraryArtifactId = "kotlin-data-wedge" +val libraryVersion = "0.0.3" android { namespace = "dk.gls.kdw" @@ -25,8 +27,8 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_14 - targetCompatibility = JavaVersion.VERSION_14 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } testOptions { unitTests { @@ -36,7 +38,7 @@ android { } kotlin { - jvmToolchain(14) + jvmToolchain(17) } @@ -58,6 +60,43 @@ dependencies { testImplementation("org.robolectric:robolectric:4.10.3") } -apply { - from("../publish.gradle") +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/gls-denmark/kotlin-data-wedge") + credentials { + username = getEnvironmentVariable("GIT_USERNAME") + password = getEnvironmentVariable("GIT_AUTH_TOKEN") + } + } + } + publications { + register("release") { + groupId = libraryGroupId + artifactId = libraryArtifactId + version = libraryVersion + + afterEvaluate { + from(components["release"]) + } + } + } +} + +fun getEnvironmentVariable(variableName: String): String { + return try { + //Try to get the variable from gradle.properties + extra[variableName].toString() + } catch (e: ExtraPropertiesExtension.UnknownPropertyException) { + //Try to get the variable from the environment + System.getenv(variableName) + .let { + if (it?.isNotEmpty() == true) { + "$it" + } else { + "\"\"" + } + } + } } \ No newline at end of file diff --git a/publish.gradle b/publish.gradle deleted file mode 100644 index 5ffc56a..0000000 --- a/publish.gradle +++ /dev/null @@ -1,13 +0,0 @@ -// See https://github.com/jitpack/android-example -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - from components.release - - groupId = 'dk.gls' - artifactId = 'kdw' - } - } - } -} \ No newline at end of file