-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpsakefile.ps1
More file actions
77 lines (63 loc) · 2.61 KB
/
psakefile.ps1
File metadata and controls
77 lines (63 loc) · 2.61 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Task Publish -Depends Pack {
Exec { docker login docker.io --username=tiksn }
foreach ($VersionTag in $script:VersionTags) {
$localTag = ($script:imageName + ":" + $VersionTag)
$remoteTag = ("docker.io/" + $localTag)
Exec { docker tag $localTag $remoteTag }
Exec { docker push $remoteTag }
try {
Exec { keybase chat send --nonblock --private lionize "BUILD: Published $remoteTag" }
}
catch {
Write-Warning "Failed to send notification"
}
}
}
Task Pack -Depends Build, EstimateVersions {
$tagsArguments = @()
foreach ($VersionTag in $script:VersionTags) {
$tagsArguments += "-t"
$tagsArguments += ($script:imageName + ":" + $VersionTag)
}
Exec { docker build -f Dockerfile $script:publishFolder $tagsArguments }
}
Task EstimateVersions {
$script:VersionTags = @()
if ($Latest) {
$script:VersionTags += 'latest'
}
if (!!($Version)) {
$Version = [Version]$Version
Assert ($Version.Revision -eq -1) "Version should be formatted as Major.Minor.Patch like 1.2.3"
Assert ($Version.Build -ne -1) "Version should be formatted as Major.Minor.Patch like 1.2.3"
$Version = $Version.ToString()
$script:VersionTags += $Version
}
Assert $script:VersionTags "No version parameter (latest or specific version) is passed."
}
Task Build -Depends TranspileModels {
$script:publishFolder = Join-Path -Path $script:trashFolder -ChildPath "publish"
New-Item -Path $script:publishFolder -ItemType Directory | Out-Null
$project = Resolve-Path ".\src\WebAPI\WebAPI.csproj"
$project = $project.Path
Exec { dotnet publish $project --configuration Release --output $script:publishFolder }
}
Task TranspileModels -Depends Init, Clean {
$apiModelYaml = (Resolve-Path ".\src\ApiModels.yml").Path
$apiModelOutput = Join-Path -Path ".\src\WebAPI" -ChildPath "Models"
Exec { smite --input-file $apiModelYaml --lang csharp --field property --output-folder $apiModelOutput }
}
Task Clean -Depends Init {
Get-ChildItem .\ -Include bin, obj -Recurse | ForEach-Object ($_) {
Remove-Item $_.fullname -Force -Recurse
}
}
Task Init {
$date = Get-Date
$ticks = $date.Ticks
$script:imageName = "tiksn/lionize-habitica-task-provider-service"
$script:trashFolder = Join-Path -Path . -ChildPath ".trash"
$script:trashFolder = Join-Path -Path $script:trashFolder -ChildPath $ticks.ToString("D19")
New-Item -Path $script:trashFolder -ItemType Directory | Out-Null
$script:trashFolder = Resolve-Path -Path $script:trashFolder
}