Skip to content

Commit

Permalink
Rework publishing plugins so they can be used externally and on multi…
Browse files Browse the repository at this point in the history
…-project builds
  • Loading branch information
jdaugherty committed Nov 20, 2024
1 parent b78c0db commit e252848
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 213 deletions.
58 changes: 36 additions & 22 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,50 @@ jobs:
env:
WORKSPACE: ${{ github.workspace }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: liberica
java-version: ${{ matrix.java }}
- name: Run Build
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🔨 Build project"
id: build
uses: gradle/gradle-build-action@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
with:
arguments: build -Dgeb.env=chromeHeadless
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: ./gradlew build
publish:
if: github.event_name == 'push'
needs: ['build']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: liberica
java-version: 17
- name: Publish Artifacts (repo.grails.org)
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "📤 Publish Snapshot Artifacts to Artifactory (repo.grails.org/libs-snapshot-local)"
id: publish
uses: gradle/gradle-build-action@v3
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
with:
arguments: |
-Dorg.gradle.internal.publish.checksums.insecure=true
publish
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: >
./gradlew
-Dorg.gradle.internal.publish.checksums.insecure=true
publish
docs:
if: github.event_name == 'push'
needs: publish
Expand All @@ -61,18 +70,23 @@ jobs:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@unityfoundation.io
steps:
- name: Checkout repository
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: Set up JDK
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: liberica
java-version: 17
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: Generate Groovydoc
id: groovydoc
uses: gradle/gradle-build-action@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
arguments: groovydoc
- name: Publish to Github Pages
Expand Down
44 changes: 25 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,43 @@ jobs:
release_version: ${{ steps.release_version.outputs.value }}
target_branch: ${{ steps.extract_branch.outputs.value }}
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@unityfoundation.io
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: 'grails-build@users.noreply.github.com'
steps:
- name: Checkout repository
- name: "📥 Checkout repository"
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set up JDK
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: liberica
java-version: 17
- name: Extract Target Branch
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "📝 Store the target branch"
id: extract_branch
run: |
echo "Determining Target Branch"
TARGET_BRANCH=`cat $GITHUB_EVENT_PATH | jq '.release.target_commitish' | sed -e 's/^"\(.*\)"$/\1/g'`
TARGET_BRANCH=${GITHUB_REF#refs/heads/}
echo $TARGET_BRANCH
echo "value=${TARGET_BRANCH}" >> $GITHUB_OUTPUT
- name: Set the current release version
- name: "📝 Store the current release version"
id: release_version
run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: Run pre-release
- name: "⚙️ Run pre-release"
uses: micronaut-projects/github-actions/pre-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Assemble
- name: "🧩 Run Assemble"
if: success()
id: assemble
uses: gradle/gradle-build-action@v3
with:
arguments: assemble
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: ./gradlew assemble
- name: Upload Distribution
if: success()
uses: actions/upload-artifact@v4
Expand All @@ -67,7 +70,8 @@ jobs:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SECRING_FILE: ${{ secrets.SECRING_FILE }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
arguments: |
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
Expand All @@ -93,7 +97,8 @@ jobs:
- name: Nexus Staging Close And Release
uses: gradle/gradle-build-action@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_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 }}
Expand All @@ -114,8 +119,8 @@ jobs:
permissions:
contents: write
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@unityfoundation.io
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: 'grails-build@users.noreply.github.com'
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -131,7 +136,8 @@ jobs:
id: groovydoc
uses: gradle/gradle-build-action@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
arguments: groovydoc
- name: Publish to Github Pages
Expand Down
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ grails-gsp
---------
* Configure GSP Compiling Task

grails-plugin-publish
---------
_Todo_: Add the docs

grails-plugin
---------
* Configure Ast Sources
Expand All @@ -41,6 +37,58 @@ grails-profile
---------
_Todo_: Add the docs

grails-profile-publish
---------
_Todo_: Add the docs

grails-publish
---------
A Gradle plugin to simplify publishing to either an Artifactory or Maven Central endpoint for snapshots & to Maven Central for releases.

Example Usage:

grailsPublish {
websiteUrl = 'http://foo.com/myplugin'
license {
name = 'Apache-2.0'
}
issueTrackerUrl = 'http://github.com/myname/myplugin/issues'
vcsUrl = 'http://github.com/myname/myplugin'
title = "My plugin title"
desc = "My plugin description"
developers = [johndoe:"John Doe"]
}

or

grailsPublish {
githubSlug = 'foo/bar'
license {
name = 'Apache-2.0'
}
title = "My plugin title"
desc = "My plugin description"
developers = [johndoe:"John Doe"]
}

By default this plugin will publish to the specified Artifactory instance for snapshots, and Maven Central for releases. To change the snapshot publish behavior, you can set the `snapshotRepoType` to `RepositoryType.CENTRAL`.

The credentials and connection url must be specified as a project property or an environment variable.

Artifactory Environment Variables are:

ARTIFACTORY_USERNAME
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL

Sonatype Environment Variables are:

SONATYPE_NEXUS_URL
SONATYPE_SNAPSHOT_URL
SONATYPE_USERNAME
SONATYPE_PASSWORD
SONATYPE_STAGING_PROFILE_ID

grails-web
---------
* Adds web specific extensions
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ gradlePlugin {
}
grailsPluginPublish {
displayName = "Grails Publish Gradle Plugin"
description = 'A plugin to setup publishing to Grails central repo'
id = 'org.grails.internal.grails-plugin-publish'
implementationClass = 'org.grails.gradle.plugin.publishing.internal.GrailsCentralPublishGradlePlugin'
description = 'A plugin to assist in publishing Grails related artifacts'
id = 'org.grails.grails-plugin-publish'
implementationClass = 'org.grails.gradle.plugin.publishing.GrailsCentralPublishGradlePlugin'
}
grailsProfilePublish {
displayName = "Grails Profile Publish Plugin"
description = 'A plugin for publishing profiles'
id = 'org.grails.internal.grails-profile-publish'
implementationClass = 'org.grails.gradle.plugin.profiles.internal.GrailsProfilePublishGradlePlugin'
id = 'org.grails.grails-profile-publish'
implementationClass = 'org.grails.gradle.plugin.profiles.GrailsProfilePublishGradlePlugin'
}
}
}
Expand Down
47 changes: 27 additions & 20 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
plugins {
// id "com.gradle.enterprise" version "3.17.2"
// id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.1'
id 'com.gradle.develocity' version '3.18.1'
id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2'
}

