Skip to content

Commit

Permalink
WIP - Publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaugherty committed Oct 15, 2024
1 parent e5d060e commit cb40070
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 87 deletions.
45 changes: 44 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- '[5-9].[0-9].x'
workflow_dispatch:
env:
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: '[email protected]'
jobs:
core-tests:
if: github.event_name == 'pull_request'
Expand Down Expand Up @@ -46,4 +49,44 @@ jobs:
with:
arguments: |
check
-Dgeb.env=chromeHeadless
-Dgeb.env=chromeHeadless
publish_documentation:
name: Publish Snapshot release
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: build
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
- name: Publish to Artifactory (repo.grails.org)
uses: gradle/actions/setup-gradle@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
ORG_GRADLE_PROJECT_artifactoryPublishUsername: ${{ secrets.ARTIFACTORY_USERNAME }}
ORG_GRADLE_PROJECT_artifactoryPublishPassword: ${{ secrets.ARTIFACTORY_PASSWORD }}
with:
arguments: |
-Dorg.gradle.internal.publish.checksums.insecure=true
publish
- name: Generate Documentation
if: success()
uses: gradle/actions/setup-gradle@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
with:
arguments: docs
- name: Publish to Github Pages
if: success()
uses: micronaut-projects/github-pages-deploy-action@grails
env:
BRANCH: gh-pages
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ env.GIT_USER_NAME }}
FOLDER: docs/build/docs
GH_TOKEN: ${{ secrets.GH_TOKEN }}
TARGET_REPOSITORY: ${{ github.repository }}
DOC_FOLDER: gh-pages
16 changes: 6 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@v4
with: { java-version: 11, distribution: temurin }
- name: Get the current release version
id: release_version
id: Set the current release version
run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: Tag the release version
uses: micronaut-projects/github-actions/pre-release@master
Expand All @@ -30,19 +30,15 @@ jobs:
uses: gradle/actions/setup-gradle@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SONATYPE_NEXUS_URL: ${{ secrets.SONATYPE_NEXUS_URL }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SECRING_FILE: ${{ secrets.SECRING_FILE }}
with:
arguments: |
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
publishToSonatype
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
publishToSonatype
closeAndReleaseSonatypeStagingRepository
- name: Generate Documentation
if: success()
Expand Down
36 changes: 15 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository

buildscript {
repositories {
mavenCentral()
Expand All @@ -21,9 +23,10 @@ allprojects {
}

def pluginProjects = ['spring-security-rest', 'spring-security-rest-memcached', 'spring-security-rest-redis', 'spring-security-rest-grailscache', 'spring-security-rest-gorm']
def publishedProjects = pluginProjects
def profileProjects = ['spring-security-rest-testapp-profile']
def publishedProjects = pluginProjects + profileProjects

version project.projectVersion
version projectVersion

subprojects { Project project ->
group projectGroup
Expand All @@ -32,13 +35,17 @@ subprojects { Project project ->
ext {
grailsVersion = project.grailsVersion
isSnapshot = version.endsWith('SNAPSHOT')
isReleaseVersion = !ext.isSnapshot
isProfile = project.name.endsWith('-profile')
}

repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
if (project.name != "spring-security-rest-docs" && !project.name.startsWith("build") ) {
if (project.name != "spring-security-rest-docs" &&
project.name != "spring-security-rest-testapp-profile" &&
!project.name.startsWith("build") ) {
apply plugin: "org.grails.grails-plugin"
}

Expand Down Expand Up @@ -81,31 +88,18 @@ subprojects { Project project ->
}
}

if (project.name in profileProjects) {
apply plugin: "org.grails.grails-profile"
}

if (project.name in publishedProjects) {
apply from: rootProject.file("gradle/publishing.gradle")
}
}

apply from: rootProject.file("gradle/docs.gradle")

if (project.hasProperty('release')) {
nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : ''
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
username = ossUser
password = ossPass
stagingProfileId = ossStagingProfileId
}
}
}
}

//do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
tasks.withType(InitializeNexusStagingRepository).configureEach {
shouldRunAfter(tasks.withType(Sign))
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pac4jVersion=5.7.2
jackson.version=2.15.0

# Publish Information
title=Spring Security REST plugin
projectDesc=Grails plugin to implement token-based, RESTful authentication using Spring Security
projectUrl=https://github.com/grails/grails-spring-security-rest
scmConnection=scm:git:https://github.com/grails/grails-spring-security-rest.git
scmDeveloperConnection=scm:git:https://github.com/grails/grails-spring-security-rest.git
scmUrl=https://github.com/grails/grails-spring-security-rest/tree/5.0.x
githubSlug=grails/grails-spring-security-rest
105 changes: 61 additions & 44 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

ext {
isReleaseVersion = !version.toString().endsWith("SNAPSHOT")
ext.set('signing.keyId', project.findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY'))
ext.set('signing.password', project.findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE'))

def pomInfo = {
delegate.name project.title
delegate.description project.projectDesc
delegate.url projectUrl

delegate.licenses {
delegate.license {
delegate.name 'Apache-2.0'
delegate.url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
delegate.distribution 'repo'
}
}

delegate.scm {
delegate.url "scm:[email protected]:${githubSlug}.git"
delegate.connection "scm:[email protected]:${githubSlug}.git"
delegate.developerConnection "scm:[email protected]:${githubSlug}.git"
}

delegate.developers {
delegate.developer {
delegate.id = 'alvarosanchez'
delegate.name = 'Alvaro Sanchez-Mariscal'
}
delegate.developer {
delegate.id = 'jameskleeh'
delegate.name = 'James Kleeh'
}
delegate.developer {
delegate.id = 'jdaugherty'
delegate.name = "James Daugherty"
}
}
}

publishing {
Expand All @@ -12,58 +46,41 @@ publishing {
groupId = project.group
version = project.version

from components.java
if(!isProfile) {
from components.java

artifact sourcesJar
artifact javadocJar
artifact sourcesJar
artifact javadocJar
}

pom {
name = 'Spring Security REST plugin'
description = 'Grails plugin to implement token-based, RESTful authentication using Spring Security'
url = project.projectUrl
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'alvarosanchez'
name = 'Alvaro Sanchez-Mariscal'
email = ''
}
developer {
id = 'jameskleeh'
name = 'James Kleeh'
email = ''
}
developer {
id = 'jdaugherty'
name = "James Daugherty"
email = ''
}
}
scm {
connection = project.scmConnection
developerConnection = project.scmDeveloperConnection
url = project.scmUrl
pom.withXml {
def pomNode = asNode()
pomNode.children().last() + pomInfo
}
}
}

if (isSnapshot) {
repositories {
maven {
credentials {
username = project.findProperty('artifactoryPublishUsername') ?: ''
password = project.findProperty('artifactoryPublishPassword') ?: ''
}
url = isProfile ?
uri('https://repo.grails.org/grails/libs-snapshots-local') :
uri('https://repo.grails.org/grails/plugins3-snapshots-local')


}
}
}
}

afterEvaluate {
signing {
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSPHRASE')
ext["signing.secretKeyRingFile"] = System.getenv('SECRING_FILE')

required {
isReleaseVersion && gradle.taskGraph.hasTask("publish")
}
sign publishing.publications.maven
required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') }
sign(publishing.publications.maven)
}
}

Expand Down
8 changes: 1 addition & 7 deletions spring-security-rest-testapp-profile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
buildscript {
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginForProfileVersion"
}
}

plugins {
id 'maven-publish'
id 'signing'
}

task generateProfileConfig () {
tasks.register('generateProfileConfig') {
copy {
from 'profile.yml.tmpl'
into '.'
Expand Down
1 change: 0 additions & 1 deletion spring-security-rest-testapp-profile/gradle.properties

This file was deleted.

0 comments on commit cb40070

Please sign in to comment.