Skip to content

Commit 0e09e0b

Browse files
author
Your Name
committed
init
0 parents  commit 0e09e0b

File tree

10 files changed

+419
-0
lines changed

10 files changed

+419
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
target

io_changes.sh

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
function check_current_version {
4+
local expected_version=$1
5+
local xpath='/*[local-name()="project"]/*[local-name()="version"]/text()'
6+
local actual_version=`xmllint --xpath "$xpath" $GIT_ROOT/maven/pom.xml`
7+
if [ $actual_version != $expected_version ] ; then
8+
exit_safe 99 "Unexpected version $actual_version , expected was $expected_version"
9+
fi
10+
}
11+
12+
function check_compile {
13+
cd $GIT_ROOT/maven
14+
mvn clean verify
15+
}
16+
17+
function io_changes {
18+
local create_release=$1
19+
assert_current_branch_name $RELEASE_BRANCH
20+
if [ $create_release = true ] ; then
21+
local new_version=$RELEASE_VERSION
22+
update_versions $new_version
23+
echo remove_version_snapshot $new_version
24+
remove_version_snapshot $new_version
25+
else
26+
local new_version=$FUTURE_DEVELOP_VERSION
27+
update_versions $new_version
28+
echo add_version_snapshot $new_version
29+
local expected_rpm_version_if_adding=$RELEASE_VERSION
30+
add_version_snapshot $new_version $expected_rpm_version_if_adding
31+
fi
32+
}
33+
34+
function update_versions {
35+
local new_version=$1
36+
cd $GIT_ROOT/maven
37+
mvn -o versions:set -DnewVersion=$new_version versions:commit
38+
}
39+
40+
# private
41+
function remove_version_snapshot {
42+
local expected_rpm_version=$1
43+
cd $GIT_ROOT/maven
44+
# rpm.version should be set already to $new_version
45+
egrep "<rpm.version>$expected_rpm_version</rpm.version>" pom.xml
46+
assert_success "Expected $expected_rpm_version inside rpm.version tag"
47+
egrep "<rpm.release>SNAPSHOT<\/rpm.release>" pom.xml
48+
assert_success "Expected SNAPSHOT inside rpm.release tag"
49+
sed -i "s/<rpm.release>SNAPSHOT<\/rpm.release>/\<rpm.release\>0\<\/rpm.release\>/" pom.xml
50+
}
51+
52+
# private
53+
function add_version_snapshot {
54+
local future_version=$1
55+
local expected_rpm_version=$2
56+
cd $GIT_ROOT/_ASSEMBLY_/Install/rpm
57+
local future_version_core=${future_version%-*}
58+
egrep "<rpm.version>$expected_rpm_version</rpm.version>" pom.xml
59+
assert_success "Expected $expected_rpm_version inside rpm.version tag"
60+
egrep "<rpm.release>0<\/rpm.release>" pom.xml
61+
assert_success "Expected 0 inside rpm.release tag"
62+
63+
sed -i "s/<rpm.version>$expected_rpm_version<\/rpm.version>/<rpm.version>$future_version_core<\/rpm.version>/" pom.xml
64+
sed -i "s/<rpm.release>0<\/rpm.release>/<rpm.release>SNAPSHOT<\/rpm.release>/" pom.xml
65+
}

io_changes_tbo.sh

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
function check_compile {
4+
cd $GIT_ROOT/_ASSEMBLY_/Build
5+
mvn clean install -T 3 -e
6+
7+
cd $GIT_ROOT/_ASSEMBLY_/Install/rpm
8+
mvn clean install -T 3 -e
9+
10+
cd $GIT_ROOT/WRMI
11+
grails compile
12+
}
13+
14+
function io_changes {
15+
local create_release=$1
16+
assert_current_branch_name $RELEASE_BRANCH
17+
if [ $create_release = true ] ; then
18+
local new_version=$RELEASE_VERSION
19+
update_versions $new_version
20+
echo remove_version_snapshot $new_version
21+
remove_version_snapshot $new_version
22+
# this might produce no change if source branch != develop:
23+
change_ci_db "CI-DEVELOP" "CI-MASTER"
24+
else
25+
local new_version=$FUTURE_DEVELOP_VERSION
26+
update_versions $new_version
27+
echo add_version_snapshot $new_version
28+
local expected_rpm_version_if_adding=$RELEASE_VERSION
29+
add_version_snapshot $new_version $expected_rpm_version_if_adding
30+
change_ci_db "CI-MASTER" "CI-DEVELOP"
31+
fi
32+
}
33+
34+
function update_versions {
35+
local new_version=$1
36+
cd $GIT_ROOT/_ASSEMBLY_/Build
37+
mvn -o versions:set -DnewVersion=$new_version versions:commit
38+
39+
cd $GIT_ROOT/_ASSEMBLY_/Install/rpm
40+
mvn -o versions:set -DnewVersion=$new_version versions:commit
41+
42+
cd $GIT_ROOT/WRMI
43+
sed -i 's/^app.version.*/app.version='$new_version'/' application.properties
44+
sed -i 's/^version.tbo.*/version.tbo = "'$new_version'"/' grails-app/conf/BuildConfig.groovy
45+
}
46+
47+
# private
48+
function remove_version_snapshot {
49+
local expected_rpm_version=$1
50+
cd $GIT_ROOT/_ASSEMBLY_/Install/rpm
51+
# rpm.version should be set already to $new_version
52+
egrep "<rpm.version>$expected_rpm_version</rpm.version>" pom.xml
53+
assert_success "Expected $expected_rpm_version inside rpm.version tag"
54+
egrep "<rpm.release>SNAPSHOT<\/rpm.release>" pom.xml
55+
assert_success "Expected SNAPSHOT inside rpm.release tag"
56+
sed -i "s/<rpm.release>SNAPSHOT<\/rpm.release>/\<rpm.release\>0\<\/rpm.release\>/" pom.xml
57+
}
58+
59+
# private
60+
function add_version_snapshot {
61+
local future_version=$1
62+
local expected_rpm_version=$2
63+
cd $GIT_ROOT/_ASSEMBLY_/Install/rpm
64+
local future_version_core=${future_version%-*}
65+
egrep "<rpm.version>$expected_rpm_version</rpm.version>" pom.xml
66+
assert_success "Expected $expected_rpm_version inside rpm.version tag"
67+
egrep "<rpm.release>0<\/rpm.release>" pom.xml
68+
assert_success "Expected 0 inside rpm.release tag"
69+
70+
sed -i "s/<rpm.version>$expected_rpm_version<\/rpm.version>/<rpm.version>$future_version_core<\/rpm.version>/" pom.xml
71+
sed -i "s/<rpm.release>0<\/rpm.release>/<rpm.release>SNAPSHOT<\/rpm.release>/" pom.xml
72+
}
73+
74+
#private
75+
function change_ci_db() {
76+
local old_db_user=$1
77+
local new_db_user=$2
78+
cd $GIT_ROOT
79+
sed -i "s/<test.database.group.username>$old_db_user<\/test.database.group.username>/<test.database.group.username>$new_db_user<\/test.database.group.username>/" Data-Service-Group/pom.xml
80+
sed -i "s/<test.database.outlet.username>$old_db_user<\/test.database.outlet.username>/<test.database.outlet.username>$new_db_user<\/test.database.outlet.username>/" Data-Service-Outlet/pom.xml
81+
}

