-
Notifications
You must be signed in to change notification settings - Fork 1
/
release-setup.sh
executable file
·145 lines (121 loc) · 4.69 KB
/
release-setup.sh
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
#!/bin/bash
set -ve
# release should always happen from a dedicated branch, SOURCE_BRANCH must be set
if [ -z "${SOURCE_BRANCH}" ]; then
echo "SOURCE_BRANCH variable not set and it is mandatory."
exit 1;
fi
# VERSION is mandatory
if [ -z "${VERSION}" ]; then
echo "VERSION variable not set and it is mandatory."
exit 1;
fi
echo "Will build version '$VERSION' off of branch '$SOURCE_BRANCH'"
# removes any dash, performs toLower
toVersionCatalogName () {
replacement=""
input=$1
cleaned=$(echo "${input//-/"$replacement"}")
lower=$(echo "$cleaned" | tr '[:upper:]' '[:lower:]')
echo $lower
}
# the core components
declare -a components=("Runtime-Metamodel" "GradlePlugins" "Connector" "IdentityHub" "FederatedCatalog")
# create the base settings.gradle.kts file containing the version catalogs
cat << EOF > settings.gradle.kts
rootProject.name = "edc"
// this is needed to have access to snapshot builds of plugins
pluginManagement {
repositories {
mavenLocal()
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
mavenCentral()
mavenLocal()
}
versionCatalogs {
create("runtimemetamodel"){
from("org.eclipse.edc:runtime-metamodel-versions:$VERSION")
}
create("gradleplugins") {
from("org.eclipse.edc:edc-versions:$VERSION")
}
create("connector") {
from("org.eclipse.edc:connector-versions:$VERSION")
}
create("identityhub") {
from("org.eclipse.edc:identity-hub-versions:$VERSION")
}
create("federatedcatalog") {
from("org.eclipse.edc:federated-catalog-versions:$VERSION")
}
}
}
EOF
# create gradle.properties file for the release
cat << EOF > gradle.properties
group=org.eclipse.edc
version=$VERSION
javaVersion=17
annotationProcessorVersion=$VERSION
edcGradlePluginsVersion=$VERSION
edcDeveloperId=mspiekermann
edcDeveloperName=Markus Spiekermann
edcScmConnection=scm:git:[email protected]:eclipse-edc/Connector.git
edcWebsiteUrl=https://github.com/eclipse-edc/Connector.git
edcScmUrl=https://github.com/eclipse-edc/Connector.git
EOF
# clone all the component repositories
for component in "${components[@]}"
do
rm -rf "$component"
git clone -b "$SOURCE_BRANCH" "https://github.com/eclipse-edc/$component"
done
# update the project version
sed -i 's#^version=.*#version='"$VERSION"'#g' $(find . -name "gradle.properties")
# update the eventual core library version in the version catalog
sed -i 's#^edc\s*=\s*.*#edc = "'"$VERSION"'"#g' $(find . -name "libs.versions.toml")
# Copy LICENSE and NOTICE.md files to root, to be included in the jar
cp Connector/LICENSE .
cp Connector/NOTICE.md .
# create a comprehensive DEPENDENCIES file on root, to be included in the jar
cat */DEPENDENCIES | sort -u > DEPENDENCIES
# prebuild and publish plugins and modules to local repository, this needed to permit the all-in-one publish later
for component in "${components[@]}"
do
# publish artifacts to maven local
echo "Build and publish to maven local component $component"
cd "$component"
./gradlew -Pskip.signing "-Pversion=$VERSION" publishToMavenLocal -Dorg.gradle.internal.network.retry.max.attempts=5 -Dorg.gradle.internal.network.retry.initial.backOff=5000
cd ..
done
for component in "${components[@]}"
do
# rename version-catalog module to avoid conflicts
mv ${component}/version-catalog ${component}/${component}-version-catalog-1
sed -i "s#:version-catalog#:${component}-version-catalog-1#g" ${component}/settings.gradle.kts
# copy all the component modules into the main settings, adding the component name in the front of it
cat $component/settings.gradle.kts | grep "include(" | grep -v "system-tests" | grep -v "launcher" | grep -v "data-plane-integration-tests" | sed "s/\":/\":$component:/g" >> settings.gradle.kts
# update all the dependency with the new project tree
sed -i "s#project(\":#project(\":$component:#g" $(find $component -name "build.gradle.kts")
# update all dependency with the new version catalog prefix
versionCatalogName=$(toVersionCatalogName $component)
sed -i "s#(libs\.#(${versionCatalogName}\.#g" $(find $component -name "build.gradle.kts")
# remove unneeded stuff
rm -rf $component/system-tests
rm -rf $component/launcher
rm -rf $component/launchers
done
# runtime metamodel needs its libs file to get the edc-build version to be used
cp Runtime-Metamodel/gradle/libs.versions.toml gradle