forked from sonatype-nexus-community/DevAudit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-release.sh
executable file
·60 lines (58 loc) · 1.75 KB
/
build-release.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
#!/bin/bash
if [[ $# -lt 4 ]]; then
echo Usage is ./build-release.sh major minor patch build [special].
exit 1
fi
MAJOR=$1
MINOR=$2
PATCH=$3
BUILD=$4
if [[ $# -eq 5 ]];
then
SPECIAL="-$5"
else
SPECIAL=""
fi
TAG=v$MAJOR.$MINOR.x
BUILD_TAG=$MAJOR.$MINOR.$PATCH.$BUILD
RELEASE_TAG=$MAJOR.$MINOR.$PATCH.$BUILD$SPECIAL
BUILD_DIR=DevAudit.$TAG.Build_$BUILD
if [ -d "$BUILD_DIR" ]; then
echo Deleting $BUILD_DIR.
rm -rf "$BUILD_DIR"
fi
git clone --branch "$TAG" https://github.com/OSSIndex/DevAudit $BUILD_DIR
if [[ $? -ne 0 ]]; then
echo An error occurred during checkout of branch $TAG.
exit 1
fi
if [ ! -f $BUILD_DIR/DevAudit.sln ]; then
echo Could not find the solution file $BUILD_DIR/DevAudit.sln. An error may have occurred during git checkout.
exit 2
fi
if [ -d "$RELEASE_TAG" ]; then
echo Deleting $RELEASE_TAG.
rm -rf "$RELEASE_TAG"
fi
mkdir $RELEASE_TAG
mkdir $RELEASE_TAG/DevAudit
RELEASE_DIR=$RELEASE_TAG/DevAudit
mono .nuget/nuget.exe restore $BUILD_DIR/DevAudit.sln && msbuild $BUILD_DIR/DevAudit.sln /verbosity:diagnostic /p:Configuration=RuntimeDebug /p:VersionAssembly=$BUILD_TAG
if [[ $? -ne 0 ]]; then
echo An error occurred during build in $BUILD_DIR.
rm -rf "$BUILD_DIR"
rm -rf "$RELEASE_DIR"
exit 3
fi
cp -R $BUILD_DIR/DevAudit.CommandLine/bin/Debug/* $RELEASE_DIR
mkdir $RELEASE_DIR/Examples && cp -R $BUILD_DIR/Examples/* $RELEASE_DIR/Examples
copy ./README.md %RELEASE_DIR%
copy ./LICENSE %RELEASE_DIR%
cp $BUILD_DIR/BuildCommon/devaudit-run-linux.sh $RELEASE_DIR
mv $RELEASE_DIR/devaudit-run-linux.sh $RELEASE_DIR/devaudit
chmod +x $RELEASE_DIR/devaudit
cd $RELEASE_TAG
tar -cvzf ../DevAudit-$RELEASE_TAG.tgz DevAudit
cd ..
rm -rf "$BUILD_DIR"
echo Release $RELEASE_TAG created in directory $RELEASE_DIR and archive DevAudit-$RELEASE_TAG.tgz.