Add Maven Central deployment
Build & Release / release-library (push) Has been cancelled Details

This commit is contained in:
John Ahlroos 2024-11-04 13:17:40 +01:00
parent a2593877bd
commit 434390b0a4
Signed by: john
GPG Key ID: 258D0F70DB84CD5D
2 changed files with 108 additions and 1 deletions

View File

@ -0,0 +1,43 @@
name: Build & Release
on:
push:
branches: [master]
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
ORG_GRADLE_PROJECT_BUILD_VERSION: ${{ gitea.ref_name }}
DEVSOAP_GPG_KEY: ${{ secrets.GPG_DEVSOAP_PRIVATE_KEY }}
DEVSOAP_GPG_PASSWORD: ${{ secrets.GPG_DEVSOAP_PASSPHRASE }}
TAG: ${{ gitea.ref_name }}
RUNNER_TOOL_CACHE: /toolcache
jobs:
release-library:
runs-on: node20
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_JOHN_PRIVATE_KEY }}
- name: Configure Java project
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'
- name: Cache Java dependencies
uses: actions/cache@v4
env:
cache-name: cache-java-dependencies
with:
path: ~/.gradle
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/build.gradle') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Run tests
run: ./gradlew --info --stacktrace test
- name: Upload to Maven Central
run: ./gradlew --info --stacktrace publish

View File

@ -1,9 +1,18 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
group = 'com.devsoap'
version = '1.0-SNAPSHOT'
version = findProperty('BUILD_VERSION') ?: 'latest'
java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
repositories {
mavenCentral()
@ -26,4 +35,59 @@ test {
testLogging {
events "passed", "skipped", "failed"
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'assertj-json'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'AssertJ JSON'
description = 'JSON assertions for AssertJ'
url = 'https://code.devsoap.com/john/assertj-json'
licenses {
license {
name = 'Creative Commons Attribution-NoDerivatives 4.0 International'
url = 'https://creativecommons.org/licenses/by-nd/4.0'
}
}
developers {
developer {
id = 'john'
name = 'John Ahlroos'
email = 'john@ahlroos.me'
organization = "Devsoap"
organizationUrl = "https://devsoap.com"
timezone = "Europe/Madrid"
}
}
scm {
connection = 'scm:git:ssh://git@code.devsoap.com:john/assertj-json.git'
developerConnection = 'scm:git:ssh://git@code.devsoap.com:john/assertj-json.git'
url = 'https://code.devsoap.com/john/assertj-json'
}
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publish") }
def signingKey = findProperty("DEVSOAP_GPG_KEY") as String
def signingPassword = findProperty("DEVSOAP_GPG_PASSWORD") as String
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
javadoc {
options.addBooleanOption('html5', true)
}