Skip to content

Commit 95f78b0

Browse files
authored
add nexus publish info (#5)
* add nexus publish info * remove duplicated key * change jar to assembleRelease in mavencentral.gradle * remove useless command * remove unused command * publish plugin on nexus * add nexus credentials * remove plugin portal * add mavencentral.gradle for the plugin * remove mavencentral.gradle * remove useless command * add mavencentral.gradle * try remove publish_maven_central command * add publish_maven_central command * remove publish_maven_central from include-build * remove publish_maven_central from include-build * solve publish plugin addition * change mavecentral.gradle * fix typo
1 parent c58c642 commit 95f78b0

File tree

6 files changed

+102
-6
lines changed

6 files changed

+102
-6
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
types: [published]
55
jobs:
66
library:
7-
runs-on: ubuntu-latest
7+
runs-on: [ self-hosted-org, linux ]
8+
container:
9+
image: docker://docker.tuenti.io/android/novum_android:8
810
steps:
911
- name: Checkout repo
1012
uses: actions/checkout@v4
@@ -16,10 +18,14 @@ jobs:
1618
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
1719
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
1820
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEYID }}
21+
NEXUS_USER: ${{ secrets.NEXUS_RELEASE_USER }}
22+
NEXUS_PASS: ${{ secrets.NEXUS_RELEASE_PASSWORD }}
1923
run: |
20-
./gradlew publishReleasePublicationToSonatypeRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }} --max-workers 1 closeAndReleaseStagingRepository
24+
./gradlew publishReleasePublicationToMavenRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }}
2125
plugin:
22-
runs-on: ubuntu-latest
26+
runs-on: [ self-hosted-org, linux ]
27+
container:
28+
image: docker://docker.tuenti.io/android/novum_android:8
2329
steps:
2430
- name: Checkout repo
2531
uses: actions/checkout@v4
@@ -28,6 +34,8 @@ jobs:
2834
env:
2935
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
3036
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
37+
NEXUS_USER: ${{ secrets.NEXUS_RELEASE_USER }}
38+
NEXUS_PASS: ${{ secrets.NEXUS_RELEASE_PASSWORD }}
3139
run: |
3240
cd include-build
33-
../gradlew publishPlugins -DLIBRARY_VERSION=${{ github.event.release.tag_name }}
41+
../gradlew publishGradlePluginPublicationToMavenRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }}

include-build/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
alias(libs.plugins.kotlin.jvm) apply false
33
alias(libs.plugins.detekt)
4+
alias(libs.plugins.publish)
45
}
56

67
allprojects {
@@ -14,3 +15,5 @@ allprojects {
1415
buildUponDefaultConfig = true
1516
}
1617
}
18+
19+
apply("${rootProject.projectDir}/../publish_maven_central.gradle")

include-build/gradle-plugin/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ gradlePlugin {
3131
}
3232
}
3333
}
34+
35+
apply("${rootProject.projectDir}/mavencentral.gradle")

include-build/gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ddmlib = "31.4.1"
55
kotlin = "1.9.23"
66
detekt = "1.23.6"
77
publish-plugin = "1.2.0"
8+
publish = "1.1.0"
89

910
[libraries]
1011
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
1516
[plugins]
1617
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
1718
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
18-
publish-plugin = { id = "com.gradle.plugin-publish", version.ref = "publish-plugin" }
19+
publish-plugin = { id = "com.gradle.plugin-publish", version.ref = "publish-plugin" }
20+
publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "publish" }

include-build/mavencentral.gradle

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
publishing {
5+
repositories {
6+
maven {
7+
credentials {
8+
username System.env.NEXUS_USER
9+
password System.env.NEXUS_PASS
10+
}
11+
url "https://nexusng.tuenti.io/repository/maven-release-private/"
12+
}
13+
}
14+
publications {
15+
gradlePlugin(MavenPublication) {
16+
groupId 'com.telefonica'
17+
artifactId 'android-snaptesting-gradle-plugin'
18+
version version
19+
20+
artifact("$buildDir/libs/gradle-plugin-${version}.jar")
21+
22+
pom {
23+
name = 'Android Snaptesting Gradle Plugin'
24+
description = 'Gradle Plugin for logs snapshot testing for Android Instrumentation tests.'
25+
url = 'https://github.com/Telefonica/android-snaptesting'
26+
licenses {
27+
license {
28+
name = 'The Apache License, Version 2.0'
29+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
30+
}
31+
}
32+
developers {
33+
developer {
34+
id = 'android-team-telefonica'
35+
name = 'Android Team'
36+
37+
}
38+
}
39+
scm {
40+
connection = 'scm:git:github.com/Telefonica/android-snaptesting.git'
41+
developerConnection = 'scm:git:ssh://github.com/Telefonica/android-snaptesting.git'
42+
url = 'https://github.com/Telefonica/android-snaptesting/tree/main'
43+
}
44+
withXml {
45+
def dependenciesNode = asNode().appendNode('dependencies')
46+
47+
project.configurations.getByName("implementation").dependencies.each {
48+
def dependencyNode = dependenciesNode.appendNode('dependency')
49+
dependencyNode.appendNode('groupId', it.group)
50+
dependencyNode.appendNode('artifactId', it.name)
51+
dependencyNode.appendNode('version', it.version)
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
58+
59+
afterEvaluate {
60+
tasks.getByName("publishGradlePluginPublicationToMavenLocal").dependsOn("jar")
61+
tasks.getByName("publishGradlePluginPublicationToMavenRepository").dependsOn("jar")
62+
//tasks.getByName("signGradlePluginPublication").dependsOn("jar")
63+
//tasks.getByName("signPluginMavenPublication").dependsOn("jar")
64+
}
65+
66+
67+
/*signing {
68+
def signingKeyId = findProperty("signingKeyId")
69+
def signingKey = findProperty("signingKey")
70+
def signingPassword = findProperty("signingPassword")
71+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
72+
sign publishing.publications
73+
}*/

mavencentral.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ apply plugin: 'maven-publish'
1111
apply plugin: 'signing'
1212

1313
publishing {
14+
repositories {
15+
maven {
16+
credentials {
17+
username System.env.NEXUS_USER
18+
password System.env.NEXUS_PASS
19+
}
20+
url "https://nexusng.tuenti.io/repository/maven-release-private/"
21+
}
22+
}
1423
publications {
1524
release(MavenPublication) {
1625
groupId 'com.telefonica'
@@ -59,7 +68,6 @@ publishing {
5968

6069
afterEvaluate {
6170
tasks.getByName("publishReleasePublicationToMavenLocal").dependsOn("assembleRelease")
62-
tasks.getByName("publishReleasePublicationToSonatypeRepository").dependsOn("assembleRelease")
6371
tasks.getByName("signReleasePublication").dependsOn("assembleRelease")
6472
}
6573

0 commit comments

Comments
 (0)