-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathpsakefile.ps1
133 lines (109 loc) · 6.19 KB
/
psakefile.ps1
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
properties {
$NUGET_AUTH_TOKEN = $env:NUGET_AUTH_TOKEN
$build_version = $env:build_version
}
Task default -depends Restore, Build
Task Deploy -depends Deploy-packages
Task CI -depends Install-deps, Restore, Gen-Build-Status, Build, Test, Benchmark, Report
Task CD -depends CD-Build, Pack, Deploy
Task CD-Build -depends Install-deps, Restore, Gen-Build-Status, Build, Pack, Publish-wasm
Task Build-dotnet -depends Restore-dotnet, Build
Task Restore -depends Restore-WASM, Restore-dotnet
Task Restore-dotnet {
Exec { dotnet nuget add source https://sparkshine.pkgs.visualstudio.com/StardustDL/_packaging/feed/nuget/v3/index.json -n ownpkgs }
Exec { dotnet restore }
}
Task Build {
Exec { dotnet build -c Release /p:Version=$build_version }
}
Task Install-deps {
Exec { npm install --global gulp }
Exec { dotnet tool install --global Microsoft.Web.LibraryManager.Cli }
Exec { dotnet tool install dotnet-reportgenerator-globaltool --tool-path ./tools }
}
Task Test {
if (-not (Test-Path -Path "reports/test")) {
New-Item -Path "reports/test" -ItemType Directory
}
Exec { dotnet test -c Release --logger GitHubActions /p:CollectCoverage=true /p:CoverletOutput=../../reports/test/coverage.json /p:MergeWith=../../reports/test/coverage.json /maxcpucount:1 }
Exec { dotnet test -c Release ./test/Test.Base --logger GitHubActions /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../../reports/test/coverage.xml /p:MergeWith=../../reports/test/coverage.json }
}
Task Benchmark {
Exec { dotnet run -c Release --project ./test/Benchmark.Base }
}
Task Report {
Exec { ./tools/reportgenerator -reports:./reports/test/coverage.xml -targetdir:./reports/test }
if (-not (Test-Path -Path "reports/benchmark")) {
New-Item -Path "reports/benchmark" -ItemType Directory
}
Copy-Item ./BenchmarkDotNet.Artifacts/* ./reports/benchmark -Recurse
}
Task Pack {
if (-not (Test-Path -Path "packages")) {
New-Item -Path "packages" -ItemType Directory
}
Exec -maxRetries 10 { dotnet pack -c Release /p:Version=$build_version -o ./packages }
}
Task Publish-wasm {
Set-Location ./src/client/AcBlog.Client.WebAssembly
if (-not (Test-Path -Path "publish")) {
New-Item -Path "publish" -ItemType Directory
}
# Move-Item ./wwwroot/data ./data
Exec { dotnet publish -c Release /p:Version=$build_version -o ./publish }
# Move-Item ./data ./wwwroot/data
Set-Location ../../..
}
Task NPMUP? {
Set-Location src/client/AcBlog.Client.UI
Exec { ncu }
Set-Location ../../..
}
Task NPMUP {
Set-Location src/client/AcBlog.Client.UI
Exec { ncu -u }
Exec { npm i }
Set-Location ../../..
}
Task Deploy-packages {
Exec { dotnet nuget update source ownpkgs -u sparkshine -p $NUGET_AUTH_TOKEN --store-password-in-clear-text }
Exec { dotnet nuget push ./packages/AcBlog.Data.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Extensions.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.FileSystem.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.SQLServer.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.Externals.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Sdk.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Tools.Sdk.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Client.Core.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Client.UI.$build_version.nupkg -s ownpkgs -k az --skip-duplicate }
}
Task Deploy-packages-release {
Exec { dotnet nuget push ./packages/AcBlog.Data.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Extensions.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.FileSystem.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.SQLServer.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.Externals.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Sdk.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN --skip-duplicate }
Exec { dotnet nuget push ./packages/AcBlog.Tools.Sdk.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN --skip-duplicate }
}
Task Gen-Build-Status {
Set-Location src/client/AcBlog.Client.WebAssembly.Host
Write-Output "{ ""Build"": { ""Commit"": ""$env:GITHUB_SHA"", ""Branch"": ""$env:GITHUB_REF"", ""BuildDate"": ""$(Get-date)"", ""Repository"": ""$env:GITHUB_REPOSITORY"", ""Version"": ""$env:build_version"" } }" > ./build.json
Set-Location ../AcBlog.Client.WebAssembly
Write-Output "{ ""Build"": { ""Commit"": ""$env:GITHUB_SHA"", ""Branch"": ""$env:GITHUB_REF"", ""BuildDate"": ""$(Get-date)"", ""Repository"": ""$env:GITHUB_REPOSITORY"", ""Version"": ""$env:build_version"" } }" > ./wwwroot/build.json
Set-Location ../AcBlog.Client.Server
Write-Output "{ ""Build"": { ""Commit"": ""$env:GITHUB_SHA"", ""Branch"": ""$env:GITHUB_REF"", ""BuildDate"": ""$(Get-date)"", ""Repository"": ""$env:GITHUB_REPOSITORY"", ""Version"": ""$env:build_version"" } }" > ./build.json
Set-Location ../../..
}
Task Restore-WASM {
Set-Location src/client/AcBlog.Client.UI
Exec { npm ci }
Exec { gulp }
Set-Location ../../..
}
Task Api {
Exec { dotnet run -p ./src/AcBlog.Server.Api }
}
Task Wasm {
Exec { dotnet run -p ./src/client/AcBlog.Client.WebAssembly }
}