Skip to content

Commit

Permalink
Move release build properties to separate file (geonetwork#5348)
Browse files Browse the repository at this point in the history
* Moved "global" props to build.properties file

* Fixed shell scripts to replace versions in build.properties

* Additional updates for updateReleaseVersions.sh

- Version check fixes to in case a version number has more than 1 digit.
- Fix path for documents conf.py update

* Update updateBranchVersions.sh

- Version check fixes to in case a version number has more than 1 digit.
- Fix path for documents conf.py update

* Fix regular expression in updateReleaseVersions.sh

* Update resetReleaseVersions.sh

- Version check fixes to in case a version number has more than 1 digit.
- Fix path for documents conf.py update

Co-authored-by: josegar74 <[email protected]>
  • Loading branch information
GeoSander and josegar74 committed Jun 25, 2021
1 parent dd5e443 commit b8f876b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 90 deletions.
15 changes: 15 additions & 0 deletions release/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# General properties
appName=GeoNetwork
displayName=GeoNetwork opensource
homepage=https://geonetwork-opensource.org
supportEmail=[email protected]

# Application version properties
version=4.0.6
subVersion=SNAPSHOT

# Java runtime properties
javaVersion=1.8.0
javaDisplayVersion=8
jreUrl=https://adoptopenjdk.net/?variant=openjdk8
jreName=AdoptOpenJDK
94 changes: 30 additions & 64 deletions release/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,19 @@
<os family="unix"/>
</condition>

<!-- Project build properties -->
<property name="appName" value="GeoNetwork"/>
<property name="displayName" value="GeoNetwork opensource"/>
<property name="homepage" value="https://geonetwork-opensource.org"/>
<property name="version" value="4.0.6"/>
<property name="subVersion" value="SNAPSHOT"/>
<property name="javaVersion" value="1.8.0"/>
<property name="jreUrl" value="http://openjdk.java.net/"/>
<property name="OS" value="Compiled on ${os.name} (${osys})"/>
<property name="propsdir" value="../.props"/>
<!-- Import global build properties -->
<property file="./build.properties"/>

<!-- Additional build properties -->
<property name="bundleName" value="geonetwork-bundle"/>
<property name="propsdir" value="target/props"/>
<property name="ant.build.javac.target" value="1.8"/>
<property name="debugOn" value="on"/>

<!-- Used for copyright year -->
<!-- Copyright year and build date properties -->
<tstamp>
<format property="year" pattern="yyyy"/>
<format property="buildDate" pattern="dd-M-yyyy" />
</tstamp>

<!-- =================================================================================== -->
Expand All @@ -69,43 +66,17 @@
<mkdir dir="${propsdir}"/>

<!-- Extract Git properties -->
<exec executable="git" dir=".." output="git.properties">
<exec executable="git" dir=".." output="target/git.properties">
<arg value="remote"/>
<arg value="-v"/>
</exec>
<property prefix="git" file="git.properties"/>
<property prefix="git" file="target/git.properties"/>

<exec executable="git" dir=".." output="git2.properties">
<exec executable="git" dir=".." output="target/git2.properties">
<arg value="log"/>
<arg value="--max-count=1"/>
</exec>
<property prefix="git2" file="git2.properties"/>

<!-- Update the properties file -->
<propertyfile
file="../web/src/main/webapp/WEB-INF/server.prop"
comment="GeoNetwork opensource properties. These are also used by geonetwork at runtime">
<!-- These are used by geonetwork at runtime -->
<!-- DO NOT REMOVE!! -->
<entry key="version" value="${version}"/>
<entry key="subVersion" value="${subVersion}"/>
<entry key="release" value="${version}"/>

<entry key="javaVersion" value="${javaVersion}"/>
<entry key="jre_url" value="${jreUrl}"/>
<entry key="ant.build.javac.target" value="1.8"/>
<entry key="buildDate" type="date" value="now"
pattern="yyyy-MM-dd'T'HH:mm:ssZ"/>

<entry key="date" type="date" value="now" pattern="yymmddHHmm"/>
<entry key="day" type="date" value="now" pattern="dd-M-yyyy"/>
<entry key="OS" value="${OS}"/>
<entry key="debugOn" value="${debugOn}"/>

<entry key="git_revision" value="${git2.commit}"/>
<entry key="git_url" value="${git.origin}"/>

</propertyfile>
<property prefix="git2" file="target/git2.properties"/>

<!-- Make sure all files that we need have their version numbers etc. updated -->

Expand All @@ -120,15 +91,12 @@
filtering="on" overwrite="yes"/>

<echo message="Replacing template variables in readme files..."/>
<replace file="${propsdir}/readme.html"
propertyFile="../web/src/main/webapp/WEB-INF/server.prop">
<replacefilter token="@version@" property="version"/>
<replacefilter token="@subVersion@" property="subVersion"/>
<replacefilter token="@day@" property="day"/>
<replacefilter token="@jreUrl@" property="jre_url"/>
<replacefilter token="@javaVersion@" property="javaVersion"/>
</replace>
<!-- Replace variables in ReadMe file that are not in server.prop -->

<replace file="${propsdir}/readme.html" token="@version@" value="${version}"/>
<replace file="${propsdir}/readme.html" token="@subVersion@" value="${subVersion}"/>
<replace file="${propsdir}/readme.html" token="@day@" value="${buildDate}" />
<replace file="${propsdir}/readme.html" token="@jreUrl@" value="${jreUrl}"/>
<replace file="${propsdir}/readme.html" token="@javaVersion@" value="${javaVersion}"/>
<replace file="${propsdir}/readme.html" token="@appName@" value="${appName}"/>
<replace file="${propsdir}/readme.html" token="@displayName@" value="${displayName}"/>
<replace file="${propsdir}/readme.html" token="@homepage@" value="${homepage}"/>
Expand All @@ -143,38 +111,36 @@

<!-- Create ZIP distribution for GeoNetwork + Jetty + shell scripts -->
<target name="zip">
<property file="../web/src/main/webapp/WEB-INF/server.prop"/>

<delete dir="../${appName}-${release}"/>
<mkdir dir="../${appName}-${release}"/>
<mkdir dir="target/${appName}-${version}"/>

<echo message="Creating ZIP file for ${appName} ${release}..."/>
<echo message="Creating ZIP file for ${appName} ${version}..."/>

<zip destfile="../${appName}-${release}/${appName}-${release}-${subVersion}.zip">
<zip destfile="target/${appName}-${version}/${bundleName}-${version}-${subVersion}.zip">
<zipfileset dir="./bin" excludes="**.sh" prefix="bin" />
<zipfileset dir="./bin" includes="**.sh" prefix="bin" filemode="774"/>
<zipfileset dir="../.props" includes="readme.html, license.html" />
<zipfileset dir="${propsdir}" includes="readme.html, license.html" />
<zipfileset dir="./jetty" prefix="jetty" excludes="logs/*.log, logs/archive/*.log" />
<zipfileset dir="../web/target/geonetwork" prefix="web/geonetwork" />
<!-- Use war to include META-INF/MANIFEST.MF file -->
<zipfileset src="../web/target/geonetwork.war" prefix="web/geonetwork" />
<zipfileset dir="./data" prefix="web/geonetwork/data" />
<zipfileset dir="./schemaPlugins" prefix="web/geonetwork/WEB-INF/data/config/schema_plugins" />
</zip>

<checksum file="../${appName}-${release}/${appName}-${release}-${subVersion}.zip"
pattern="{0} {1}"
forceOverwrite="yes"/>
<checksum
file="target/${appName}-${version}/${bundleName}-${version}-${subVersion}.zip"
forceOverwrite="yes"/>

</target>

<!-- Copy and rename WAR file and calculate checksum -->
<target name="war" depends="zip">

<copy file="../web/target/geonetwork.war"
tofile="../${appName}-${release}/${appName}-${release}-${subVersion}.war" />
tofile="target/${appName}-${version}/${appName}-${version}-${subVersion}.war" />

<checksum file="../${appName}-${release}/${appName}-${release}-${subVersion}.war"
pattern="{0} {1}"
<checksum file="target/${appName}-${version}/${appName}-${version}-${subVersion}.war"
forceOverwrite="yes"/>

</target>

</project>
15 changes: 9 additions & 6 deletions resetReleaseVersions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ then
fi


if [[ $1 != [0-9].[0-9].[0-9] ]]; then
if [[ $1 =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo
else
echo
echo 'Update failed due to incorrect versionnumber format: ' $1
echo 'The format should be three numbers separated by dots. e.g.: 2.7.0'
Expand All @@ -40,7 +42,9 @@ if [[ $1 != [0-9].[0-9].[0-9] ]]; then
exit
fi

if [[ $2 != [0-9].[0-9].[0-9] ]]; then
if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo
else
echo
echo 'Update failed due to incorrect new versionnumber format (' $2 ')'
echo 'The format should be three numbers separated by dots. e.g.: 2.7.1'
Expand All @@ -63,11 +67,10 @@ echo 'sed will use the following option: ' $sedopt
echo

# Update version in sphinx doc files
sed $sedopt "s/${version}/${new_version}/g" docs/eng/users/source/conf.py
sed $sedopt "s/${version}/${new_version}/g" docs/eng/developer/source/conf.py
sed $sedopt "s/${version}/${new_version}/g" docs/manuals/source/conf.py

# Update ZIP distribution
sed $sedopt "s/\<property name=\"version\" value=\"${version}\" \/\>/\<property name=\"version\" value=\"${new_version}\" \/\>/g" release/build.xml
# Update release version
sed $sedopt "s/version=${version}/version=${new_version}/g" release/build.properties

# Update version pom files
find . -name pom.xml -exec sed $sedopt "s/${version}/${new_version}/g" {} \;
10 changes: 5 additions & 5 deletions update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ echo ' * updating docs/manuals/source/conf.py'
sed $sedopt "s/${version}/${new_version_main}/g" docs/manuals/source/conf.py
echo

# Update ZIP distro
echo 'ZIP distribution'
echo ' * updating release/build.xml'
sed $sedopt "s/property name=\"version\" value=\".*\"/property name=\"version\" value=\"${new_version_main}\"/g" release/build.xml
sed $sedopt "s/property name=\"subVersion\" value=\".*\"/property name=\"subVersion\" value=\"${sub_version}\"/g" release/build.xml
# Update release properties
echo 'Release (ZIP bundle)'
echo ' * updating release/build.properties'
sed $sedopt "s/version=.*/version=${new_version_main}/g" release/build.properties
sed $sedopt "s/subVersion=.*/subVersion=${sub_version}/g" release/build.properties
echo

# Update SQL - needs improvements
Expand Down
19 changes: 11 additions & 8 deletions updateBranchVersions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ then
exit
fi

if [[ $1 != [0-9].[0-9].[0-9] ]]; then
if [[ $1 =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo
else
echo
echo 'Update failed due to incorrect versionnumber format (' $1 ')'
echo 'The format should be three numbers separated by dots. e.g.: 2.7.0'
Expand All @@ -36,7 +38,9 @@ if [[ $1 != [0-9].[0-9].[0-9] ]]; then
exit
fi

if [[ $2 != [0-9].[0-9].[0-9] ]]; then
if [[ $2 =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo
else
echo
echo 'Update failed due to incorrect new versionnumber format (' $2 ')'
echo 'The format should be three numbers separated by dots. e.g.: 2.7.1'
Expand All @@ -62,12 +66,11 @@ version="$1"
new_version="$2"

# Update version in sphinx doc files
sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" docs/eng/users/source/conf.py
sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" docs/eng/developer/source/conf.py
sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" docs/manuals/source/conf.py

# Update ZIP distribution
sed $sedopt "s/\<property name=\"version\" value=\"${version}\" \/\>/\<property name=\"version\" value=\"${new_version}\" \/\>/g" release/build.xml
sed $sedopt "s/\<property name=\"subVersion\" value=\"0\" \/\>/\<property name=\"subVersion\" value=\"SNAPSHOT\" \/\>/g" release/build.xml
# Update release properties
sed $sedopt "s/version=${version}/version=${new_version}/g" release/build.properties
sed $sedopt "s/subVersion=0/subVersion=SNAPSHOT/g" release/build.properties

# Update version pom files
find . -name pom.xml -exec sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" {} \;
find . -name pom.xml -exec sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" {} \;
14 changes: 7 additions & 7 deletions updateReleaseVersions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ then
exit
fi

if [[ $1 != [0-9].[0-9].[0-9] ]]; then
echo
if [[ $1 =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo
else
echo 'Update failed due to incorrect versionnumber format: ' $1
echo 'The format should be three numbers separated by dots. e.g.: 2.7.0'
echo
Expand All @@ -51,11 +52,10 @@ echo
version="$1"

# Update version in sphinx doc files
sed $sedopt "s/${version}-SNAPSHOT/${version}/g" docs/eng/users/source/conf.py
sed $sedopt "s/${version}-SNAPSHOT/${version}/g" docs/eng/developer/source/conf.py
sed $sedopt "s/${version}-SNAPSHOT/${version}/g" docs/manuals/source/conf.py

# Update ZIP distribution
sed $sedopt "s/\<property name=\"subVersion\" value=\"SNAPSHOT\" \/\>/\<property name=\"subVersion\" value=\"0\" \/\>/g" release/build.xml
# Update release subversion
sed $sedopt "s/subVersion=SNAPSHOT/subVersion=0/g" release/build.properties

# Update version pom files
find . -name pom.xml -exec sed $sedopt "s/${version}-SNAPSHOT/${version}/g" {} \;
find . -name pom.xml -exec sed $sedopt "s/${version}-SNAPSHOT/${version}/g" {} \;

0 comments on commit b8f876b

Please sign in to comment.