-
Notifications
You must be signed in to change notification settings - Fork 42
147 lines (146 loc) · 7.44 KB
/
groovy-joint-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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