Skip to content

Commit de88d3b

Browse files
committed
[wpeview] Add configs to publish to maven repository
1 parent cb2a242 commit de88d3b

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

.github/publish-to-maven-central.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
workflow_dispatch: # Allow manual trigger
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Fetch Dependencies (WPE Bootstrap)
14+
run: python3 tools/scripts/bootstrap.py -a all
15+
- name: Java™ Setup
16+
uses: actions/setup-java@v4
17+
with:
18+
distribution: temurin
19+
java-version: 17
20+
- name: Setup Gradle
21+
uses: gradle/actions/setup-gradle@v4
22+
- name: Build and publish
23+
run: ./gradlew wpeview:publishReleasePublicationToOSSRHRepository
24+
env:
25+
OSSRH_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
26+
OSSRH_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
27+
SIGNING_KEY: ${{ secrets.PGP_CENTRAL_SIGNING_KEY }}
28+
SIGNING_PASSWORD: ${{ secrets.PGP_CENTRAL_SIGNING_KEY_PASSPHRASE }}

wpeview/build.gradle

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
plugins {
22
id 'com.android.library'
3+
id 'maven-publish'
4+
id 'signing'
35
}
46

57
android {
@@ -88,6 +90,14 @@ android {
8890
})
8991
}
9092
}
93+
94+
publishing {
95+
singleVariant('release') {
96+
// This ensures only the release variant is published
97+
withSourcesJar() // Include sources JAR
98+
withJavadocJar() // Include Javadoc JAR (optional)
99+
}
100+
}
91101
}
92102

93103
dependencies {
@@ -97,6 +107,78 @@ dependencies {
97107
androidTestImplementation "androidx.test.ext:junit:1.2.1"
98108
}
99109

110+
publishing {
111+
publications {
112+
release(MavenPublication) {
113+
afterEvaluate {
114+
from components.release
115+
}
116+
117+
groupId 'org.wpewebkit.wpeview'
118+
artifactId 'wpeview'
119+
version '0.1.0'
120+
121+
// The sources and Javadoc JARs are automatically added because of `withSourcesJar()` and `withJavadocJar()` above
122+
123+
pom {
124+
name = 'WPEView'
125+
description = 'WPE WebKit for Android'
126+
url = 'https://github.com/Igalia/wpe-android'
127+
128+
licenses {
129+
license {
130+
name = 'GNU Lesser General Public License v2.1'
131+
url = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt'
132+
distribution = 'repo'
133+
}
134+
}
135+
136+
scm {
137+
connection = 'scm:[email protected]/Igalia/wpe-android.git'
138+
url = 'https://github.com/Igalia/wpe-android.git'
139+
}
140+
}
141+
}
142+
}
143+
144+
repositories {
145+
maven {
146+
name = "OSSRH"
147+
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
148+
149+
credentials {
150+
username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
151+
password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD")
152+
}
153+
}
154+
}
155+
}
156+
157+
signing {
158+
def signingKey = project.findProperty("signing.secretKey") ?: System.getenv("SIGNING_KEY")
159+
def signingPassword = project.findProperty("signing.password")?: System.getenv("SIGNING_PASSWORD")
160+
161+
if (signingKey && signingPassword) {
162+
useInMemoryPgpKeys(signingKey, signingPassword)
163+
sign publishing.publications
164+
} else {
165+
logger.warn("Signing key or password not found, signing will be skipped.")
166+
}
167+
}
168+
169+
tasks.withType(Javadoc).configureEach {
170+
enabled = false // Disable Javadoc if not needed
171+
}
172+
173+
tasks.register('javadocJar', Jar) {
174+
archiveClassifier.set('javadoc')
175+
}
176+
177+
tasks.register('sourcesJar', Jar) {
178+
from android.sourceSets.main.java.srcDirs
179+
archiveClassifier.set('sources')
180+
}
181+
100182
gradle.afterProject { project ->
101183
if (project == getProject()) {
102184
def abiList = []

0 commit comments

Comments
 (0)