Skip to content

Commit

Permalink
[wpeview] Add configs to publish to maven repository
Browse files Browse the repository at this point in the history
  • Loading branch information
zhani committed Oct 7, 2024
1 parent cb2a242 commit de88d3b
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/publish-to-maven-central.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to Maven Central

on:
workflow_dispatch: # Allow manual trigger

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch Dependencies (WPE Bootstrap)
run: python3 tools/scripts/bootstrap.py -a all
- name: Java™ Setup
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build and publish
run: ./gradlew wpeview:publishReleasePublicationToOSSRHRepository
env:
OSSRH_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
SIGNING_KEY: ${{ secrets.PGP_CENTRAL_SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.PGP_CENTRAL_SIGNING_KEY_PASSPHRASE }}
82 changes: 82 additions & 0 deletions wpeview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id 'com.android.library'
id 'maven-publish'
id 'signing'
}

android {
Expand Down Expand Up @@ -88,6 +90,14 @@ android {
})
}
}

publishing {
singleVariant('release') {
// This ensures only the release variant is published
withSourcesJar() // Include sources JAR
withJavadocJar() // Include Javadoc JAR (optional)
}
}
}

dependencies {
Expand All @@ -97,6 +107,78 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:1.2.1"
}

publishing {
publications {
release(MavenPublication) {
afterEvaluate {
from components.release
}

groupId 'org.wpewebkit.wpeview'
artifactId 'wpeview'
version '0.1.0'

// The sources and Javadoc JARs are automatically added because of `withSourcesJar()` and `withJavadocJar()` above

pom {
name = 'WPEView'
description = 'WPE WebKit for Android'
url = 'https://github.com/Igalia/wpe-android'

licenses {
license {
name = 'GNU Lesser General Public License v2.1'
url = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt'
distribution = 'repo'
}
}

scm {
connection = 'scm:[email protected]/Igalia/wpe-android.git'
url = 'https://github.com/Igalia/wpe-android.git'
}
}
}
}

repositories {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD")
}
}
}
}

signing {
def signingKey = project.findProperty("signing.secretKey") ?: System.getenv("SIGNING_KEY")
def signingPassword = project.findProperty("signing.password")?: System.getenv("SIGNING_PASSWORD")

if (signingKey && signingPassword) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
} else {
logger.warn("Signing key or password not found, signing will be skipped.")
}
}

tasks.withType(Javadoc).configureEach {
enabled = false // Disable Javadoc if not needed
}

tasks.register('javadocJar', Jar) {
archiveClassifier.set('javadoc')
}

tasks.register('sourcesJar', Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
}

gradle.afterProject { project ->
if (project == getProject()) {
def abiList = []
Expand Down

0 comments on commit de88d3b

Please sign in to comment.