-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_test_deploy.ps1
165 lines (134 loc) · 5.24 KB
/
build_test_deploy.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<#
.SYNOPSIS
Script for publishing applications. Requires .sln and Directory.Build.props
.DESCRIPTION
For additional usage info, please use Get-Help -Full and see related scripts source code
.LINK
https://github.com/Gigas002/dotnet_gh_deploy
#>
[CmdletBinding(PositionalBinding = $false)]
param (
# Directory.Build.props path
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("b", "build-props-path")]
[string] $buildPropsPath = "Directory.Build.props",
# Codecov token
[Parameter ()]
[Alias("codecov-token")]
[SecureString] $codecovToken = (Read-Host "Enter your codecov token" -AsSecureString),
# continious tag
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("continious-tag")]
[string] $continiousTag = "continious",
# docker continious tag
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("docker-continious-tag")]
[string] $dockerContiniousTag = "latest",
# docfx.json path
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("docfx-json")]
[string] $docfxJson = "docfx.json",
# Docker hub token
[Parameter ()]
[Alias("docker-hub-token")]
[SecureString] $dockerHubToken = (Read-Host "Enter your docker hub token token" -AsSecureString),
# Docker hub username
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("docker-hub-username")]
[string] $dockerHubUsername = "gigas002",
# Github token
[Parameter ()]
[Alias("github-token")]
[SecureString] $githubToken = (Read-Host "Enter your github token" -AsSecureString),
# Github username
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("github-username")]
[string] $githubUsername = "Gigas002",
# Github package feed name
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("github-feed-name")]
[string] $githubFeedName = "Gigas002",
# Github repo name
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("github-repo-name")]
[string] $githubRepoName = "dotnet_gh_deploy",
# Nuget API token
[Parameter ()]
[Alias("n", "nuget-token")]
[SecureString] $nugetToken = (Read-Host "Enter your nuget token" -AsSecureString),
# Publish path
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("p", "publish-path")]
[string] $publishPath = "artifacts/publish",
# runsettings.xml path
[Parameter ()]
[Alias("r", "runsettings-xml")]
[string] $runsettingsXml = "",
# Paths to projects to test
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("inputs-tests")]
[string[]] $inputsTests = ("Deploy.Tests/Deploy.Tests.csproj",
"Deploy.Server.Tests/Deploy.Server.Tests.csproj"
),
# Paths to projects to publish
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("inputs-publish")]
[string[]] $inputsPublish = ("Deploy.Cli/Deploy.Cli.csproj",
"Deploy.Benchmarks/Deploy.Benchmarks.csproj",
"Deploy.Gui/Deploy.Gui.csproj",
"Deploy.Server/Deploy.Server.csproj",
"Deploy.Client/Deploy.Client.csproj"
),
# Paths to packages to publish
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("inputs-nupkg")]
[string[]] $inputsNupkg = (
"Deploy.Core/Deploy.Core.csproj",
"Deploy.Core.Dummy/Deploy.Core.Dummy.csproj"
),
# Dictionary<ProjectName,DockerfilePath>
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("inputs-docker")]
[hashtable] $inputsDocker = [ordered]@{
"dotnet.cli" = "Cli.Dockerfile";
"dotnet.benchmarks" = "Benchmarks.Dockerfile"
},
# snyk token
[Parameter ()]
[Alias("snyk-token")]
[SecureString] $snykToken = (Read-Host "Enter your snyk token" -AsSecureString),
# sarif path
[Parameter ()]
[Alias("sarif-path")]
[string] $sarifPath = "snyk-code.sarif"
)
Write-Host "Removing previous publish directory: $publishPath" -ForegroundColor Yellow
Remove-Item -Path $publishPath -Recurse -Force -ErrorAction SilentlyContinue
# pack all source code into zip, excluding .gitignore files
./src.ps1 -p $publishPath -continious-tag $continiousTag -b $buildPropsPath
# build and test + upload report if needed
./test.ps1 -i $inputsTests -codecov-token $codecovToken -r $runsettingsXml
# build docs
./docs.ps1 -docfx-json $docfxJson
# publish binaries
./publish.ps1 -p $publishPath -i $inputsPublish
# publish nupkgs
./nupkg.ps1 -n $nugetToken -github-token $githubToken -i $inputsNupkg -p $publishPath -github-feed-name $githubFeedName -b $buildPropsPath
# publish docker
./docker.ps1 -docker-hub-token $dockerHubToken -github-token $githubToken -docker-hub-username $dockerHubUsername -github-username $githubUsername -i $inputsDocker -github-repo-name $githubRepoName -b $buildPropsPath -docker-continious-tag $dockerContiniousTag
# run secirity analyzis
./snyk.ps1 -snyk-token $snykToken -docker-hub-token $dockerHubToken -github-token $githubToken -docker-hub-username $dockerHubUsername -github-username $githubUsername -inputs-docker $inputsDocker -github-repo-name $githubRepoName -b $buildPropsPath -docker-continious-tag $dockerContiniousTag
Write-Host "Deploy complete" -ForegroundColor Green