forked from connamara/quickfixn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
New-Release.ps1
167 lines (139 loc) · 5.77 KB
/
New-Release.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
166
167
[CmdletBinding()]
Param (
[Parameter(Position=0, Mandatory)]
[string]$TagVersion,
[Parameter(Position=1, Mandatory)]
[Alias('AccessKey')]
[string]$AwsAccessKey,
[Parameter(Position=2, Mandatory)]
[Alias('SecretKey')]
[string]$AwsSecretKey,
[Parameter(Position=3)]
[string]$NuGetApiKey,
[switch]$UseWslRuby
)
$QFDir = "quickfixn-$TagVersion"
$BuildTarget = if ($NuGetApiKey) { 'build' } else { 'pack' }
$BuildProps = "-c Release$(if ($NuGetApiKey) { ' --include-symbols -o tmp\NuGet' })"
Write-Host '--== QuickFIX/n Package Release Script ==--' -ForegroundColor Cyan
Write-Host "`nTag Version: $TagVersion`n"
if ($UseWslRuby -and $UseWslRuby.IsPresent) {
wsl ruby scripts\update_assembly_version.rb $TagVersion QuickFIXn\QuickFix.csproj Messages\FIX40\QuickFix.FIX40.csproj Messages\FIX41\QuickFix.FIX41.csproj Messages\FIX42\QuickFix.FIX42.csproj Messages\FIX43\QuickFix.FIX43.csproj Messages\FIX44\QuickFix.FIX44.csproj Messages\FIX50\QuickFix.FIX50.csproj Messages\FIX50SP1\QuickFix.FIX50SP1.csproj Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
} else {
ruby scripts\update_assembly_version.rb $TagVersion QuickFIXn\QuickFix.csproj Messages\FIX40\QuickFix.FIX40.csproj Messages\FIX41\QuickFix.FIX41.csproj Messages\FIX42\QuickFix.FIX42.csproj Messages\FIX43\QuickFix.FIX43.csproj Messages\FIX44\QuickFix.FIX44.csproj Messages\FIX50\QuickFix.FIX50.csproj Messages\FIX50SP1\QuickFix.FIX50SP1.csproj Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
}
$ExitCode = $LASTEXITCODE
if ($ExitCode -eq 0) {
Write-Host '* QuickFix *.csproj files updated with new version number.'
} else {
Write-Error 'update_assembly_version.rb FAILED'
Exit $ExitCode
}
git add QuickFIXn\QuickFix.csproj
git add Messages\FIX40\QuickFix.FIX40.csproj
git add Messages\FIX41\QuickFix.FIX41.csproj
git add Messages\FIX42\QuickFix.FIX42.csproj
git add Messages\FIX43\QuickFix.FIX43.csproj
git add Messages\FIX44\QuickFix.FIX44.csproj
git add Messages\FIX50\QuickFix.FIX50.csproj
git add Messages\FIX50SP1\QuickFix.FIX50SP1.csproj
git add Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
git commit -m "version number for version %TAG_VERSION%"
Write-Host '* Version number committed.'
git tag -a $TagVersion -m 'Release version $TagVersion'
Write-Host '* Created tag.'
git checkout $TagVersion
$ExitCode = $LASTEXITCODE
if ($ExitCode -eq 0) {
Write-Host "* Checked out tag $TagVersion"
} else {
Write-Error "There was an error checking out QuickFIX/n $TagVersion"
Exit $ExitCode
}
if ($UsWslRuby -and $UseWslRuby.IsPresent) {
wsl ruby generator/generate.rb
} else {
ruby generator/generate.rb
}
$ExitCode = $LASTEXITCODE
if ($ExitCode -eq 0) {
Write-Host '* Generated code.'
} else {
Write-Error "There was an error generating code from the data dictionaries"
Exit $ExitCode
}
if (Test-Path 'tmp') {
Get-ChildItem 'tmp' -Recurse | Remove-Item -Force > $null
}
dotnet $BuildTarget $BuildProps QuickFIXn.sln
$ExitCode = $LASTEXITCODE
if ($ExitCode -eq 0) {
Write-Host '* Built QuickFIX/n and created NuGet packages at .\tmp\Nuget'
} else {
Write-Error "There was an error building and/or packaging QuickFIX/n."
Exit $ExitCode
}
# DO NOT remove quotes around *.nupkg. Due to a bug in older versions of the .NET SDK,
# without the surrounding quotes, only the first package will be pushed.
#if ($BuildTarget -ieq 'pack') {
# dotnet nuget push '*.nupkg' -s 'https://api.nuget.org/v3/index.json' -k $NuGetApiKey 'tmp\NuGet'
#}
#$ExitCode = $LASTEXITCODE
#if ($ExitCode -eq 0) {
# Write-Host '* Pushed QuickFIX/n NuGet packages to NuGet.org'
#} else {
# Write-Error 'A problem occurred while pushing NuGet packages to NuGet.org'
# Exit $ExitCode
#}
@(
$QFDir
"$QFDir\bin"
"$QFDir\bin\netstandard2.0"
"$QFDir\spec"
"$QFDir\spec\fix"
"$QFDir\config"
) | ForEach-Object { New-Item -ItemType Directory $_ }
@(
'QuickFIXn\bin\Release\netstandard2.0\QuickFix.dll',
'Messages\FIX40\bin\Release\netstandard2.0\QuickFix.FIX40.dll',
'Messages\FIX41\bin\Release\netstandard2.0\QuickFix.FIX41.dll',
'Messages\FIX42\bin\Release\netstandard2.0\QuickFix.FIX42.dll',
'Messages\FIX43\bin\Release\netstandard2.0\QuickFix.FIX43.dll',
'Messages\FIX44\bin\Release\netstandard2.0\QuickFix.FIX44.dll',
'Messages\FIX50\bin\Release\netstandard2.0\QuickFix.FIX50.dll',
'Messages\FIX50SP1\bin\Release\netstandard2.0\QuickFix.FIX50SP1.dll',
'Messages\FIX50SP2\bin\Release\netstandard2.0\QuickFix.FIX50SP2.dll'
) | ForEach-Object {
$Filename = Split-Path $_ -Leaf
Copy-Item -Path $_ -Destination "tmp\$QFDir\bin\netstandard2.0\$Filename"
}
Copy-Item -Path 'spec\fix' -Destination "tmp\$QFDir\spec\fix" -Recurse -Force
Copy-Item -Path 'config\*.cfg' -Destination "tmp\$QFDir\config"
Copy-Item -Path 'RELEASE_README.md' -Destination "tmp\$QFDir\README.md"
@('LICENSE', 'RELEASE_NOTES.md') | ForEach-Object { Copy-Item -Path $_ -Destination "tmp\$QFDir" }
Write-Host '* Copied files to ''tmp'' directory.'
Compress-Archive -CompressionLevel Optimal -Path ".\tmp\$QFDir" -DestinationPath "$QFDir.zip" -Force
Write-Host '* Created zip.'
if ($UseWslRuby -and $UseWslRuby.IsPresent) {
wsl ruby scripts\s3_upload.rb "$QFDir.zip" $AwsAccessKey $AwsSecretKey
} else {
ruby scripts\s3_upload.rb "$QFDir.zip" $AwsAccessKey $AwsSecretKey
}
$ExitCode = $LASTEXITCODE
if ($ExitCode -eq 0) {
Write-Host '* Uploaded zip.'
} else {
Write-Error "There was an error uploading $QFDir.zip into Amazon S3"
Exit $ExitCode
}
Get-ChildItem -Path 'tmp' -Recurse | Remove-Item -Recurse -Force
Write-Host '* Removed ''tmp'' directory.'
git checkout master
Write-Host '* Changed back to master.'
Write-Host "`nSuccessfully created QuickFIX/n $TagVersion" -ForegroundColor Green
Write-Host "You can download the zip here: http://quickfix.s3.amazonaws.com/$QFDir.zip"
if ($NuGetApiKey) {
Write-Host "Alternatively, you can download the NuGet packages from NuGet.org."
}
Write-Host "You must commit the new tag and deploy the website"
Exit 0