This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch 1.0.x
in repository https://gitbox.apache.org/repos/asf/grails-gradle-publish.git


The following commit(s) were added to refs/heads/1.0.x by this push:
     new e8b0911  Write the Gradle caches from every release branch
e8b0911 is described below

commit e8b09118843ffd7f650a11e2ee5fce3b1d6d1af5
Author: James Daugherty <[email protected]>
AuthorDate: Mon Oct 12 11:37:20 2026 +0100

    Write the Gradle caches from every release branch
    
    The GitHub cache that setup-gradle manages is written only from the 
repository default
    branch unless told otherwise. The default branch is main, while all 
development happens
    on the release lines, so every 1.0.x run restored nothing and saved 
nothing. Set
    cache-read-only so that pushes write and pull requests only read their base 
branch's
    entries, as grails-core does; GitHub scopes the entries by ref, so each 
release branch
    keeps its own and a release's tag run serves only a re-run of the same 
release.
    
    Remote build cache stores to develocity.apache.org were rejected with 403 
Forbidden.
    ASF Infra provisioned a Develocity access key with cache write access as the
    GRAILS_DEVELOCITY_ACCESS_KEY organization secret, which the workflows 
already pass to
    setup-gradle. Declare the Grails Develocity project ID so build scans and 
cache entries
    are associated with the Grails project, and push only when the exchanged
    DEVELOCITY_ACCESS_KEY is present instead of whenever CI is set, so builds 
without
    credentials, such as pull requests from forks, no longer attempt stores 
that are rejected.
---
 .github/workflows/ci.yaml      | 4 ++++
 .github/workflows/rat.yaml     | 2 ++
 .github/workflows/release.yaml | 6 ++++++
 settings.gradle                | 4 +++-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index a20fad1..557b796 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -49,6 +49,8 @@ jobs:
       - name: "🐘 Setup Gradle"
         uses: 
gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
         with:
+          # Every push writes, so each release branch keeps its own entries; a 
pull request only reads its base branch's.
+          cache-read-only: ${{ github.event_name == 'pull_request' }}
           develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
       - name: "🔨 Build Project (without tests)"
         if: ${{ contains(github.event.head_commit.message, '[skip tests]') }}
@@ -82,6 +84,8 @@ jobs:
       - name: "🐘 Setup Gradle"
         uses: 
gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
         with:
+          # Every push writes, so each release branch keeps its own entries; a 
pull request only reads its base branch's.
+          cache-read-only: ${{ github.event_name == 'pull_request' }}
           develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
       - name: "📤 Publish Snapshot Artifacts"
         env:
diff --git a/.github/workflows/rat.yaml b/.github/workflows/rat.yaml
index 63cebe8..54091d0 100644
--- a/.github/workflows/rat.yaml
+++ b/.github/workflows/rat.yaml
@@ -38,6 +38,8 @@ jobs:
       - name: "🐘 Setup Gradle"
         uses: 
gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
         with:
+          # Every push writes, so each release branch keeps its own entries; a 
pull request only reads its base branch's.
+          cache-read-only: ${{ github.event_name == 'pull_request' }}
           develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
       - name: "🧐 Apache License - Release Audit Tool"
         run: ./gradlew rat
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 92b0921..5d26137 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -70,6 +70,9 @@ jobs:
       - name: "🐘 Setup Gradle"
         uses: 
gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
         with:
+          # A release runs on its tag, which GitHub lets read the default 
branch's entries but not its release branch's;
+          # what it writes is scoped to that tag, so it serves only a re-run 
of the same release.
+          cache-read-only: ${{ github.event_name == 'pull_request' }}
           develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
       - name: "⚙️ Run pre-release"
         uses: apache/grails-github-actions/[email protected]
@@ -426,6 +429,9 @@ jobs:
       - name: "🐘 Setup Gradle"
         uses: 
gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
         with:
+          # A release runs on its tag, which GitHub lets read the default 
branch's entries but not its release branch's;
+          # what it writes is scoped to that tag, so it serves only a re-run 
of the same release.
+          cache-read-only: ${{ github.event_name == 'pull_request' }}
           develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
       - name: "📖 Generate Documentation"
         run: ./gradlew grails-publish:groovydoc
diff --git a/settings.gradle b/settings.gradle
index e088f3c..cd83b7e 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -24,6 +24,7 @@ plugins {
 
 def isCI = System.getenv().containsKey('CI')
 def isLocal = !isCI
+def hasDevelocityAccessKey = System.getenv('DEVELOCITY_ACCESS_KEY') != null
 def isReproducibleBuild = System.getenv('SOURCE_DATE_EPOCH') != null
 if (isReproducibleBuild) {
     gradle.settingsEvaluated {
@@ -34,6 +35,7 @@ if (isReproducibleBuild) {
 
 develocity {
     server = 'https://develocity.apache.org'
+    projectId = 'grails'
     buildScan {
         tag('grails')
         tag('grails-publish-gradle-plugin')
@@ -45,7 +47,7 @@ develocity {
 buildCache {
     local { enabled = (isLocal && !isReproducibleBuild) || (isCI && 
isReproducibleBuild) }
     remote(develocity.buildCache) {
-        push = isCI
+        push = hasDevelocityAccessKey
         enabled = !isReproducibleBuild
     }
 }

Reply via email to