Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release / Utility script #7399

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ out/
package-lock.json
rebel.xml
release/jetty/*
release-build.sh
schemas/*/doc/*/*.rst
schematrons/.build
target/
Expand Down
95 changes: 95 additions & 0 deletions release-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash

buildRequiredApps=( "java" "git" "mvn" "ant" "xmlstarlet" )

for app in "${buildRequiredApps[@]}"; do :
if ! [ -x "$(command -v ${app})" ]; then
echo "Error: ${app} is not installed." >&2
exit 1
fi
done

function showUsage
{
echo -e "\nThis script is used to build a release for the current branch"
echo
}

if [ "$1" = "-h" ]
then
showUsage
exit
fi

projectVersion=`xmlstarlet sel -t -m "/_:project/_:version" -v . -n pom.xml`
subVersion=`cut -d "-" -f 2 <<< $projectVersion`
mainVersion=`cut -d "-" -f 1 <<< $projectVersion`
mainVersionMajor=`cut -d "." -f 1 <<< $mainVersion`
mainVersionMinor=`cut -d "." -f 2 <<< $mainVersion`
mainVersionSub=`cut -d "." -f 3 <<< $mainVersion`

gitBranch=`git branch --show-current`

nextVersionNumber="${mainVersionMajor}.${mainVersionMinor}.$((mainVersionSub+1))"
previousVersionNumber="${mainVersionMajor}.${mainVersionMinor}.$((mainVersionSub-1))"

ianwallen marked this conversation as resolved.
Show resolved Hide resolved
from=origin
frombranch=origin/${gitBranch}
series=${mainVersionMajor}.${mainVersionMinor}
versionbranch=${gitBranch}
version=${projectVersion}
minorversion=0
release=latest
newversion=${mainVersion}-$minorversion
currentversion=${projectVersion}
previousversion=${previousVersionNumber}
nextversion=${nextVersionNumber}-SNAPSHOT

echo "Creating release for version ${newversion} (from ${currentversion}). Next version will be ${nextversion}. Git branch ${gitBranch}."
read -p "Press enter to continue"

# TODO: Transifex update
# TODO: Changelog

# Update version number (in pom.xml, installer config and SQL)
./update-version.sh $currentversion $newversion

# Generate list of changes
cat <<EOF > docs/changes/changes$newversion.txt
================================================================================
===
=== GeoNetwork $version: List of changes
===
================================================================================
EOF
git log --pretty='format:- %s' $previousversion... >> docs/changes/changes$newversion.txt

# Then commit the new version
git add .
git commit -m "Update version to $newversion"
git tag -a $version -m "Tag for $version release"

# Build the new release
mvn clean install -DskipTests -Pwar -Pwro4j-prebuild-cache

(cd datastorages && mvn clean install -Drelease -DskipTests)


# Download Jetty and create the installer
(cd release && mvn clean install -Pjetty-download && ant)

# Set version number to SNAPSHOT
./update-version.sh $newversion $nextversion

git add .
git commit -m "Update version to $nextversion"


rm release/target/GeoNetwork-$version/geonetwork-bundle-$newversion.zip.MD5
if [[ ${OSTYPE:0:6} == 'darwin' ]]; then
md5 -r web/target/geonetwork.war > web/target/geonetwork.war.md5
md5 -r release/target/GeoNetwork-$newversion/geonetwork-bundle-$newversion.zip > release/target/GeoNetwork-$newversion/geonetwork-bundle-$newversion.zip.md5
else
(cd web/target && md5sum geonetwork.war > geonetwork.war.md5)
(cd release/target/GeoNetwork-$version && md5sum geonetwork-bundle-$newversion.zip > geonetwork-bundle-$newversion.zip.md5)
fi
48 changes: 48 additions & 0 deletions release-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

function showUsage
{
echo -e "\nThis script is used to publish a release on sourceforge, github and maven repository"
echo
echo -e "Usage: ./`basename` sourceforge_username"
echo
echo -e "Example:"
echo -e "\t./`basename ` sourceforgeusername"
echo
}

if [ "$1" = "-h" ]
then
showUsage
exit
fi

if [ $# -ne 1 ]
then
showUsage
exit
fi

projectVersion=`xmlstarlet sel -t -m "/_:project/_:version" -v . -n pom.xml`
version=`cut -d "-" -f 1 <<< $projectVersion`
versionbranch=`git branch --show-current`
sourceforge_username=$1

sftp $sourceforge_username,geonetwork@frs.sourceforge.net << EOT
cd /home/frs/project/g/ge/geonetwork/GeoNetwork_opensource
mkdir v${version}
cd v${version}
put docs/changes/changes{$version}-0.txt
put release/target/GeoNetwork*/geonetwork-bundle*.zip*
put web/target/geonetwork.war*
put datastorages/*/target/*.zip
bye
EOT


# Push the branch and tag
git push origin $versionbranch
git push origin $version

# Deploy to osgeo repository (requires credentials in ~/.m2/settings.xml)
mvn deploy -Drelease