Skip to content

Commit 3cd3f2e

Browse files
committed
Added vtk-9.1.0 build
1 parent c86d60a commit 3cd3f2e

File tree

2 files changed

+361
-0
lines changed

2 files changed

+361
-0
lines changed

.github/workflows/build-vtk-9.1.0.yml

+283
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
name: build-vtk-9.1.0
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop*
8+
paths:
9+
- .github/workflows/build-vtk-9.1.0.yml
10+
- misc/CMakePresets-vtk-9.1.0.json
11+
12+
env:
13+
CL: /MP
14+
VTK_VERSION: 9.1.0
15+
VS_VERSION: vs2019
16+
PRESET: VTK-9.1.0-vs2019-x64
17+
18+
jobs:
19+
20+
cache-vtk-debug:
21+
# comment the next line if you want to compile vtk
22+
if: github.repository == 'MODFLOW-USGS/modelviewer-mf6'
23+
24+
runs-on: windows-2019
25+
26+
steps:
27+
28+
- uses: actions/checkout@v2
29+
30+
- name: Export env
31+
env:
32+
type: debug
33+
zipfile: v${{env.VTK_VERSION}}.zip
34+
instdir: C:/VTK-${{env.VTK_VERSION}}-${{env.VS_VERSION}}-x64
35+
builddir: C:/VTK-${{env.VTK_VERSION}}-${{env.VS_VERSION}}-x64-build
36+
srcdir: C:/VTK-${{env.VTK_VERSION}}
37+
shell: pwsh
38+
run: |
39+
echo "type=$env:type" >> $env:GITHUB_ENV
40+
echo "zipfile=$env:zipfile" >> $env:GITHUB_ENV
41+
echo "instdir=$env:instdir" >> $env:GITHUB_ENV
42+
echo "builddir=$env:builddir" >> $env:GITHUB_ENV
43+
echo "srcdir=$env:srcdir" >> $env:GITHUB_ENV
44+
45+
- name: Cache vtk
46+
id: cache-vtk-debug
47+
uses: actions/cache@v2
48+
with:
49+
path: ${{env.instdir}}
50+
key: windows-2019-vtk-${{env.type}}-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
51+
52+
- name: Download vtk
53+
if: steps.cache-vtk-debug.outputs.cache-hit != 'true'
54+
shell: pwsh
55+
run: |
56+
curl -L -O "https://github.com/Kitware/VTK/archive/refs/tags/${{env.zipfile}}"
57+
Get-FileHash ${{env.zipfile}}
58+
cd C:\
59+
7z x ${{github.workspace}}\${{env.zipfile}}
60+
rm ${{github.workspace}}\${{env.zipfile}}
61+
62+
- name: Build vtk
63+
if: steps.cache-vtk-debug.outputs.cache-hit != 'true'
64+
shell: pwsh
65+
run: |
66+
cp misc\CMakePresets.json ${{env.srcdir}}
67+
cd ${{env.srcdir}}
68+
cmake --preset ${{env.PRESET}}
69+
cmake --build --preset ${{env.PRESET}} --config ${{env.type}}
70+
cmake --install ${{env.builddir}} --prefix ${{env.instdir}} --config ${{env.type}}
71+
72+
- name: Check debug cache
73+
shell: pwsh
74+
run: |
75+
dir ${{env.instdir}}\bin
76+
77+
cache-vtk-release:
78+
# uncomment the next line if you want to compile vtk
79+
if: github.repository == 'MODFLOW-USGS/modelviewer-mf6'
80+
81+
runs-on: windows-2019
82+
83+
steps:
84+
85+
- uses: actions/checkout@v2
86+
87+
- name: Export env
88+
env:
89+
type: release
90+
zipfile: v${{env.VTK_VERSION}}.zip
91+
instdir: C:/VTK-${{env.VTK_VERSION}}-${{env.VS_VERSION}}-x64
92+
builddir: C:/VTK-${{env.VTK_VERSION}}-${{env.VS_VERSION}}-x64-build
93+
srcdir: C:/VTK-${{env.VTK_VERSION}}
94+
shell: pwsh
95+
run: |
96+
echo "type=$env:type" >> $env:GITHUB_ENV
97+
echo "zipfile=$env:zipfile" >> $env:GITHUB_ENV
98+
echo "instdir=$env:instdir" >> $env:GITHUB_ENV
99+
echo "builddir=$env:builddir" >> $env:GITHUB_ENV
100+
echo "srcdir=$env:srcdir" >> $env:GITHUB_ENV
101+
102+
- name: Cache vtk
103+
id: cache-vtk-release
104+
uses: actions/cache@v2
105+
with:
106+
path: ${{env.instdir}}
107+
key: windows-2019-vtk-${{env.type}}-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
108+
109+
- name: Download vtk
110+
if: steps.cache-vtk-release.outputs.cache-hit != 'true'
111+
shell: pwsh
112+
run: |
113+
curl -L -O "https://github.com/Kitware/VTK/archive/refs/tags/${{env.zipfile}}"
114+
Get-FileHash ${{env.zipfile}}
115+
cd C:\
116+
7z x ${{github.workspace}}\${{env.zipfile}}
117+
rm ${{github.workspace}}\${{env.zipfile}}
118+
119+
- name: Build vtk
120+
if: steps.cache-vtk-release.outputs.cache-hit != 'true'
121+
shell: pwsh
122+
run: |
123+
cp misc\CMakePresets.json ${{env.srcdir}}
124+
cd ${{env.srcdir}}
125+
cmake --preset ${{env.PRESET}}
126+
cmake --build --preset ${{env.PRESET}} --config ${{env.type}}
127+
cmake --install ${{env.builddir}} --prefix ${{env.instdir}} --config ${{env.type}}
128+
129+
- name: Check release cache
130+
shell: pwsh
131+
run: |
132+
dir ${{env.instdir}}\bin
133+
134+
cache-vtk:
135+
# uncomment the next line if you want to compile vtk
136+
if: github.repository == 'MODFLOW-USGS/modelviewer-mf6'
137+
138+
runs-on: windows-2019
139+
needs: [cache-vtk-debug, cache-vtk-release]
140+
141+
steps:
142+
143+
- name: Checkout
144+
uses: actions/checkout@v2
145+
146+
- name: Export env
147+
env:
148+
zipfile: v${{env.VTK_VERSION}}.zip
149+
instdir: C:/VTK-${{env.VTK_VERSION}}-${{env.VS_VERSION}}-x64
150+
builddir: C:/VTK-${{env.VTK_VERSION}}-${{env.VS_VERSION}}-x64-build
151+
srcdir: C:/VTK-${{env.VTK_VERSION}}
152+
tag: vtk-${{env.VTK_VERSION}}-${{env.VS_VERSION}}-x64
153+
shell: pwsh
154+
run: |
155+
echo "zipfile=$env:zipfile" >> $env:GITHUB_ENV
156+
echo "instdir=$env:instdir" >> $env:GITHUB_ENV
157+
echo "builddir=$env:builddir" >> $env:GITHUB_ENV
158+
echo "srcdir=$env:srcdir" >> $env:GITHUB_ENV
159+
echo "tag=$env:tag" >> $env:GITHUB_ENV
160+
161+
- name: Cache vtk
162+
id: cache-vtk
163+
uses: actions/cache@v2
164+
with:
165+
path: ${{env.instdir}}
166+
key: windows-2019-vtk-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
167+
168+
- name: Cache vtk debug
169+
if: steps.cache-vtk.outputs.cache-hit != 'true'
170+
id: cache-vtk-debug
171+
uses: actions/cache@v2
172+
with:
173+
path: ${{env.instdir}}
174+
key: windows-2019-vtk-debug-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
175+
176+
- name: Cache vtk release
177+
if: steps.cache-vtk.outputs.cache-hit != 'true'
178+
uses: actions/cache@v2
179+
with:
180+
path: ${{env.instdir}}
181+
key: windows-2019-vtk-release-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
182+
183+
- name: Check merged cache
184+
shell: pwsh
185+
run: |
186+
dir ${{env.instdir}}\bin
187+
188+
- name: Compress cache
189+
shell: pwsh
190+
run: |
191+
7z a ${{env.tag}}.7z ${{env.instdir}}
192+
193+
- name: Delete release
194+
env:
195+
releases_url: ${{github.api_url}}/repos/${{github.repository}}/releases
196+
run: |
197+
# create headers dictionary
198+
$h = @{"Authorization" = "token ${{secrets.GITHUB_TOKEN}}"}
199+
200+
try {
201+
# Get a release by tag name
202+
# https://docs.github.com/rest/reference/repos#get-a-release-by-tag-name
203+
# get /repos/{owner}/{repo}/releases/tags/{tag}
204+
$response = Invoke-WebRequest -Uri ${{env.releases_url}}/tags/${{env.tag}} -Headers $h -Method Get
205+
$hashtable = $response.Content | ConvertFrom-Json -AsHashtable
206+
207+
# Delete a release
208+
# https://docs.github.com/en/rest/reference/releases#delete-a-release
209+
# delete /repos/{owner}/{repo}/releases/{release_id}
210+
$id = $hashtable.id.ToString()
211+
$response = Invoke-WebRequest -Uri ${{env.releases_url}}/$id -Headers $h -Method Delete
212+
}
213+
catch {
214+
Write-Output "An error occured:"
215+
Write-Output $_
216+
}
217+
218+
- name: Delete tag
219+
shell: pwsh
220+
run: |
221+
git push --delete origin refs/tags/${{env.tag}}
222+
223+
- name: Create release
224+
env:
225+
releases_url: ${{github.api_url}}/repos/${{github.repository}}/releases
226+
run: |
227+
# setup json variables
228+
$tag_name = "${{env.tag}}"
229+
$filename = "${{env.tag}}.7z"
230+
$hash = (Get-FileHash $filename).Hash.ToLower()
231+
# format using markdown
232+
$body = "```````nsha256`n$hash $filename`n``````"
233+
234+
# store commit
235+
$target_commitish = "${{github.sha}}"
236+
237+
# create headers dictionary
238+
$h = @{"Authorization" = "token ${{secrets.GITHUB_TOKEN}}"}
239+
$releases_url = "${{env.releases_url}}"
240+
# create release
241+
# POST /repos/{owner}/{repo}/releases
242+
# see https://docs.github.com/en/rest/reference/repos#create-a-release
243+
#
244+
$create = @{
245+
"body" = $body
246+
"tag_name" = $tag_name
247+
"target_commitish" = $target_commitish
248+
"name" = $tag_name
249+
"draft" = $true
250+
}
251+
$create_json = $create | ConvertTo-Json
252+
$release = Invoke-WebRequest -Uri $releases_url -Headers $h -Method Post -Body $create_json
253+
# upload artifact (asset)
254+
# POST /repos/{owner}/{repo}/releases/{release_id}/assets
255+
# see https://docs.github.com/en/rest/reference/repos#upload-a-release-asset
256+
#
257+
$upload_uri = ($release.Content | ConvertFrom-Json).upload_url
258+
if (! ($upload_uri -match "(.*)\{\?name,label\}") ) {
259+
# expecting URI{?name,label}
260+
# ie https://uploads.github.com/repos/scharlton2/iricdev-2019/releases/24058628/assets{?name,label}
261+
throw "Bad upload_url"
262+
}
263+
$upload_uri = $Matches[1] + "?name=$filename"
264+
$h["Content-type"] = "application/x-7z-compressed"
265+
$bytes = [System.IO.File]::ReadAllBytes($filename)
266+
$upload = Invoke-WebRequest -Uri $upload_uri -Headers $h -Method Post -Body $bytes
267+
# update release
268+
# PATCH /repos/{owner}/{repo}/releases/{release_id}
269+
# see https://docs.github.com/en/rest/reference/repos#update-a-release
270+
#
271+
$release_id = ($release.Content | ConvertFrom-Json).id
272+
$h.Remove("Content-type")
273+
$update = @{ "draft" = $false }
274+
$update_json = $update | ConvertTo-Json
275+
$release = Invoke-WebRequest -Uri "$releases_url/$release_id" -Headers $h -Method Patch -Body $update_json
276+
277+
# display download url
278+
Write-Output "::group::Results"
279+
Write-Output "$((($release.Content | ConvertFrom-Json).assets).browser_download_url)"
280+
Write-Output "${{github.sha}}"
281+
Write-Output "sha256"
282+
Write-Output "$hash $filename"
283+
Write-Output "::endgroup::"

