Automate grailsw distribution #4983
This file contains hidden or 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
# Licensed to the Apache Software Foundation (ASF) under one or more | |
# contributor license agreements. See the NOTICE file distributed with | |
# this work for additional information regarding copyright ownership. | |
# The ASF licenses this file to You under the Apache License, Version 2.0 | |
# (the "License"); you may not use this file except in compliance with | |
# the License. You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: "Groovy Joint Validation Build" | |
on: | |
push: | |
branches: | |
- '[4-9]+.[0-9]+.x' | |
pull_request: | |
branches: | |
- '[4-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: | |
java-version: 17 | |
distribution: liberica | |
- name: "🗄️ Cache local Maven repository" | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: cache-local-maven-${{ github.sha }} | |
- name: "📥 Checkout Grails Core 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 this project" | |
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.GRAILS_DEVELOCITY_ACCESS_KEY }} | |
- name: "📝 Store Groovy version to use when building Grails" | |
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('GRAILS_DEVELOCITY_ACCESS_KEY ') != null" >> $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-core')" >> $GITHUB_OUTPUT | |
echo " publishing.onlyIf { isAuthenticated }" >> $GITHUB_OUTPUT | |
echo " uploadInBackground = false" >> $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 = isAuthenticated" >> $GITHUB_OUTPUT | |
echo " enabled = true" >> $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)" | |
run: | | |
cd groovy | |
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK | |
build_grails: | |
needs: [build_groovy] | |
runs-on: ubuntu-latest | |
services: | |
mongodb: | |
image: mongo:8 | |
ports: | |
- 27017:27017 | |
options: >- | |
--health-cmd "mongosh --eval 'db.adminCommand(\"ping\")'" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
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.GRAILS_DEVELOCITY_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: 'Swap Groovy Version' | |
run: | | |
sed -i "/['\"]groovy\.version['\"][[:space:]]*:/c\'groovy.version':'${{ needs.build_groovy.outputs.groovyVersion }}'," dependencies.gradle | |
- name: "🔨 Build and test Grails using the locally built Groovy snapshot" | |
run: > | |
./gradlew build | |
-x groovydoc |