Skip to content

Commit

Permalink
Merge pull request #7 from gls-denmark/use-github-packages-instead-of…
Browse files Browse the repository at this point in the history
…-jitpack

remove jitpack publish file. add credentials to publish to github packages
  • Loading branch information
mnlatrifork authored Nov 23, 2023
2 parents 4c91960 + 0c53adb commit 42bd581
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 19 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/UploadReleaseGithub.yml
Original file line number Diff line number Diff line change
@@ -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
51 changes: 45 additions & 6 deletions kotlin-data-wedge-lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -25,8 +27,8 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_14
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
testOptions {
unitTests {
Expand All @@ -36,7 +38,7 @@ android {
}

kotlin {
jvmToolchain(14)
jvmToolchain(17)
}


Expand All @@ -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<MavenPublication>("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 {
"\"\""
}
}
}
}
13 changes: 0 additions & 13 deletions publish.gradle

This file was deleted.

0 comments on commit 42bd581

Please sign in to comment.