Skip to content

Commit 501cc18

Browse files
committed
Modify publish script
1 parent 948427b commit 501cc18

File tree

3 files changed

+54
-44
lines changed

3 files changed

+54
-44
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Set up JDK
13+
uses: actions/setup-java@v4
14+
with:
15+
distribution: 'temurin'
16+
java-version: 17
17+
18+
- name: Build and Publish
19+
run: ./gradlew publish --stacktrace
20+
env:
21+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
22+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
23+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
24+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ allprojects {
2525
}
2626

2727
project.ext.set("publishGroupId", group)
28+
project.ext.set("publishVersion", version)
2829
}
2930

3031
ext.loadExtraProperties = { fileName ->

publish.gradle

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1+
apply plugin: 'maven-publish'
12
apply plugin: 'signing'
2-
apply plugin: "de.marcphilipp.nexus-publish"
3-
apply plugin: "io.codearte.nexus-staging"
4-
apply plugin: 'digital.wup.android-maven-publish'
53

6-
if (hasProperty("ossrhTokenPassword")) {
7-
signing {
8-
sign configurations.archives
4+
// === Configure Android publishing (sources/javadoc jars) ===
5+
android {
6+
publishing {
7+
singleVariant('release') {
8+
withSourcesJar()
9+
withJavadocJar()
10+
}
911
}
12+
}
1013

11-
nexusStaging {
12-
packageGroup = group
13-
username = project.hasProperty("ossrhToken") ? project.ext["ossrhToken"] : ""
14-
password = project.hasProperty("ossrhTokenPassword") ? project.ext["ossrhTokenPassword"] : ""
15-
}
14+
def getReleaseComponent() {
15+
return components.findByName("release")
16+
}
1617

18+
// === Publishing Configuration ===
19+
afterEvaluate {
1720
publishing {
1821
publications {
19-
mavenAar(MavenPublication) {
20-
from components.android
22+
release(MavenPublication) {
23+
from getReleaseComponent()
24+
25+
groupId = publishGroupId
26+
artifactId = publishArtifactId
27+
version = publishVersion
2128

2229
pom {
2330
name = publishArtifactName
24-
packaging = 'aar'
25-
groupId = publishGroupId
26-
artifactId = publishArtifactId
2731
description = publishDescription
2832
url = githubUrl
2933
licenses {
@@ -32,7 +36,6 @@ if (hasProperty("ossrhTokenPassword")) {
3236
url = licenseUrl
3337
}
3438
}
35-
3639
developers {
3740
developer {
3841
id = developerId
@@ -49,37 +52,19 @@ if (hasProperty("ossrhTokenPassword")) {
4952
}
5053
}
5154

52-
nexusPublishing {
53-
repositories {
54-
sonatype {
55-
username = project.hasProperty("ossrhToken") ? project.ext["ossrhToken"] : ""
56-
password = project.hasProperty("ossrhTokenPassword") ? project.ext["ossrhTokenPassword"] : ""
55+
repositories {
56+
maven {
57+
name = "Sonatype"
58+
url = uri("https://s01.oss.sonatype.org/content/repositories/releases/")
59+
credentials {
60+
username = System.getenv("OSSRH_USERNAME")
61+
password = System.getenv("OSSRH_PASSWORD")
5762
}
5863
}
5964
}
6065
}
6166

62-
// Configure signing to happen after evaluation
63-
afterEvaluate {
64-
signing.sign publishing.publications.mavenAar
65-
}
66-
}
67-
68-
// Enable sources and javadoc generation for Android libraries
69-
android {
70-
publishing {
71-
singleVariant('release') {
72-
withSourcesJar()
73-
withJavadocJar()
74-
}
67+
signing {
68+
sign publishing.publications.release
7569
}
7670
}
77-
78-
// Ensure signing happens before publishing
79-
tasks.withType(PublishToMavenRepository) {
80-
dependsOn tasks.withType(Sign)
81-
}
82-
83-
tasks.withType(GenerateModuleMetadata) {
84-
enabled = false
85-
}

0 commit comments

Comments
 (0)