misc/CMakePresets-vtk-9.1.0.json

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 18,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "VTK-9.1.0-vs2019-x64",
11+
"displayName": "vtk-9.1.0 with VTK_MODULE_ENABLE_VTK_GUISupportMFC=YES using vs2019 x64",
12+
"generator": "Visual Studio 16 2019",
13+
"architecture": "x64",
14+
"binaryDir": "C:/VTK-$env{VTK_VERSION}-$env{VS_VERSION}-x64-build",
15+
"cacheVariables": {
16+
"BUILD_TESTING": "OFF",
17+
"CMAKE_DEBUG_POSTFIX": "d",
18+
"CMAKE_INSTALL_PREFIX": "C:/VTK-$env{VTK_VERSION}-$env{VS_VERSION}-x64",
19+
"VTK_MODULE_ENABLE_VTK_GUISupportMFC": "YES"
20+
},
21+
"environment": {
22+
"VTK_VERSION": "9.1.0",
23+
"VS_VERSION": "vs2019"
24+
},
25+
"vendor": {
26+
"usgs.gov/modflow": {
27+
"Name": "U.S. Geological Survey",
28+
"Notes": "This file should be placed in the root directory of C:/VTK-9.1.0",
29+
"Configure": "cmake --preset VTK-9.1.0-vs2019-x64",
30+
"Build": "cmake --build --preset VTK-9.1.0-vs2019-x64 --config release",
31+
"Install-debug": "cmake --install C:/VTK-9.1.0-vs2019-x64-build --config debug",
32+
"Install-release": "cmake --install C:/VTK-9.1.0-vs2019-x64-build --config release"
33+
}
34+
}
35+
},
36+
{
37+
"name": "VTK-9.1.0-leaks-vs2019-x64",
38+
"displayName": "vtk-9.1.0 w/ VTK_MODULE_ENABLE_VTK_GUISupportMFC=YES and VTK_DEBUG_LEAKS=ON on vs2017-x64",
39+
"generator": "Visual Studio 16 2019",
40+
"architecture": "x64",
41+
"binaryDir": "C:/VTK-$env{VTK_VERSION}-leaks-$env{VS_VERSION}-x64-build",
42+
"cacheVariables": {
43+
"BUILD_TESTING": "OFF",
44+
"CMAKE_DEBUG_POSTFIX": "d",
45+
"CMAKE_INSTALL_PREFIX": "C:/VTK-$env{VTK_VERSION}-leaks-$env{VS_VERSION}-x64",
46+
"VTK_MODULE_ENABLE_VTK_GUISupportMFC": "YES",
47+
"VTK_DEBUG_LEAKS": "ON"
48+
},
49+
"environment": {
50+
"VTK_VERSION": "9.1.0",
51+
"VS_VERSION": "vs2019"
52+
},
53+
"vendor": {
54+
"usgs.gov/modflow": {
55+
"Name": "U.S. Geological Survey",
56+
"Notes": "This file should be placed in the root directory of C:/VTK-9.1.0",
57+
"Configure": "cmake --preset VTK-9.1.0-leaks-vs2019-x64",
58+
"Build": "cmake --build --preset VTK-9.1.0-leaks-vs2019-x64 --config release",
59+
"Install-debug": "cmake --install C:/VTK-9.1.0-leaks-vs2019-x64 --config debug",
60+
"Install-release": "cmake --install C:/VTK-9.1.0-leaks-vs2019-x64 --config release"
61+
}
62+
}
63+
}
64+
],
65+
"buildPresets": [
66+
{
67+
"name": "VTK-9.1.0-vs2019-x64",
68+
"configurePreset": "VTK-9.1.0-vs2019-x64"
69+
},
70+
{
71+
"name": "VTK-9.1.0-leaks-vs2019-x64",
72+
"configurePreset": "VTK-9.1.0-leaks-vs2019-x64"
73+
}
74+
],
75+
"vendor": {
76+
"Note": ""
77+
}
78+
}

0 commit comments

Comments
 (0)