Skip to content

Commit

Permalink
build: update build and github workflows
Browse files Browse the repository at this point in the history
- Fix resolution of custom groovy version
- Remove use of user/pass auth for remote build cache
- Other miscellaneous updates
  • Loading branch information
matrei committed Jan 1, 2025
1 parent 13535a7 commit 98e2a7a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 90 deletions.
32 changes: 14 additions & 18 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,20 +51,14 @@ 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
- 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 }}
Expand All @@ -71,8 +69,6 @@ jobs:
- 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
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
-PgroovyVersion=${{needs.build_groovy.outputs.groovyVersion}}
-x groovydoc
44 changes: 19 additions & 25 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,7 +25,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: "📝 Store the current release version"
id: release_version
run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
Expand All @@ -31,8 +35,6 @@ jobs:
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"
Expand All @@ -47,25 +49,25 @@ jobs:
run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg
- name: "📤 Publish release artifacts to Sonatype"
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
-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
Expand All @@ -80,35 +82,32 @@ 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: "🚪 Nexus Staging Close And Release"
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 +117,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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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)

Expand Down
27 changes: 4 additions & 23 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
plugins {
id 'com.gradle.develocity' version '3.18.1'
id 'com.gradle.develocity' version '3.19'
id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2'
}

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

develocity {
server = 'https://ge.grails.org'
buildScan {
tag('grails')
tag('grails-views')
publishing.onlyIf { isAuthenticated }
uploadInBackground = isLocal
}
Expand All @@ -21,31 +20,13 @@ develocity {
buildCache {
local { enabled = isLocal }
remote(develocity.buildCache) {
push = isCI && isBuildCacheAuthenticated
push = isCI && isAuthenticated
enabled = true
usernameAndPassword(
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: '',
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: ''
)
}
}

rootProject.name = 'grails-views'

dependencyResolutionManagement {
versionCatalogs {
libs {
// Make it possible to override the Groovy version
// via environment variable
def groovyVersion = System.getenv('GROOVY_VERSION')
if (groovyVersion) {
logger.warn "Using custom version $groovyVersion of Groovy due to GROOVY_VERSION being set."
version('groovy', groovyVersion)
}
}
}
}

['core', 'json', 'docs', 'json-testing-support', 'markup'].each {dirName ->
include("views-$dirName")
project(":views-$dirName").projectDir = file(dirName)
Expand Down

0 comments on commit 98e2a7a

Please sign in to comment.