Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .agents/skills/repository-structure/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ These are available in all subprojects as project properties (`projectVersion`,
## SDK Management

The `.sdkmanrc` file pins exact SDK versions. Run `sdk env install` to install them. CI reads `.sdkmanrc` to determine
the Java version dynamically.
the Java version dynamically. `.sdkmanrc` and the Gradle wrapper are not overwritten by the template sync — each repo
owns them, and CI fails if `.sdkmanrc`'s `gradle` version differs from the wrapper's `distributionUrl`.

## CI/CD Pipeline

Expand Down
37 changes: 37 additions & 0 deletions .github/scripts/groovy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# WARNING: Do not edit this file directly in your own repository.
# It is maintained in the grails-plugin-template repository.
# To make changes, edit it there and they will be synced automatically:
# https://github.com/grails-plugins/grails-plugin-template/tree/main/.github/scripts
#
# Runs a Groovy script in the official Groovy Docker image, so workflows need
# neither a JDK nor sdkman to run the scripts in .github/scripts. The Groovy
# version is independent of .sdkmanrc: the scripts only need Groovy and its
# bundled YAML module.
#
# Usage: .github/scripts/groovy.sh <script.groovy> [args...]
#
# The current directory is mounted at the same path, so relative and absolute
# paths into it keep working, and the script runs as the calling user, so files
# it writes stay owned by that user (and committable by the workflow).
#
# Environment:
# GROOVY_IMAGE overrides the image (default below)
# GITHUB_TOKEN, GITHUB_REPOSITORY, GITHUB_OUTPUT, FILTER_PROJECT, VERIFY_STRICT
# passed through to the script when set
set -euo pipefail

image="${GROOVY_IMAGE:-groovy:5.0-jdk21}"

docker_args=(--rm --user "$(id -u):$(id -g)" -e HOME=/tmp -v "${PWD}:${PWD}" -w "${PWD}")
for var in GITHUB_TOKEN GITHUB_REPOSITORY GITHUB_OUTPUT FILTER_PROJECT VERIFY_STRICT; do
if [ -n "${!var:-}" ]; then
docker_args+=(-e "${var}")
fi
done
# GITHUB_OUTPUT is a runner file outside the workspace
if [ -n "${GITHUB_OUTPUT:-}" ]; then
docker_args+=(-v "${GITHUB_OUTPUT}:${GITHUB_OUTPUT}")
fi

exec docker run "${docker_args[@]}" "${image}" groovy "$@"
1 change: 0 additions & 1 deletion .github/scripts/update-contributors.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// WARNING: Do not edit this file directly in your own repository.
// It is maintained in the grails-plugin-template repository.
// https://github.com/grails-plugins/grails-plugin-template/tree/main/.github/scripts
@Grab('org.apache.groovy:groovy-yaml')
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import groovy.yaml.YamlBuilder
Expand Down
1 change: 0 additions & 1 deletion .github/scripts/update-versions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// WARNING: Do not edit this file directly in your own repository.
// It is maintained in the grails-plugin-template repository.
// https://github.com/grails-plugins/grails-plugin-template/tree/main/.github/scripts
@Grab('org.apache.groovy:groovy-yaml')
import groovy.json.JsonSlurper
import groovy.yaml.YamlBuilder
import groovy.yaml.YamlSlurper
Expand Down
12 changes: 10 additions & 2 deletions .github/scripts/verify-repository.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//
// Run it locally with:
// groovy .github/scripts/verify-repository.groovy
// or, without a local Groovy, through Docker like CI does:
// .github/scripts/groovy.sh .github/scripts/verify-repository.groovy
//
// It works both in the template repo itself and in any repo that received a
// files-sync.yml sync from it — template-only checks are gated on the
Expand All @@ -11,7 +13,6 @@
// Exit code is non-zero if any error was found. Warnings are printed but do
// not fail the run unless VERIFY_STRICT=1 is set, in which case they are
// escalated to errors too.
@Grab('org.apache.groovy:groovy-yaml')
import groovy.yaml.YamlSlurper

def errors = []
Expand Down Expand Up @@ -189,7 +190,8 @@ if (sdkmanrcFile.exists()) {
def m = distUrl =~ /gradle-([0-9.]+)-/
if (m.find() && m.group(1) != sdkmanrc.getProperty('gradle')) {
err(".sdkmanrc gradle version ('${sdkmanrc.getProperty('gradle')}') does not match the wrapper's " +
"distributionUrl version ('${m.group(1)}')")
"distributionUrl version ('${m.group(1)}') — update one to match the other, e.g. " +
"./gradlew wrapper --gradle-version ${sdkmanrc.getProperty('gradle')}")
}
}
}
Expand Down Expand Up @@ -427,6 +429,12 @@ if (isTemplate) {
}
}

def contributorsJob = loadYaml('.github/workflows/update-contributors.yml')?.jobs?.get('update-contributors')
if (contributorsJob != null && !((contributorsJob.'if' as String)?.contains(repoGuard))) {
err("update-contributors.yml job 'update-contributors' does not guard against running in the template " +
"repo itself (expected its 'if:' to contain \"${repoGuard}\")")
}

