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

Sugested documentation and demo #6

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
515 changes: 479 additions & 36 deletions README.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions module1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
<parent>
<groupId>io.jitpack</groupId>
<artifactId>example-root</artifactId>
<version>2.0-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<groupId>io.jitpack</groupId>
<artifactId>module1</artifactId>
<version>2.0-SNAPSHOT</version>
<name>module1</name>
<url>http://maven.apache.org</url>
<properties>
Expand Down
5 changes: 2 additions & 3 deletions module2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
<parent>
<groupId>io.jitpack</groupId>
<artifactId>example-root</artifactId>
<version>2.0-SNAPSHOT</version>
<version>${revision}</version>
</parent>

<groupId>io.jitpack</groupId>
<artifactId>module2</artifactId>
<version>2.0-SNAPSHOT</version>
<name>module2</name>
<url>http://maven.apache.org</url>

Expand All @@ -23,7 +22,7 @@
<dependency>
<groupId>io.jitpack</groupId>
<artifactId>module1</artifactId>
<version>2.0-SNAPSHOT</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
37 changes: 30 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,40 @@

<groupId>io.jitpack</groupId>
<artifactId>example-root</artifactId>
<version>2.0-SNAPSHOT</version>
<version>${revision}</version>
<packaging>pom</packaging>
<name>example-root</name>

<modules>
<module>module1</module>
<module>module2</module>
</modules>


<properties>
<revision>1.0.0-local-SNAPSHOT</revision>
</properties>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>default</name>
<value>!disabled</value>
</property>
</activation>
<modules>
<module>module1</module>
<module>module2</module>
</modules>
</profile>
<profile>
<id>testRelease</id>
<modules>
<module>testRelease</module>
</modules>
</profile>
</profiles>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
89 changes: 89 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/sh

TEST_OPTION=$1
if [ "TEST_OPTION" = "help" ]
then
echo " test options
BRANCH - Release Branch Snapshopt like jenkins branch build"
RELEASE_CHECK - do full release process, check for snapshots
RELEASE_NO_CHECK - bypass snapshot check on build
fi

#get the current pom version and store it into a variable
MVN_VERSION=`mvn help:evaluate -Dexpression=project.properties -q -DforceStdout|egrep revision|cut -f2 -d\>|cut -f1 -d\<`
echo "MVN_VERSION=$MVN_VERSION"

GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
echo "GIT_BRANCH=$GIT_BRANCH"
HEAD_SHA=`git rev-parse --short HEAD`
echo "HEAD_SHA=$HEAD_SHA"

#increment the second digit of the version and overwrite the variable
RELEASE_VERSION=$(echo ${MVN_VERSION} | awk -F'.' '{print $1"."$2}' | sed s/[.]$//)".$HEAD_SHA"
echo "RELEASE_VERSION=$RELEASE_VERSION"

BRANCH_VERSION="${RELEASE_VERSION}.${GIT_BRANCH}-SNAPSHOT"
echo "BRANCH_VERSION=$BRANCH_VERSION"

echo "TEST_OPTION=$TEST_OPTION"
case "$TEST_OPTION" in


"RELEASE_CHECK" | "RELEASE_NO_CHECK")
echo "Step 1 Check if releases exit if it does fail."
EXISTING_TAG=`git tag --list | egrep "$RELEASE_VERSION"`
if [ "$EXISTING_TAG" != "" ]
then
echo "ERROR: Tag $RELEASE_VERSION exists, to rebuild version delete tag the re-run"
exit 1
fi

if [ "$TEST_OPTION" = "RELEASE_CHECK" ]
then
#for demo purposes to make the build fail
cp module1/pom.xml module1/pom.xml.bak
sed 's/3.8.1/5.11.0-SNAPSHOT/g' module1/pom.xml.bak >module1/pom.xml
##### test code end

echo "Step 2 check if we have any snapshots, fail build if we do."
SNAPSHOT_DEPENDENCIES=`find . -name pom.xml -exec egrep -H SNAPSHOT {} \;|egrep -v '<revision>.*\..*\..*-SNAPSHOT</revision>'`
#echo "SNAPSHOT_DEPENDENCIES=$SNAPSHOT_DEPENDENCIES"
if [ "$SNAPSHOT_DEPENDENCIES" != "" ]
then
echo "ERROR: cannot release with SNAPSHOT dependencies."
echo "------------------------------------------------"
echo $SNAPSHOT_DEPENDENCIES
echo "------------------------------------------------"

#for demo cleanup
git co module1/pom.xml

exit 1
fi
else
echo "INFO: Skipping step 2 - checking SNAPSHOT_DEPENDENCIES"
fi

set -e
echo "Step 3 build branch - fail if the build fails for compile or tests we save pushing artifacts."
mvn -Drevision="$RELEASE_VERSION" clean install

echo "Step 4 if the build passes push to nexus."
mvn -Drevision="$RELEASE_VERSION" -DskipTests validate
#mvn -Drevision=$RELEASE_VERSION -DskipTests deploy

echo "Step 4a Validate maven artifacts."
mvn -Drevision="$RELEASE_VERSION" -DskipTests -P testRelease install

echo "Step 5 - Tag the release and push to repo, tag: $RELEASE_VERSION"
git tag $RELEASE_VERSION
git push origin $RELEASE_VERSION
;;

*) echo "BRANCH release."
echo "Step 3 build branch - fail if the build fails for compile or tests we save pushing artifacts."
#mvn -Drevision=$BRANCH_VERSION clean install deploy
mvn -Drevision=$BRANCH_VERSION clean install
;;
esac

29 changes: 29 additions & 0 deletions testRelease/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.jitpack</groupId>
<artifactId>example-root</artifactId>
<version>${revision}</version>
</parent>

<groupId>io.jitpack</groupId>
<artifactId>testrelease</artifactId>
<name>module2</name>
<packaging>pom</packaging>


<dependencies>
<dependency>
<groupId>io.jitpack</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.jitpack</groupId>
<artifactId>module2</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>