Skip to content

Commit

Permalink
#6 Publish releases to Maven Central via OSSRH (OSS Repository Hosting)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasschaefer committed Mar 23, 2020
1 parent 70a53e7 commit 008c48a
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 2 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will build a package using Gradle and then publish it to OSSRH when a release is created
# For more information see: https://github.com/actions/setup-java#publishing-using-gradle

name: Publish to OSSRH when released

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Set up JDK 1.8 (Current LTS Release)
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Extract secring.gpg to sign files
run: echo -n $SECRING_GPG | base64 --decode > micronaut-camunda-bpm-feature/secring.gpg
env:
SECRING_GPG: ${{ secrets.SECRING_GPG }}

# The GITHUB_REF tag comes in the format 'refs/tags/v0.0.1'. If we split on '/' and take the 3rd value, we can get the release version, e.g. v.0.0.1
# We then remove the leading "v", e.g. 0.0.1
- name: Build release based on tag and publish to OSSRH
run: |
echo "${GITHUB_ACTOR} is publishing tag ${GITHUB_REF}."
echo "${GITHUB_REF}" | cut -d "/" -f3 | grep --regexp '^v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+$' > /dev/null #Validate format with regular expression
RELEASE_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | sed 's/v//')
echo "New release version: ${RELEASE_VERSION}"
./gradlew -Pversion=${RELEASE_VERSION} build --warning-mode=fail
./gradlew -Pversion=${RELEASE_VERSION} -Psigning.password=${SIGNING_PWD} publish --info
env:
OSSRH_PWD: ${{ secrets.OSSRH_PWD }}
SIGNING_PWD: ${{ secrets.SIGNING_PWD }}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# The project property 'version' is overwritten via .github/workflows/publish-release.yml
version=0.0.1-SNAPSHOT
micronautVersion=1.3.3
1 change: 0 additions & 1 deletion micronaut-camunda-bpm-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id "application"
}

version "0.0.1-SNAPSHOT"
group "info.novatec"

configurations {
Expand Down
50 changes: 49 additions & 1 deletion micronaut-camunda-bpm-feature/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
plugins {
id "application"
id "maven-publish"
id "signing"
}

version "0.0.1-SNAPSHOT"
group "info.novatec"

configurations {
Expand Down Expand Up @@ -53,3 +54,50 @@ java {
withJavadocJar()
withSourcesJar()
}

// based on https://docs.gradle.org/current/userguide/publishing_maven.html#sec:modifying_the_generated_pom and https://central.sonatype.org/pages/requirements.html#sufficient-metadata
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = 'micronaut-camunda-bpm-feature'
description = 'Integration between Micronaut and Camunda BPM Process Engine'
url = 'https://github.com/NovatecConsulting/micronaut-camunda-bpm'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = 'The micronaut-camunda-bpm Team at Novatec Consulting GmbH'
email = '[email protected]'
organization = 'Novatec Consulting GmbH'
organizationUrl = 'https://www.novatec-gmbh.de'
}
}
scm {
connection = 'scm:git:https://github.com/NovatecConsulting/micronaut-camunda-bpm.git'
developerConnection = 'scm:git:https://github.com/NovatecConsulting/micronaut-camunda-bpm.git'
url = 'https://github.com/NovatecConsulting/micronaut-camunda-bpm'
}
}
}
}
repositories {
maven {
url = version.endsWith('SNAPSHOT') ? 'https://oss.sonatype.org/content/repositories/snapshots/' : 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
credentials {
username 'micronaut-camunda'
password "$System.env.OSSRH_PWD"
}
}
}
}

// see https://docs.gradle.org/current/userguide/signing_plugin.html#sec:specifying_what_to_sign and https://central.sonatype.org/pages/working-with-pgp-signatures.html#generating-a-key-pair
signing {
sign publishing.publications.mavenJava
}
5 changes: 5 additions & 0 deletions micronaut-camunda-bpm-feature/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# see https://docs.gradle.org/current/userguide/signing_plugin.html#signing_plugin
# The project property 'signing.password' is set via .github/workflows/publish-release.yml
signing.keyId=2A0D5A78
signing.secretKeyRingFile=secring.gpg
#signing.password=

0 comments on commit 008c48a

Please sign in to comment.