// ci.yml is synced, but synced repos have no conventions/ directory to test
def templateOnlyGuard = "github.repository == 'grails-plugins/grails-plugin-template'"
(ciYaml?.jobs?.build?.steps ?: []).each { step ->
Expand Down
22 changes: 2 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,8 @@ jobs:
steps:
- name: "📥 Checkout repository"
uses: actions/checkout@v7
- name: "Export .sdkmanrc properties"
uses: apache/grails-github-actions/export-gradle-properties@asf
with:
file: ".sdkmanrc"
prefix: "SDKMANRC_"
- name: "Determine Java Version"
run: echo "SDKMANRC_java=${{ env.SDKMANRC_java }}" | sed 's/-.*//' >> $GITHUB_ENV
- name: "☕️ Setup JDK"
uses: actions/setup-java@v6
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.SDKMANRC_java }}
- name: "🦊 Install Groovy ${{ env.SDKMANRC_groovy }}"
run: |
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install groovy ${{ env.SDKMANRC_groovy }} < /dev/null
echo "$HOME/.sdkman/candidates/groovy/current/bin" >> $GITHUB_PATH
- name: "🔍 Verify repository structure"
run: groovy .github/scripts/verify-repository.groovy
run: bash .github/scripts/groovy.sh .github/scripts/verify-repository.groovy
build:
name: "Build & Test"
needs: verify
Expand Down Expand Up @@ -89,7 +71,7 @@ jobs:
--stacktrace
--rerun-tasks
- name: "☕️ Setup JDK 21 for the convention plugin tests"
# GrailsLineSpec also builds a Grails 8 consumer, whose Gradle plugin needs Java 21
# GrailsLineSpec also builds Grails 8 and 9 consumers, whose Gradle plugins need Java 21
id: setup-java-21
if: ${{ github.repository == 'grails-plugins/grails-plugin-template' && !contains(github.event.head_commit.message, '[skip tests]') }}
uses: actions/setup-java@v6
Expand Down
31 changes: 4 additions & 27 deletions .github/workflows/update-contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ permissions:
contents: write
pull-requests: write

env:
JAVA_DISTRIBUTION: 'liberica'

jobs:
update-contributors:
# Contributors are only maintained in the plugin repos this workflow is synced to
if: ${{ github.repository != 'grails-plugins/grails-plugin-template' }}
runs-on: ubuntu-24.04
steps:
# A pull request opened with GITHUB_TOKEN never triggers workflows, so on a
Expand All @@ -44,7 +43,7 @@ jobs:
- name: "🔑 Mint GitHub App token"
id: app-token
if: steps.app-creds.outputs.available == 'true'
uses: actions/create-github-app-token@v2
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
Expand All @@ -54,33 +53,11 @@ jobs:
with:
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}

- name: "Export .sdkmanrc properties"
uses: apache/grails-github-actions/export-gradle-properties@asf
with:
file: ".sdkmanrc"
prefix: "SDKMANRC_"

- name: "Determine Java Version"
run: echo "SDKMANRC_java=${{ env.SDKMANRC_java }}" | sed 's/-.*//' >> $GITHUB_ENV

- name: "☕️ Setup JDK"
uses: actions/setup-java@v6
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.SDKMANRC_java }}

- name: "🦊 Install Groovy ${{ env.SDKMANRC_groovy }}"
run: |
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install groovy ${{ env.SDKMANRC_groovy }} < /dev/null
echo "$HOME/.sdkman/candidates/groovy/current/bin" >> $GITHUB_PATH

- name: "👥 Update contributors in project.yml"
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: groovy .github/scripts/update-contributors.groovy
run: bash .github/scripts/groovy.sh .github/scripts/update-contributors.groovy

- name: "📝 Commit if changed"
env:
Expand Down
29 changes: 2 additions & 27 deletions .github/workflows/update-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ permissions:
contents: write
pull-requests: write

env:
JAVA_DISTRIBUTION: 'liberica'

jobs:
update-versions:
runs-on: ubuntu-24.04
Expand All @@ -46,7 +43,7 @@ jobs:
- name: "🔑 Mint GitHub App token"
id: app-token
if: steps.app-creds.outputs.available == 'true'
uses: actions/create-github-app-token@v2
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
Expand All @@ -58,33 +55,11 @@ jobs:
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: "Export .sdkmanrc properties"
uses: apache/grails-github-actions/export-gradle-properties@asf
with:
file: ".sdkmanrc"
prefix: "SDKMANRC_"

- name: "Determine Java Version"
run: echo "SDKMANRC_java=${{ env.SDKMANRC_java }}" | sed 's/-.*//' >> $GITHUB_ENV

- name: "☕️ Setup JDK"
uses: actions/setup-java@v6
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.SDKMANRC_java }}

- name: "🦊 Install Groovy ${{ env.SDKMANRC_groovy }}"
run: |
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install groovy ${{ env.SDKMANRC_groovy }} < /dev/null
echo "$HOME/.sdkman/candidates/groovy/current/bin" >> $GITHUB_PATH

- name: "🔢 Update versions in project.yml and generate index.html"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: groovy .github/scripts/update-versions.groovy
run: bash .github/scripts/groovy.sh .github/scripts/update-versions.groovy

- name: "📝 Commit project.yml if changed"
env:
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.id.startsWith('config.')) {
useModule('org.grails.plugins.gradle:grails-plugin-conventions:1.0.0-RC3')
useModule('org.grails.plugins.gradle:grails-plugin-conventions:1.0.0-RC6')
}
}
}
Expand Down
Loading