Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Snapshot to Maven

on:
push:
branches:
- main
tags-ignore:
- '*'

jobs:
publish:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

- name: Install dependencies
run: bash ./install_deps.sh

- name: Compile and prepare package
run: |
./gradlew buildHeaders build assemble androidSourcesJar

- name: Publish Snapshot to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SNAPSHOT: true
17 changes: 0 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,3 @@ apply plugin: 'io.github.gradle-nexus.publish-plugin'
task clean(type: Delete) {
delete rootProject.buildDir
}

Properties properties = new Properties()
if (rootProject.file("local.properties").exists()) {
properties.load(rootProject.file("local.properties").newDataInputStream())
}
// Publish to Maven Central
nexusPublishing {
repositories {
sonatype {
stagingProfileId = properties.getProperty("sonatypeStagingProfileId", System.getenv('SONATYPE_STAGING_PROFILE_ID'))
username = properties.getProperty("ossrhUsername", System.getenv('OSSRH_USERNAME'))
password = properties.getProperty("ossrhPassword", System.getenv('OSSRH_PASSWORD'))
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
25 changes: 25 additions & 0 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,38 @@ ext["key"] = properties.getProperty("signing.key", System.getenv('SIGNING_KEY'))
ext["ossrhUsername"] = properties.getProperty("ossrhUsername", System.getenv('OSSRH_USERNAME'))
ext["ossrhPassword"] = properties.getProperty("ossrhPassword", System.getenv('OSSRH_PASSWORD'))
ext["sonatypeStagingProfileId"] = properties.getProperty("sonatypeStagingProfileId", System.getenv('SONATYPE_STAGING_PROFILE_ID'))
ext["snapshot"] = System.getenv('SNAPSHOT') ?: false

ext {
set("GROUP_ID", "org.kiwix.libkiwix")
set("ARTIFACT_ID", "libkiwix")
set("VERSION", "1.0.0")
}

if (snapshot) {
ext["VERSION_CODE"] = VERSION + "-SNAPSHOT"
} else {
ext["VERSION_CODE"] = VERSION
}

// Publish to Maven Central
nexusPublishing {
useStaging.set(provider {
def release = publishing.publications.release
release.version.endsWith("-SNAPSHOT")
})
repositories {
sonatype {
stagingProfileId = properties.getProperty("sonatypeStagingProfileId", System.getenv('SONATYPE_STAGING_PROFILE_ID'))
username = properties.getProperty("ossrhUsername", System.getenv('OSSRH_USERNAME'))
password = properties.getProperty("ossrhPassword", System.getenv('OSSRH_PASSWORD'))
version = VERSION_CODE
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}

// Replace these versions with the latest available versions of libkiwix and libzim
ext.libkiwix_version = "12.0.0"
ext.libzim_version = "8.2.0"
Expand Down
13 changes: 2 additions & 11 deletions lib/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def siteUrl = 'https://www.kiwix.org/en/'
def gitUrl = 'https://github.com/kiwix/libkiwix.git'

group = GROUP_ID
version = VERSION
version = VERSION_CODE

afterEvaluate {
publishing {
Expand All @@ -31,7 +31,7 @@ afterEvaluate {

groupId GROUP_ID
artifactId ARTIFACT_ID
version VERSION
version VERSION_CODE

from components.release

Expand Down Expand Up @@ -61,15 +61,6 @@ afterEvaluate {
}
}
}
repositories {
maven {
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
}

Expand Down