diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f27f0cd..65d61f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,9 @@ on: types: [published] jobs: library: - runs-on: ubuntu-latest + runs-on: [ self-hosted-org, linux ] + container: + image: docker://docker.tuenti.io/android/novum_android:8 steps: - name: Checkout repo uses: actions/checkout@v4 @@ -16,10 +18,14 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEYID }} + NEXUS_USER: ${{ secrets.NEXUS_RELEASE_USER }} + NEXUS_PASS: ${{ secrets.NEXUS_RELEASE_PASSWORD }} run: | - ./gradlew publishReleasePublicationToSonatypeRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }} --max-workers 1 closeAndReleaseStagingRepository + ./gradlew publishReleasePublicationToMavenRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }} plugin: - runs-on: ubuntu-latest + runs-on: [ self-hosted-org, linux ] + container: + image: docker://docker.tuenti.io/android/novum_android:8 steps: - name: Checkout repo uses: actions/checkout@v4 @@ -28,6 +34,8 @@ jobs: env: GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} + NEXUS_USER: ${{ secrets.NEXUS_RELEASE_USER }} + NEXUS_PASS: ${{ secrets.NEXUS_RELEASE_PASSWORD }} run: | cd include-build - ../gradlew publishPlugins -DLIBRARY_VERSION=${{ github.event.release.tag_name }} \ No newline at end of file + ../gradlew publishGradlePluginPublicationToMavenRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }} \ No newline at end of file diff --git a/include-build/build.gradle.kts b/include-build/build.gradle.kts index 7d2d7b7..2c6e64d 100644 --- a/include-build/build.gradle.kts +++ b/include-build/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(libs.plugins.kotlin.jvm) apply false alias(libs.plugins.detekt) + alias(libs.plugins.publish) } allprojects { @@ -14,3 +15,5 @@ allprojects { buildUponDefaultConfig = true } } + +apply("${rootProject.projectDir}/../publish_maven_central.gradle") \ No newline at end of file diff --git a/include-build/gradle-plugin/build.gradle.kts b/include-build/gradle-plugin/build.gradle.kts index 7fb061c..abd7f82 100644 --- a/include-build/gradle-plugin/build.gradle.kts +++ b/include-build/gradle-plugin/build.gradle.kts @@ -31,3 +31,5 @@ gradlePlugin { } } } + +apply("${rootProject.projectDir}/mavencentral.gradle") \ No newline at end of file diff --git a/include-build/gradle/libs.versions.toml b/include-build/gradle/libs.versions.toml index d879c7c..b343cbb 100644 --- a/include-build/gradle/libs.versions.toml +++ b/include-build/gradle/libs.versions.toml @@ -5,6 +5,7 @@ ddmlib = "31.4.1" kotlin = "1.9.23" detekt = "1.23.6" publish-plugin = "1.2.0" +publish = "1.1.0" [libraries] android-builder-test-api = { module = "com.android.tools.build:builder-test-api", version.ref = "agp" } @@ -15,4 +16,5 @@ android-gradle = { module = "com.android.tools.build:gradle", version.ref = "agp [plugins] detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -publish-plugin = { id = "com.gradle.plugin-publish", version.ref = "publish-plugin" } \ No newline at end of file +publish-plugin = { id = "com.gradle.plugin-publish", version.ref = "publish-plugin" } +publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "publish" } \ No newline at end of file diff --git a/include-build/mavencentral.gradle b/include-build/mavencentral.gradle new file mode 100644 index 0000000..ef5b789 --- /dev/null +++ b/include-build/mavencentral.gradle @@ -0,0 +1,73 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +publishing { + repositories { + maven { + credentials { + username System.env.NEXUS_USER + password System.env.NEXUS_PASS + } + url "https://nexusng.tuenti.io/repository/maven-release-private/" + } + } + publications { + gradlePlugin(MavenPublication) { + groupId 'com.telefonica' + artifactId 'android-snaptesting-gradle-plugin' + version version + + artifact("$buildDir/libs/gradle-plugin-${version}.jar") + + pom { + name = 'Android Snaptesting Gradle Plugin' + description = 'Gradle Plugin for logs snapshot testing for Android Instrumentation tests.' + url = 'https://github.com/Telefonica/android-snaptesting' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'android-team-telefonica' + name = 'Android Team' + email = 'cto-android@telefonica.com' + } + } + scm { + connection = 'scm:git:github.com/Telefonica/android-snaptesting.git' + developerConnection = 'scm:git:ssh://github.com/Telefonica/android-snaptesting.git' + url = 'https://github.com/Telefonica/android-snaptesting/tree/main' + } + withXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.getByName("implementation").dependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + } + } + } + } +} + +afterEvaluate { + tasks.getByName("publishGradlePluginPublicationToMavenLocal").dependsOn("jar") + tasks.getByName("publishGradlePluginPublicationToMavenRepository").dependsOn("jar") + //tasks.getByName("signGradlePluginPublication").dependsOn("jar") + //tasks.getByName("signPluginMavenPublication").dependsOn("jar") +} + + +/*signing { + def signingKeyId = findProperty("signingKeyId") + def signingKey = findProperty("signingKey") + def signingPassword = findProperty("signingPassword") + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) + sign publishing.publications +}*/ diff --git a/mavencentral.gradle b/mavencentral.gradle index 35239cb..49385d7 100644 --- a/mavencentral.gradle +++ b/mavencentral.gradle @@ -11,6 +11,15 @@ apply plugin: 'maven-publish' apply plugin: 'signing' publishing { + repositories { + maven { + credentials { + username System.env.NEXUS_USER + password System.env.NEXUS_PASS + } + url "https://nexusng.tuenti.io/repository/maven-release-private/" + } + } publications { release(MavenPublication) { groupId 'com.telefonica' @@ -59,7 +68,6 @@ publishing { afterEvaluate { tasks.getByName("publishReleasePublicationToMavenLocal").dependsOn("assembleRelease") - tasks.getByName("publishReleasePublicationToSonatypeRepository").dependsOn("assembleRelease") tasks.getByName("signReleasePublication").dependsOn("assembleRelease") }