Update build.sh

This commit is contained in:
Petrutiu Mihai
2016-07-13 13:57:03 +03:00
committed by Petrutiu Mihai
parent 20aa9e6b7e
commit e75c139e7a

View File

@@ -1,46 +1,29 @@
#!/usr/bin/env bash #!/usr/bin/env bash
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $repoFolder
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" #exit if any command fails
if [ ! -z $KOREBUILD_ZIP ]; then set -e
koreBuildZip=$KOREBUILD_ZIP
artifactsFolder="./artifacts"
if [ -d $artifactsFolder ]; then
rm -R $artifactsFolder
fi fi
buildFolder=".build" dotnet restore
buildFile="$buildFolder/KoreBuild.sh"
if test ! -d $buildFolder; then # Ideally we would use the 'dotnet test' command to test netcoreapp and net451 so restrict for now
echo "Downloading KoreBuild from $koreBuildZip" # but this currently doesn't work due to https://github.com/dotnet/cli/issues/3073 so restrict to netcoreapp
tempFolder="/tmp/KoreBuild-$(uuidgen)" dotnet test ./test/TEST_PROJECT_NAME -c Release -f netcoreapp1.0
mkdir $tempFolder
localZipFile="$tempFolder/korebuild.zip" # Instead, run directly with mono for the full .net version
dotnet build ./test/TEST_PROJECT_NAME -c Release -f net451
retries=6 mono \
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) ./test/TEST_PROJECT_NAME/bin/Release/net451/*/dotnet-test-xunit.exe \
do ./test/TEST_PROJECT_NAME/bin/Release/net451/*/TEST_PROJECT_NAME.dll
echo "Failed to download '$koreBuildZip'"
if [ "$retries" -le 0 ]; then
exit 1
fi
retries=$((retries - 1))
echo "Waiting 10 seconds before retrying. Retries left: $retries"
sleep 10s
done
unzip -q -d $tempFolder $localZipFile revision=${TRAVIS_JOB_ID:=1}
revision=$(printf "%04d" $revision)
mkdir $buildFolder dotnet pack ./src/PROJECT_NAME -c Release -o ./artifacts --version-suffix=$revision
cp -r $tempFolder/**/build/** $buildFolder
chmod +x $buildFile
# Cleanup
if test ! -d $tempFolder; then
rm -rf $tempFolder
fi
fi
$buildFile -r $repoFolder "$@"