Skip to content

Commit 583ce45

Browse files
Gencebay DemirGencebay Demir
authored andcommitted
Build tasks
1 parent d55e603 commit 583ce45

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,6 @@ ModelManifest.xml
240240

241241
# FAKE - F# Make
242242
.fake/
243+
244+
# Build
245+
.build

appveyor.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
init:
2+
- git config --global core.autocrlf true
3+
branches:
4+
only:
5+
- master
6+
- release
7+
- dev
8+
- /^(.*\/)?ci-.*$/
9+
build_script:
10+
- build.cmd --quiet verify
11+
clone_depth: 1
12+
test: off
13+
deploy: off

build.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@ECHO OFF
2+
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"

build.ps1

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
4+
{
5+
while($true)
6+
{
7+
try
8+
{
9+
Invoke-WebRequest $url -OutFile $downloadLocation
10+
break
11+
}
12+
catch
13+
{
14+
$exceptionMessage = $_.Exception.Message
15+
Write-Host "Failed to download '$url': $exceptionMessage"
16+
if ($retries -gt 0) {
17+
$retries--
18+
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
19+
Start-Sleep -Seconds 10
20+
21+
}
22+
else
23+
{
24+
$exception = $_.Exception
25+
throw $exception
26+
}
27+
}
28+
}
29+
}
30+
31+
cd $PSScriptRoot
32+
33+
$repoFolder = $PSScriptRoot
34+
$env:REPO_FOLDER = $repoFolder
35+
36+
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip"
37+
if ($env:KOREBUILD_ZIP)
38+
{
39+
$koreBuildZip=$env:KOREBUILD_ZIP
40+
}
41+
42+
$buildFolder = ".build"
43+
$buildFile="$buildFolder\KoreBuild.ps1"
44+
45+
if (!(Test-Path $buildFolder)) {
46+
Write-Host "Downloading KoreBuild from $koreBuildZip"
47+
48+
$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid()
49+
New-Item -Path "$tempFolder" -Type directory | Out-Null
50+
51+
$localZipFile="$tempFolder\korebuild.zip"
52+
53+
DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6
54+
55+
Add-Type -AssemblyName System.IO.Compression.FileSystem
56+
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)
57+
58+
New-Item -Path "$buildFolder" -Type directory | Out-Null
59+
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse
60+
61+
# Cleanup
62+
if (Test-Path $tempFolder) {
63+
Remove-Item -Recurse -Force $tempFolder
64+
}
65+
}
66+
67+
&"$buildFile" $args

build.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
cd $repoFolder
4+
5+
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip"
6+
if [ ! -z $KOREBUILD_ZIP ]; then
7+
koreBuildZip=$KOREBUILD_ZIP
8+
fi
9+
10+
buildFolder=".build"
11+
buildFile="$buildFolder/KoreBuild.sh"
12+
13+
if test ! -d $buildFolder; then
14+
echo "Downloading KoreBuild from $koreBuildZip"
15+
16+
tempFolder="/tmp/KoreBuild-$(uuidgen)"
17+
mkdir $tempFolder
18+
19+
localZipFile="$tempFolder/korebuild.zip"
20+
21+
retries=6
22+
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
23+
do
24+
echo "Failed to download '$koreBuildZip'"
25+
if [ "$retries" -le 0 ]; then
26+
exit 1
27+
fi
28+
retries=$((retries - 1))
29+
echo "Waiting 10 seconds before retrying. Retries left: $retries"
30+
sleep 10s
31+
done
32+
33+
unzip -q -d $tempFolder $localZipFile
34+
35+
mkdir $buildFolder
36+
cp -r $tempFolder/**/build/** $buildFolder
37+
38+
chmod +x $buildFile
39+
40+
# Cleanup
41+
if test ! -d $tempFolder; then
42+
rm -rf $tempFolder
43+
fi
44+
fi
45+
46+
$buildFile -r $repoFolder "$@"

0 commit comments

Comments
 (0)