Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ca142a0
Add jreleaser to enable publishing (snapshots) to maven central
wei-qiang Sep 8, 2026
f4cc499
Change workflow to test snapshot dryrun
wei-qiang Sep 9, 2026
3bab159
add -P to deploy command
wei-qiang Sep 9, 2026
3b53a47
change -Pjreleaser.project.version to -Pversion
wei-qiang Sep 9, 2026
45d9c31
Use temp credentials and publish to other groupid
wei-qiang Sep 9, 2026
1ac3ed0
Add stagingRepository
wei-qiang Sep 9, 2026
a7fdcab
Add staging-deploy repository
wei-qiang Sep 9, 2026
54087f0
change target to build
wei-qiang Sep 9, 2026
2f2bfa7
Add publish command
wei-qiang Sep 9, 2026
3d5d306
turn on debug logging
wei-qiang Sep 9, 2026
d9ce5fd
split up commands
wei-qiang Sep 9, 2026
95a1952
add -Pversion
wei-qiang Sep 9, 2026
0f49ffd
add -Pproject.version
wei-qiang Sep 9, 2026
a972591
add -Pproject.version
wei-qiang Sep 9, 2026
593ec84
add -Pjreleaser.project.version
wei-qiang Sep 9, 2026
a438297
remove version in build.gradle
wei-qiang Sep 9, 2026
a6abfd0
set -Pversion
wei-qiang Sep 9, 2026
8a29426
Add sourcesJar
wei-qiang Sep 9, 2026
126ae12
Revert removal of sourcesJar task
wei-qiang Sep 9, 2026
e225d32
Fill pom description
wei-qiang Sep 9, 2026
d70cc54
Add more developer details
wei-qiang Sep 9, 2026
b58b6ba
remove dryrun tag
wei-qiang Sep 9, 2026
321cf90
Change jreleaser to publish to org.lfenergy.powergridmodel
wei-qiang Sep 9, 2026
9a56b3c
Use correct secrets
wei-qiang Sep 9, 2026
b807c9d
Add stagingrepository to release deployment
wei-qiang Sep 9, 2026
a86c06a
Only publish when its a release
wei-qiang Sep 10, 2026
85d1145
Remove snapshot, add release environment and create_release input for…
wei-qiang Sep 10, 2026
ad72f51
Remove publishing when workflow is triggered manually as it wont crea…
wei-qiang Sep 11, 2026
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
55 changes: 55 additions & 0 deletions .github/workflows/java-gradle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ name: Java CI with Gradle for library
on:
push:
workflow_dispatch:
inputs:
create_release:
type: boolean
description: Create a release when CI passes
default: false
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -51,3 +57,52 @@ jobs:
reuse-compliance:
name: REUSE Compliance
uses: ./.github/workflows/reuse-compliance.yml

publish:
name: Publish to maven central
needs: [build-and-test]
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
environment: release
permissions:
Comment thread
wei-qiang marked this conversation as resolved.
id-token: write

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one strictly necessary?

contents: read

steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
with:
fetch-depth: 1
persist-credentials: false

- name: Setup runtime
uses: ./.github/actions/setup-runtime

- name: Cache Gradle
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }}

- name: Optimize Gradle
shell: bash
run: |
mkdir -p ~/.gradle
echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties
echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties

- name: Gradle Release Build
env:
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
Comment thread
nitbharambe marked this conversation as resolved.
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
SANITIZED_TAG: ${{ github.ref_name }}
run: |
echo "Performing release Gradle publish for tag: $SANITIZED_TAG"

./gradlew clean build publish -Pversion=$SANITIZED_TAG
./gradlew jreleaserDeploy -Pversion=$SANITIZED_TAG
73 changes: 71 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import javax.inject.Inject
plugins {
id 'java'
id 'maven-publish'
id 'org.jreleaser' version '1.26.0'
}

interface InjectedExecOps {
Expand All @@ -15,7 +16,6 @@ interface InjectedExecOps {
}

group = 'org-power-grid-model'
version = '1.0-SNAPSHOT'

repositories {
mavenCentral()
Expand Down Expand Up @@ -268,6 +268,21 @@ sourceSets {
}
}

tasks.register('sourcesJar', Jar) {
dependsOn(tasks.named('generatePGMBindings'))
from sourceSets.main.java
archiveClassifier.set('sources')
}

artifacts {
archives sourcesJar
}

java {
withSourcesJar()
withJavadocJar()
}

tasks.named('compileJava') {
dependsOn(tasks.named('generatePGMBindings'))
}
Expand All @@ -277,10 +292,64 @@ tasks.named('processResources') {
}

publishing {
repositories {
maven {
url = layout.buildDirectory.dir("staging-deploy")
}
}
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = 'lib-power-grid-model'
groupId = 'org.lfenergy.powergridmodel'
artifactId = 'power-grid-model-ffm'

pom {
name = 'power-grid-model-ffm'
description = 'Java package which wraps PGM core shared library'
url = 'https://github.com/PowerGridModel/libpower-grid-model-java'
organization {
name = 'LF Energy'
url = 'https://lfenergy.org'
}
licenses {
license {
name = 'Mozilla Public License, Version 2.0"'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = 'Mozilla Public License, Version 2.0"'
name = 'Mozilla Public License, Version 2.0'

url = 'https://www.mozilla.org/en-US/MPL/2.0/'
}
}
developers {
developer {
id = 'contributors'
name = 'Power Grid Model Contributors'
email = 'powergridmodel@lfenergy.org'
url = 'https://github.com/PowerGridModel/libpower-grid-model-java'
}
}
scm {
url = 'https://github.com/PowerGridModel/libpower-grid-model-java'
connection = 'scm:git:git://github.com/PowerGridModel/libpower-grid-model-java.git'
developerConnection = 'scm:git:ssh://git@github.com/PowerGridModel/libpower-grid-model-java.git'
}
}

}
}
}

jreleaser {
signing {
active = 'ALWAYS'
armored = true
}
deploy {
maven {
mavenCentral {
'release-deploy' {
active = 'RELEASE'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
}
}
}
Expand Down