diff --git a/.github/workflows/deploy_to_app_distribution.yml b/.github/workflows/deploy_to_app_distribution.yml index 7d3ad94a..a0c9ef21 100644 --- a/.github/workflows/deploy_to_app_distribution.yml +++ b/.github/workflows/deploy_to_app_distribution.yml @@ -19,7 +19,7 @@ jobs: id: short-sha - uses: actions/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '2.6' - name: install firebase tool run: | yarn global add firebase-tools @@ -39,4 +39,4 @@ jobs: - name: Notify Slack about failure run: | curl -X POST -H 'Content-type: application/json' --data '{"icon_emoji": ":lock:", "username": "GitHub Actions", "text":":x: [Tiqr Android] Build #${{ github.run_number }} failed (${{ steps.short-sha.outputs.sha }})"}' ${{ secrets.SLACK_WEBHOOK_URL }} - if: failure() \ No newline at end of file + if: failure() diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..de2baed6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: Publish + +on: + release: + # We'll run this workflow when a new GitHub release is created + types: [released] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 8 + + # Builds the release artifacts of the library + - name: Release build + run: ./gradlew :tiqr-client-android:assembleRelease + + # Generates other artifacts + - name: Source jar + run: ./gradlew androidSourcesJar + + # Runs upload, and then closes & releases the repository + - name: Publish to MavenCentral + run: ./gradlew publishMavenAndroidPublicationToSonatypeRepository --max-workers 1 + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} diff --git a/core/build.gradle.kts b/core/build.gradle.kts index aafe1dd7..0d3a5e14 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,3 +1,5 @@ +import java.util.Properties + plugins { id("com.android.library") kotlin("android") @@ -5,6 +7,8 @@ plugins { id("kotlin-parcelize") id("dagger.hilt.android.plugin") id("androidx.navigation.safeargs.kotlin") + `maven-publish` + signing } android { @@ -47,6 +51,17 @@ android { jvmTarget = "1.8" } } +} + +fun loadCustomProperties(file: File): java.util.Properties { + val properties = Properties() + if (file.isFile) { + properties.load(file.inputStream()) + } + return properties +} + +val secureProperties = loadCustomProperties(file("../local.properties")) dependencies { implementation(libs.kotlin.stdlib) @@ -96,7 +111,93 @@ android { androidTestImplementation(libs.androidx.testing.uiautomator) androidTestImplementation(libs.kotlinx.coroutines.test) - androidTestImplementation(libs.dagger.hilt.testing) - kaptAndroidTest(libs.dagger.hilt.compiler) + androidTestImplementation(libs.dagger.hilt.testing) + kaptAndroidTest(libs.dagger.hilt.compiler) +} + +group = "org.tiqr" +version = "0.0.7-SNAPSHOT" + +tasks { + register("sourcesJar", Jar::class) { + archiveClassifier.set("sources") + from(android.sourceSets.getByName("main").java.srcDirs) } } +publishing { + publications { + register("mavenAndroid") { + artifactId = "core" + + afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) } + artifact(tasks.getByName("sourcesJar")) + + pom { + name.set("core") + url.set("https://github.com/SURFnet/tiqr-app-core-android") + description.set("refactoring original tiqr project") + developers { + developer { + name.set("sara hachem") + email.set("sara@egeniq.com") + } + developer { + name.set("Dmitry Kovalenko") + email.set("dima@egeniq.com") + } + } + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + scm { + connection.set("https://github.com/SURFnet/tiqr-app-core-android.git") + url.set("https://github.com/SURFnet/tiqr-app-core-android") + } + + withXml { + fun groovy.util.Node.addDependency(dependency: Dependency, scope: String) { + appendNode("dependency").apply { + appendNode("groupId", dependency.group) + appendNode("artifactId", dependency.name) + appendNode("version", dependency.version) + appendNode("scope", scope) + } + } + + asNode().appendNode("dependencies").let { dependencies -> + // List all "api" dependencies as "compile" dependencies + configurations.api.get().allDependencies.forEach { + dependencies.addDependency(it, "compile") + } + // List all "implementation" dependencies as "runtime" dependencies + configurations.implementation.get().allDependencies.forEach { + dependencies.addDependency(it, "runtime") + } + } + } + } + } + } + + repositories { + maven { + name = "sonatype" + val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + val snapshotRepo = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") + url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotRepo else releasesRepoUrl) + credentials { + username = secureProperties.getProperty("USERNAME") + password =secureProperties.getProperty("PASSWORD") + } + } + } + + + signing { + useGpgCmd() + sign(publishing.publications["mavenAndroid"]) + } +} \ No newline at end of file diff --git a/data/build.gradle.kts b/data/build.gradle.kts index f03d0710..b466f8e6 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -95,4 +95,4 @@ android { androidTestImplementation(libs.androidx.testing.epsresso) androidTestImplementation(libs.kotlinx.coroutines.test) } -} +} \ No newline at end of file