Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#350 - Rework publishing plugins so they can be used externally and on multi-project builds #355

Merged
merged 6 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
64 changes: 39 additions & 25 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,77 @@ jobs:
env:
WORKSPACE: ${{ github.workspace }}
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
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 }}
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
- 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
runs-on: ubuntu-latest
permissions:
contents: write
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: [email protected]
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: '[email protected]'
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
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
id: groovydoc
uses: gradle/gradle-build-action@v3
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
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:
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
arguments: groovydoc
- name: Publish to Github Pages
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -88,4 +102,4 @@ jobs:
DOC_FOLDER: gh-pages
COMMIT_EMAIL: [email protected]
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
COMMIT_NAME: Puneet Behl
VERSION: ${{ needs.publish.outputs.release_version }}
VERSION: ${{ needs.publish.outputs.release_version }}
44 changes: 25 additions & 19 deletions .github/workflows/release.yml
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
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: [email protected]
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: '[email protected]'
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
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
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: [email protected]
GIT_USER_NAME: 'grails-build'
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
GIT_USER_EMAIL: '[email protected]'
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"]
}
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved

or

grailsPublish {
githubSlug = 'foo/bar'
license {
name = 'Apache-2.0'
}
title = "My plugin title"
desc = "My plugin description"
developers = [johndoe:"John Doe"]
}
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved

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

jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
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
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved

//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"
jdaugherty marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading