forked from usgs-coupled/phreeqc3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-dist-build.ps1
165 lines (147 loc) · 6.03 KB
/
jenkins-dist-build.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
#
# To get the Invoke-WebRequest to work under the 'nt authority\system' account, the DOIRootCA2.cer
# CA needs to be installed by running internet explorer as system using 'psexec -sid cmd' from
# Sysinternals. The -UseBasicParsing flag may also be required.
#
#
# set DATE
#
if ([string]::IsNullOrEmpty($Env:DATE)) {
$Env:DATE = date +%x
}
$Env:DATE = date -d $Env:DATE +%x
$Env:RELEASE_DATE = date -d $Env:DATE "+%B %e, %G"
# prep for calls to Invoke_WebRequest
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#
# set VER
#
if ([string]::IsNullOrEmpty($Env:VER)) {
$request = Invoke-WebRequest https://raw.githubusercontent.com/usgs-coupled/phreeqc-version/main/phreeqc-version.txt -UseBasicParsing
$v = ($request.Content.Trim()) -split "\."
if ([string]::IsNullOrEmpty($v[2])) {
# append a new element to the array
$v += 0
}
else {
$v[2] = 1 + $v[2]
}
$Env:ver_major = $v[0]
$Env:ver_minor = $v[1]
$Env:ver_patch = $v[2]
$Env:VER = $v -join "."
}
else {
$v = ($Env:VER) -split "\."
$Env:ver_major = $v[0]
$Env:ver_minor = $v[1]
$Env:ver_patch = $v[2]
}
if ([string]::IsNullOrEmpty($v[0]) -or [string]::IsNullOrEmpty($v[1]) -or [string]::IsNullOrEmpty($v[2])) {
throw "Bad VER"
}
#
# set REL
#
Invoke-WebRequest https://raw.githubusercontent.com/usgs-coupled/phreeqc-version/main/rel.py -OutFile rel.py -UseBasicParsing
[string]$HEAD=$(python rel.py)
if ([string]::IsNullOrEmpty($Env:REL)) {
$Env:REL = $HEAD
}
$Env:VER_TAG="r$Env:REL"
$Env:VER_NUMTAG="-$Env:REL"
$Env:VERSION_LONG="$Env:ver_major.$Env:ver_minor.$Env:ver_patch.$Env:REL"
$Env:VER_UC="$Env:ver_major.$Env:ver_minor.$Env:ver_patch.$Env:REL"
$Env:MSI_VERSION="$Env:ver_major.$Env:ver_minor.$Env:REL"
$Env:FULLPKG="$Env:NAME-$Env:VER-$Env:REL"
Write-Output "HEAD=$HEAD"
Write-Output "Env:DATE=$Env:DATE"
Write-Output "Env:RELEASE_DATE=$Env:RELEASE_DATE"
Write-Output "Env:ver_major=$Env:ver_major"
Write-Output "Env:ver_major=$Env:ver_minor"
Write-Output "Env:ver_major=$Env:ver_patch"
Write-Output "Env:VER=$Env:VER"
Write-Output "Env:REL=$Env:REL"
Write-Output "Env:VER_TAG=$Env:VER_TAG"
Write-Output "Env:VER_NUMTAG=$Env:VER_NUMTAG"
Write-Output "Env:VERSION_LONG=$Env:VERSION_LONG"
Write-Output "Env:MSI_VERSION=$Env:MSI_VERSION"
Write-Output "Env:FULLPKG=$Env:FULLPKG"
###}}
###$Env:VERSION="$Env:ver_major.$Env:ver_minor.$Env:ver_patch"
###$Env:VER=$Env:VERSION
###{{
$Env:VERSION=$Env:VER
###}}
$Env:VER_UC=$Env:VERSION.ToUpper()
###$Env:REL=$Env:SVN_REVISION
###$Env:REVISION=$Env:SVN_REVISION
###$Env:REVISION_SVN=$Env:SVN_REVISION
###$Env:REL=$Env:SVN_REVISION
$Env:REVISION=$Env:REL
$Env:REVISION_SVN=$Env:REL
###$Env:REVISION_PHAST=$Env:SVN_REVISION
###$Env:VER_TAG="r$Env:SVN_REVISION"
###$Env:VER_NUMTAG="-$Env:SVN_REVISION"
###$Env:REPOS_PATH="trunk"
###{{
$Env:REPOS_PATH="$Env:TAG"
###}}
###$Env:RELEASE_DATE=Get-Date -format "MMMM d, yyyy"
###$Env:DISTNAME="phast4windows-$Env:VERSION$Env:VER_NUMTAG"
###{{
$Env:DISTNAME="$Env:NAME-$Env:VERSION$Env:VER_NUMTAG"
###}}
Write-Output "Distribution will be named: $Env:DISTNAME"
Write-Output " release branch's revision: $Env:REVISION"
Write-Output " executable's revision: $Env:REVISION_SVN"
###Write-Output " phast's revision: $Env:REVISION_PHAST"
Write-Output " constructed from path: /$Env:REPOS_PATH"
Write-Output " release date: $Env:RELEASE_DATE"
#
$sed_files=@('phreeqc_version.h', `
'src\class_main.cpp', `
'doc\RELEASE.TXT', `
'doc\README.Phreeqc.TXT')
foreach ($file in $sed_files) {
(Get-Content $file) | Foreach-Object {
$_ -replace "(#define PHREEQC_VER_MAJOR\s*)[0-9]*", "`${1}$Env:ver_major" `
-replace "(#define PHREEQC_VER_MINOR\s*)[0-9]*", "`${1}$Env:ver_minor" `
-replace "(#define PHREEQC_VER_PATCH\s*)[0-9]*", "`${1}$Env:ver_patch" `
-replace "(#define PHREEQC_VER_TAG\s*)[0-9]*", "`${1} ($Env:VER_TAG)" `
-replace "(#define PHREEQC_VER_NUMTAG\s*)[0-9]*", "`${1}$Env:VER_NUMTAG" `
-replace "(#define PHREEQC_VER_REVISION\s*)[0-9]*", "`${1}$Env:REVISION" `
-replace "(define *Major=\s*)[0-9]+", "`${1}$Env:ver_major" `
-replace "(define *Minor=\s*)[0-9]+", "`${1}$Env:ver_minor" `
-replace "(define *Build=\s*)[0-9]+", "`${1}$Env:REVISION" `
-replace "@RELEASE_DATE@", "$Env:RELEASE_DATE" `
-replace "@VER_DATE@", "$Env:RELEASE_DATE" `
-replace "@VER@", "$Env:VER" `
-replace "@VERSION@", "$Env:VER" `
-replace "@V_FIXDATE@", "$Env:V_FIXDATE" `
-replace "@VER_UC@", "$Env:VER_UC" `
-replace "@REVISION@", "$Env:REL" `
-replace "@MAJOR@", "$Env:ver_major" `
-replace "@MINOR@", "$Env:ver_minor" `
-replace "@REL@", "$Env:REL" `
-replace "@VERSION_LONG@", "$Env:VERSION_LONG" `
-replace "@PHREEQC_VER@", "$Env:VER" `
-replace "@PHREEQC_DATE@", "$Env:RELEASE_DATE"
} | Set-Content $file
}
#
Get-ChildItem Env:
[string]${MsBuild}="c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MsBuild.exe"
# build exe
[string]$opts="phreeqcpp.2005.sln /p:Configuration=Release /p:Platform=x64"
Invoke-Expression "$MsBuild $opts"
# build CLR exe
[string]$opts_clr="phreeqcpp.2005.sln /p:Configuration=ClrRelease /p:Platform=x64"
Invoke-Expression "$MsBuild $opts_clr"
# build msi
[string]$opts_msi="msi\msi.sln /p:Configuration=Release /p:Platform=x64 /p:TargetName=$Env:FULLPKG-x64 /p:Major=$Env:ver_major /p:Minor=$Env:ver_minor /p:Patch=$Env:ver_patch /p:Build=$Env:REL"
Invoke-Expression "$MsBuild $opts_msi"
# copy docs
New-Item ".\dist" -ItemType directory
Copy-Item doc\README.Phreeqc.TXT dist\README.Phreeqc.${Env:REL}.TXT
Copy-Item doc\RELEASE.TXT dist\RELEASE.${Env:REL}.TXT