maven/pom.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.foo</groupId>
6+
<artifactId>bar</artifactId>
7+
<version>2.14.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>bar</name>
11+
<url>http://maven.apache.org</url>
12+
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<rpm.version>2.14.0</rpm.version>
16+
<rpm.release>SNAPSHOT</rpm.release>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>junit</groupId>
22+
<artifactId>junit</artifactId>
23+
<version>3.8.1</version>
24+
<scope>test</scope>
25+
</dependency>
26+
</dependencies>
27+
</project>

maven/src/main/java/com/foo/App.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.foo;
2+
3+
/**
4+
* Hello world!
5+
*
6+
*/
7+
public class App
8+
{
9+
public static void main( String[] args )
10+
{
11+
System.out.println( "Hello World!" );
12+
}
13+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.foo;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
7+
/**
8+
* Unit test for simple App.
9+
*/
10+
public class AppTest
11+
extends TestCase
12+
{
13+
/**
14+
* Create the test case
15+
*
16+
* @param testName name of the test case
17+
*/
18+
public AppTest( String testName )
19+
{
20+
super( testName );
21+
}
22+
23+
/**
24+
* @return the suite of tests being tested
25+
*/
26+
public static Test suite()
27+
{
28+
return new TestSuite( AppTest.class );
29+
}
30+
31+
/**
32+
* Rigourous Test :-)
33+
*/
34+
public void testApp()
35+
{
36+
assertTrue( true );
37+
}
38+
}

release.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Before running this script edit release_properties.sh,
4+
# update your master, develop and possibly hotfix branch.
5+
# Switch to $SOURCE_BRANCH, otherwise this script will exit prematurely.
6+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
7+
8+
source $DIR/release_properties.sh
9+
source $DIR/release_messages.sh
10+
source $DIR/release_utils.sh
11+
source $DIR/io_changes.sh
12+
13+
RELEASE_BRANCH="release/$RELEASE_VERSION"
14+
GIT_ROOT=`git rev-parse --show-toplevel`
15+
16+
17+
check_git_directories
18+
check_release_tag_does_not_exist
19+
check_current_version $EXPECTED_CURRENT_VERSION
20+
create_release_branch
21+
io_changes true
22+
check_compile
23+
commit_changes "$(create_release_message)"
24+
merge_release_branch_to "master"
25+
tag_and_push_master
26+
27+
checkout_release_branch
28+
io_changes false
29+
check_compile
30+
commit_changes "$(bump_to_future_develop_message)"
31+
merge_release_branch_to "develop"
32+
push_develop_and_delete_release_branch
33+
34+
update_hotfix_branch

release_messages.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
function tag_message {
4+
echo "TBO Services release $RELEASE_VERSION."
5+
}
6+
7+
function bump_to_future_hotfix_message {
8+
echo "Bump version to ${FUTURE_HOTFIX_VERSION}"
9+
}
10+
11+
function create_release_message {
12+
echo "Create release $RELEASE_VERSION"
13+
}
14+
15+
function bump_to_future_develop_message {
16+
echo "Bump version to ${FUTURE_DEVELOP_VERSION}"
17+
}

release_properties.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
ORIGIN_BRANCH=origin
4+
EXPECTED_CURRENT_VERSION="2.14.0-SNAPSHOT"
5+
# hotfix branch does not have to exist
6+
HOTFIX_BRANCH="2.14.x"
7+
# source branch should be either develop or hotfix branch
8+
SOURCE_BRANCH="develop"
9+
# should be derived from $EXPECTED_CURRENT_VERSION
10+
RELEASE_VERSION="2.14.0"
11+
FUTURE_DEVELOP_VERSION="2.15.0-SNAPSHOT"
12+
# do not forget to add -SNAPSHOT here:
13+
FUTURE_HOTFIX_VERSION="2.14.1-SNAPSHOT"

0 commit comments

Comments
 (0)