Decouple views-gradle-plugin
from dependencies
#377
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Groovy Joint Validation Build" | |
on: | |
push: | |
branches: | |
- '[3-9]+.[0-9]+.x' | |
pull_request: | |
branches: | |
- '[3-9]+.[0-9]+.x' | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build_groovy: | |
runs-on: ubuntu-latest | |
outputs: | |
groovyVersion: ${{ steps.groovy-version.outputs.value }} | |
steps: | |
- name: "☕️ Setup JDK" | |
uses: actions/setup-java@v4 | |
with: | |
distribution: liberica | |
java-version: 17 | |
- name: "🗄️ Cache local Maven repository" | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: cache-local-maven-${{ github.sha }} | |
- name: "📥 Checkout Grails Views to fetch Gradle Plugin versions it uses" | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout-cone-mode: false | |
sparse-checkout: settings.gradle | |
- name: "📝 Store the Gradle Plugin versions used in Grails Views" | |
id: gradle-plugin-versions | |
run: | | |
DEVELOCITY_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.develocity\"\|'"'com.gradle.develocity'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:]) | |
COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.common-custom-user-data-gradle-plugin\"\|'"'com.gradle.common-custom-user-data-gradle-plugin'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:]) | |
echo "Project uses Develocity Plugin version: $DEVELOCITY_PLUGIN_VERSION" | |
echo "Project uses Common Custom User Data Plugin version: $COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" | |
echo "develocity_plugin_version=$DEVELOCITY_PLUGIN_VERSION" >> $GITHUB_OUTPUT | |
echo "common_custom_user_data_plugin_version=$COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT | |
rm settings.gradle | |
- name: "📥 Checkout Groovy 4_0_X (Grails 7 and later)" | |
run: git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch | |
- name: "🐘 Setup Gradle" | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} | |
- name: "📝 Store Groovy version to use when building Grails Views" | |
id: groovy-version | |
run: | | |
cd groovy | |
GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]') | |
echo "Groovy version $GROOVY_VERSION stored" | |
echo "value=$GROOVY_VERSION" >> $GITHUB_OUTPUT | |
- name: "🐘 Configure Gradle Plugins (Step 1/3)" | |
id: develocity-conf-1 | |
run: | | |
echo "VALUE<<EOF" >> $GITHUB_OUTPUT | |
echo "plugins { " >> $GITHUB_OUTPUT | |
echo " id 'com.gradle.develocity' version '${{ steps.gradle-plugin-versions.outputs.develocity_plugin_version }}'" >> $GITHUB_OUTPUT | |
echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle-plugin-versions.outputs.common_custom_user_data_plugin_version }}'" >> $GITHUB_OUTPUT | |
echo "}" >> $GITHUB_OUTPUT | |
echo "" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: "🐘 Configure Gradle Plugins (Step 2/3)" | |
id: develocity-conf-2 | |
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 " 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 " 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 | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: "🐘 Configure Gradle Plugins (step 3/3)" | |
run: | | |
cd groovy | |
# Delete existing plugins from settings.gradle file | |
sed -i '32,37d' settings.gradle | |
# Add Develocity setup related configuration after line no 31 in settings.gradle | |
echo "${{ steps.develocity-conf-1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle | |
# Delete existing buildCache configuration from gradle/build-scans.gradle file | |
sed -i '23,46d' gradle/build-scans.gradle | |
# 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 | |
steps: | |
- name: "📥 Checkout project" | |
uses: actions/checkout@v4 | |
- name: "☕️ Setup JDK" | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: liberica | |
- name: "🐘 Setup Gradle" | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} | |
- name: "🗄️ Restore local Maven repository from cache" | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: cache-local-maven-${{ github.sha }} | |
- name: "🪶 Add mavenLocal repository to build" | |
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 | |
-PgroovyVersion=${{needs.build_groovy.outputs.groovyVersion}} | |
-x groovydoc |