mirror of
https://github.com/kiwix/java-libkiwix.git
synced 2025-09-08 22:58:18 -04:00
Publish snapshot on maven for testing the java-libkiwix
* Introduce publish_snapshot.yml for uploading the snapshot artifact on the mavenCentral. * We have added the `SNAPSHOT` env variable in publish_snapshot.yml and match it our code if found then it means this workflow triggered to publish the snapshot on maven so on behalf of this we have rectify our code.
This commit is contained in:
parent
f561034ba8
commit
4751ef1565
41
.github/workflows/publish_snapshot.yml
vendored
Normal file
41
.github/workflows/publish_snapshot.yml
vendored
Normal file
@ -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
build.gradle
17
build.gradle
@ -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/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ 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")
|
||||
@ -22,6 +23,30 @@ ext {
|
||||
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"
|
||||
|
@ -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 {
|
||||
@ -31,7 +31,7 @@ afterEvaluate {
|
||||
|
||||
groupId GROUP_ID
|
||||
artifactId ARTIFACT_ID
|
||||
version VERSION
|
||||
version VERSION_CODE
|
||||
|
||||
from components.release
|
||||
|
||||
@ -61,15 +61,6 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||
credentials {
|
||||
username = ossrhUsername
|
||||
password = ossrhPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user