Skip to content

Commit

Permalink
Update Build and Github Workflows (#608)
Browse files Browse the repository at this point in the history
* fix: resolve custom groovy version

* build: update build and github workflows

- Fix resolution of custom groovy version
- Remove use of user/pass auth for remote build cache
- Other miscellaneous updates

* ci: pr feedback

* ci: update step names
  • Loading branch information
matrei authored Jan 4, 2025
1 parent c89aa9c commit c045ce5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 121 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ env:
GIT_USER_EMAIL: 'grails-build@users.noreply.github.com'
jobs:
test_project:
runs-on: ubuntu-latest
name: "Test Project"
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
permissions:
contents: read
packages: read
steps:
- name: "📥 Checkout repository"
uses: actions/checkout@v4
Expand All @@ -24,18 +28,18 @@ jobs:
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🏃 Run Tests"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
check
run: ./gradlew check
build_project:
runs-on: ubuntu-latest
name: "Build Project"
if: github.event_name == 'push'
runs-on: ubuntu-24.04
permissions:
contents: read
packages: read
steps:
- name: "📥 Checkout repository"
uses: actions/checkout@v4
Expand All @@ -47,36 +51,23 @@ jobs:
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔨 Build project"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
build
run: ./gradlew build --continue
- name: "📤 Publish Snapshot Artifacts to Artifactory (repo.grails.org)"
if: success()
env:
DEVELOVITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
ORG_GRADLE_PROJECT_artifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }}
ORG_GRADLE_PROJECT_artifactoryPassword: ${{ secrets.ARTIFACTORY_PASSWORD }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
-Dorg.gradle.internal.publish.checksums.insecure=true
publish
- name: "📖 Generate Snapshot Documentation"
if: success()
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
views-docs:docs
run: ./gradlew views-docs:docs
- name: "📤 Publish Snapshot Documentation to Github Pages"
if: success()
uses: grails/github-pages-deploy-action@grails
Expand Down
35 changes: 12 additions & 23 deletions .github/workflows/groovy-joint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ on:
workflow_dispatch:
permissions:
contents: read
packages: read
jobs:
build_groovy:
runs-on: ubuntu-latest
name: "Build Groovy"
runs-on: ubuntu-24.04
outputs:
groovyVersion: ${{ steps.groovy-version.outputs.value }}
steps:
Expand All @@ -25,7 +27,7 @@ jobs:
with:
path: ~/.m2/repository
key: cache-local-maven-${{ github.sha }}
- name: "📥 Checkout Grails Views to fetch Gradle Plugin versions it uses"
- name: "📥 Checkout this project to fetch Gradle Plugin versions it uses"
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
Expand Down Expand Up @@ -68,27 +70,20 @@ jobs:
run: |
echo "VALUE<<EOF" >> $GITHUB_OUTPUT
echo "def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null" >> $GITHUB_OUTPUT
echo "def isBuildCacheAuthenticated =" >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null &&" >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "develocity {" >> $GITHUB_OUTPUT
echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT
echo " buildScan {" >> $GITHUB_OUTPUT
echo " tag('groovy')" >> $GITHUB_OUTPUT
echo " tag('grails-views')" >> $GITHUB_OUTPUT
echo " publishing.onlyIf { isAuthenticated }" >> $GITHUB_OUTPUT
echo " uploadInBackground = false" >> $GITHUB_OUTPUT
echo " }" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "buildCache {" >> $GITHUB_OUTPUT
echo " local { enabled = false }" >> $GITHUB_OUTPUT
echo " remote(develocity.buildCache) {" >> $GITHUB_OUTPUT
echo " push = isBuildCacheAuthenticated" >> $GITHUB_OUTPUT
echo " push = isAuthenticated" >> $GITHUB_OUTPUT
echo " enabled = true" >> $GITHUB_OUTPUT
echo " usernameAndPassword(" >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: ''," >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: ''" >> $GITHUB_OUTPUT
echo " )" >> $GITHUB_OUTPUT
echo " }" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
Expand All @@ -105,17 +100,14 @@ jobs:
# Add Develocity setup related configuration after line no 22 in gradle/build-scans.gradle
echo "${{ steps.develocity-conf-2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle
- name: "🔨 Publish Groovy to local maven repository (no docs)"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: |
cd groovy
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK
build_project:
needs: [build_groovy]
runs-on: ubuntu-latest
name: "Build Project"
needs: build_groovy
runs-on: ubuntu-24.04
steps:
- name: "📥 Checkout project"
uses: actions/checkout@v4
Expand All @@ -127,7 +119,7 @@ jobs:
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🗄️ Restore local Maven repository from cache"
uses: actions/cache@v4
with:
Expand All @@ -137,11 +129,8 @@ jobs:
run: sed -i 's|// mavenLocal() // Keep|mavenLocal() // Keep|' build.gradle
- name: "🔨 Build and test Grails using the locally built Groovy snapshot"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
build
./gradlew build --continue
-PgroovyVersion=${{needs.build_groovy.outputs.groovyVersion}}
-x groovydoc
65 changes: 23 additions & 42 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ env:
GIT_USER_EMAIL: 'grails-build@users.noreply.github.com'
jobs:
publish:
name: "Publish to Sonatype Staging Repository"
outputs:
release_version: ${{ steps.release_version.outputs.value }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read
packages: read
steps:
- name: "📥 Checkout repository"
uses: actions/checkout@v4
Expand All @@ -21,56 +25,41 @@ jobs:
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- 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: grails/github-actions/pre-release@main
- name: "🧩 Run Assemble"
if: success()
id: assemble
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew assemble
- name: "📤 Upload Distribution"
if: success()
uses: actions/upload-artifact@v4
with:
name: grails-views-${{ steps.release_version.outputs.value }}
path: ./**/build/libs/*
- name: "🔐 Generate key file for artifact signing"
env:
SECRING_FILE: ${{ secrets.SECRING_FILE }}
run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg
- name: "📤 Publish release artifacts to Sonatype"
- name: "📤 Publish to and close Sonatype staging repository"
env:
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_sonatypeOssUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypeOssPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeOssStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
ORG_GRADLE_PROJECT_sonatypeOssRepo: ${{ secrets.SONATYPE_NEXUS_URL }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
./gradlew --no-build-cache
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
publishToSonatype
closeSonatypeStagingRepository
release:
name: "Release Sonatype Staging Repository"
needs: publish
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read # limit to read access
contents: read
packages: read
steps:
- name: "📥 Checkout repository"
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
ref: v${{ needs.publish.outputs.release_version }}
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
Expand All @@ -80,35 +69,32 @@ jobs:
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🚪 Nexus Staging Close And Release"
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🚀 Release Sonatype Staging Repository"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_sonatypeOssUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypeOssPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeOssStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
ORG_GRADLE_PROJECT_sonatypeOssRepo: ${{ secrets.SONATYPE_NEXUS_URL }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
findSonatypeStagingRepository
releaseSonatypeStagingRepository
- name: "⚙️ Run post-release"
if: success()
uses: grails/github-actions/post-release@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
docs:
name: "Publish Documentation"
needs: publish
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: write
packages: read
steps:
- name: "📥 Checkout repository"
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
ref: v${{ needs.publish.outputs.release_version }}
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
Expand All @@ -118,21 +104,16 @@ jobs:
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "📖 Generate Documentation"
if: success()
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew
views-docs:docs
run: ./gradlew views-docs:docs
- name: "📤 Publish Documentation to Github Pages"
if: success()
uses: grails/github-pages-deploy-action@grails
env:
BETA: ${{ contains(needs.publish.outputs.release_version, 'M') }}
BETA: ${{ contains(needs.publish.outputs.release_version, 'M') || contains(needs.publish.outputs.release_version, 'RC') }}
BRANCH: gh-pages
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ env.GIT_USER_NAME }}
Expand Down
26 changes: 22 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ plugins {

group = 'org.grails'
version = projectVersion
ext.set('grailsVersion', libs.versions.grails.asProvider().get())
ext.set('grailsVersion', libs.versions.grails.get())
ext.set('isSnapshot', version.endsWith('-SNAPSHOT'))
ext.set('isReleaseVersion', !isSnapshot)

String customGroovyVersion = findProperty('groovyVersion') ?: System.getenv('GROOVY_VERSION')
if (customGroovyVersion) {
logger.warn("Using custom Groovy version: $customGroovyVersion")
}

allprojects {

ext.set('signing.keyId', findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY'))
Expand Down Expand Up @@ -45,14 +50,27 @@ allprojects {
})

version = rootProject.version

if (customGroovyVersion) {
configurations.configureEach {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.apache.groovy') {
details.useVersion(customGroovyVersion)
}
}
}
}

repositories {
mavenCentral()
maven { url = 'https://repo.grails.org/grails/core' }
// mavenLocal() // Keep, this will be uncommented and used by CI (groovy-joint-workflow)
if (libs.versions.groovy.get().endsWith('-SNAPSHOT')) {
if (customGroovyVersion?.endsWith('-SNAPSHOT')) {
// Used for testing locally against the latest snapshot of Groovy
// Usage: ./gradlew build -P"groovyVersion=X.X.X-SNAPSHOT"
maven {
name = 'JFrog Groovy snapshot repo'
url = 'https://groovy.jfrog.io/artifactory/libs-snapshot-local'
name = 'ASF Snapshot repo'
url = 'https://repository.apache.org/content/repositories/snapshots'
}
}
if (System.getenv("GITHUB_MAVEN_PASSWORD") && !grailsVersion.endsWith('-SNAPSHOT')) {
Expand Down
5 changes: 0 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[versions]
grails = '7.0.0-SNAPSHOT'
grails-gradle-plugin = '7.0.0-SNAPSHOT'
groovy = '4.0.24'
java-baseline = '17'
micronaut = '4.6.5'
spring-boot-gradle-plugin = '3.4.1'

[libraries]
assetpipeline = { module = 'com.bertramlabs.plugins:asset-pipeline-grails' }
Expand All @@ -16,7 +13,6 @@ grails-datastore-core = { module = 'org.grails:grails-datastore-core' }
grails-datastore-gorm-hibernate5 = { module = 'org.grails:grails-datastore-gorm-hibernate5' }
grails-datastore-gorm-support = { module = 'org.grails:grails-datastore-gorm-support' }
grails-encoder = { module = 'org.grails:grails-encoder' }
grails-gradle-plugin = { module = 'org.grails:grails-gradle-plugin', version.ref = 'grails-gradle-plugin' }
grails-mimetypes = { module = 'org.grails:grails-plugin-mimetypes' }
grails-rest = { module = 'org.grails:grails-plugin-rest' }
grails-testing-support-core = { module = 'org.grails:grails-testing-support' }
Expand All @@ -39,4 +35,3 @@ spring-context = { module = 'org.springframework:spring-context' }
spring-web = { module = 'org.springframework:spring-web' }
spring-webmvc = { module = 'org.springframework:spring-webmvc' }
spring-boot = { module = 'org.springframework.boot:spring-boot' }
spring-boot-gradle-plugin = { module = 'org.springframework.boot:spring-boot-gradle-plugin', version.ref = 'spring-boot-gradle-plugin' }
Loading

0 comments on commit c045ce5

Please sign in to comment.