//gradleEnterprise {
// server = 'https://ge.grails.org'
// buildScan {
// publishAlwaysIf(System.getenv('CI') == 'true')
// publishIfAuthenticated()
// uploadInBackground = System.getenv("CI") == null
// capture {
// taskInputFiles = true
// }
// }
//}
def isCI = System.getenv('CI') != null
def isLocal = !isCI
def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null
def isBuildCacheAuthenticated =
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null &&
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null

//buildCache {
// local { enabled = System.getenv('CI') != 'true' }
// remote(gradleEnterprise.buildCache) {
// def isAuthenticated = System.getenv('GRADLE_ENTERPRISE_ACCESS_KEY')
// push = System.getenv('CI') == 'true' && isAuthenticated
// enabled = true
// }}
develocity {
server = 'https://ge.grails.org'
buildScan {
publishing.onlyIf { isAuthenticated }
uploadInBackground = isLocal
}
}

buildCache {
local { enabled = isLocal }
remote(develocity.buildCache) {
push = isCI && isBuildCacheAuthenticated
enabled = true
usernameAndPassword(
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: '',
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: ''
)
}
}


rootProject.name = "grails-gradle-plugin"
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.grails.gradle.plugin.profiles.internal
package org.grails.gradle.plugin.profiles


import groovy.transform.CompileStatic
Expand All @@ -25,8 +25,7 @@ import org.gradle.api.artifacts.DependencySet
import org.gradle.api.artifacts.SelfResolvingDependency
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.grails.gradle.plugin.profiles.GrailsProfileGradlePlugin
import org.grails.gradle.plugin.publishing.internal.GrailsCentralPublishGradlePlugin
import org.grails.gradle.plugin.publishing.GrailsPublishGradlePlugin

import java.nio.file.Files

Expand All @@ -39,7 +38,7 @@ import static org.gradle.api.plugins.BasePlugin.BUILD_GROUP
* @since 3.1
*/
@CompileStatic
class GrailsProfilePublishGradlePlugin extends GrailsCentralPublishGradlePlugin {
class GrailsProfilePublishGradlePlugin extends GrailsPublishGradlePlugin {

@Override
void apply(Project project) {
Expand All @@ -55,16 +54,6 @@ class GrailsProfilePublishGradlePlugin extends GrailsCentralPublishGradlePlugin
})
}

@Override
protected String getDefaultGrailsCentralReleaseRepo() {
"https://repo.grails.org/grails/libs-releases-local"
}

@Override
protected String getDefaultGrailsCentralSnapshotRepo() {
"https://repo.grails.org/grails/libs-snapshots-local"
}

@Override
protected Map<String, String> getDefaultExtraArtifact(Project project) {
[source: "${project.buildDir}/classes/profile/META-INF/grails-profile/profile.yml".toString(),
Expand All @@ -77,11 +66,6 @@ class GrailsProfilePublishGradlePlugin extends GrailsCentralPublishGradlePlugin
'profile'
}

@Override
protected String getDefaultRepo() {
'profiles'
}

@Override
protected void doAddArtefact(Project project, MavenPublication publication) {
publication.artifact(project.tasks.findByName("jar"))
Expand Down
Loading

0 comments on commit e252848

Please sign in to comment.