forked from FloatingArrayDesign/MoorDyn
-
Notifications
You must be signed in to change notification settings - Fork 2
199 lines (169 loc) · 7.74 KB
/
build-test.yml
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CMake
on:
push:
branches: [ $default-branch, master ]
pull_request:
branches:
- "**"
permissions: write-all
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
VTK_VERSION_MAJOR: 9
VTK_VERSION_MINOR: 2
VTK_VERSION_PATCH: 6
jobs:
create_release:
name: Create GitHub Release
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create_release.outputs.id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
if: github.event_name == 'push'
- name: moordyn_tag_name
id: moordyn_tag_name
shell: bash
run: |
major=`cat CMakeLists.txt | grep MOORDYN_MAJOR_VERSION | head -1 | awk -F' ' '{print $2}' | awk -F')' '{print $1}'`
minor=`cat CMakeLists.txt | grep MOORDYN_MINOR_VERSION | head -1 | awk -F' ' '{print $2}' | awk -F')' '{print $1}'`
patch=`cat CMakeLists.txt | grep MOORDYN_PATCH_VERSION | head -1 | awk -F' ' '{print $2}' | awk -F')' '{print $1}'`
echo "moordyn_tag_name=v$major.$minor.$patch" >> $GITHUB_OUTPUT
if: github.event_name == 'push'
# - uses: dev-drprasad/[email protected]
# continue-on-error: true
# with:
# delete_release: true
# tag_name: "nightly"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: github.event_name == 'push'
- uses: rickstaa/action-create-tag@v1
id: create_tag
with:
tag: ${{steps.moordyn_tag_name.outputs.moordyn_tag_name}}
message: "Latest release (${{steps.moordyn_tag_name.outputs.moordyn_tag_name}})"
force_push_tag: true
if: github.event_name == 'push'
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{steps.moordyn_tag_name.outputs.moordyn_tag_name}}
release_name: ${{steps.moordyn_tag_name.outputs.moordyn_tag_name}}
draft: false
prerelease: false
if: github.event_name == 'push'
build:
runs-on: ${{ matrix.os }}
needs: [create_release]
strategy:
matrix:
os: [ubuntu-22.04, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- name: moordyn_version
id: moordyn_version
shell: bash
run: |
major=`cat CMakeLists.txt | grep MOORDYN_MAJOR_VERSION | head -1 | awk -F' ' '{print $2}' | awk -F')' '{print $1}'`
minor=`cat CMakeLists.txt | grep MOORDYN_MINOR_VERSION | head -1 | awk -F' ' '{print $2}' | awk -F')' '{print $1}'`
patch=`cat CMakeLists.txt | grep MOORDYN_PATCH_VERSION | head -1 | awk -F' ' '{print $2}' | awk -F')' '{print $1}'`
echo "moordyn_version=$major.$minor.$patch" >> $GITHUB_OUTPUT
- name: Setup GCC Fortran (Linux)
uses: awvwgk/setup-fortran@main
id: setup-fortran
with:
compiler: gcc
if: runner.os == 'Linux'
- name: Install VTK (Linux)
run: |
sudo apt-get -qq update
sudo apt-get -qq -y install libvtk9-dev
if: runner.os == 'Linux'
- name: Install VTK (MacOS)
run: |
brew install vtk
if: runner.os == 'MacOS'
- name: download pre-built VTK static library
uses: suisei-cn/[email protected]
with:
url: https://github.com/sanguinariojoe/vtk-builds/releases/download/VTK-${{env.VTK_VERSION_MAJOR}}.${{env.VTK_VERSION_MINOR}}.${{env.VTK_VERSION_PATCH}}-static/vtk-${{runner.os}}-x86_64.tar.gz
target: ${{github.workspace}}/
if: runner.os == 'Windows'
- name: Create VTK folder
run: |
mkdir -p ${{github.workspace}}/vtk
if: runner.os == 'Windows'
- name: Extract VTK tgz
run: |
tar -xvzf vtk-${{runner.os}}-x86_64.tar.gz -C vtk/
if: runner.os == 'Windows'
- name: Create install folder
run: |
mkdir -p ${{github.workspace}}/install
- name: Configure CMake (Linux)
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DEXTERNAL_EIGEN:BOOL=OFF -DPYTHON_WRAPPER:BOOL=OFF -DFORTRAN_WRAPPER:BOOL=ON -DRUST_WRAPPER:BOOL=OFF -DUSE_VTK=ON -DBUILD_TESTING=ON
if: runner.os == 'Linux'
- name: Configure CMake (MacOS)
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DEXTERNAL_EIGEN:BOOL=OFF -DPYTHON_WRAPPER:BOOL=OFF -DFORTRAN_WRAPPER:BOOL=OFF -DRUST_WRAPPER:BOOL=OFF -DUSE_VTK=ON -DBUILD_TESTING=ON
if: runner.os == 'MacOS'
- name: Configure CMake (Windows)
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DEXTERNAL_EIGEN:BOOL=OFF -DPYTHON_WRAPPER:BOOL=OFF -DFORTRAN_WRAPPER:BOOL=OFF -DRUST_WRAPPER:BOOL=OFF -DUSE_VTK=ON -DVTK_DIR=${{github.workspace}}/vtk/lib/cmake/vtk-${{env.VTK_VERSION_MAJOR}}.${{env.VTK_VERSION_MINOR}}/ -DMOORDYN_PACKAGE_IGNORE_VTK_DEPENDENCY=ON -DBUILD_TESTING=ON
if: runner.os == 'Windows'
- name: Build
id: build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
# We do a little hack here. We install the library so we perfectly know the
# path. Then we set the environment variable to let the OS find the
# libraries
- name: Install
run: cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Set $PATH (Windows)
run: Add-Content $env:GITHUB_PATH "${{github.workspace}}\install\bin"
if: runner.os == 'Windows'
- name: Test
working-directory: ${{github.workspace}}/build
# We are just testing in Linux
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
- name: Create Installer
working-directory: ${{github.workspace}}/build
shell: bash
# Package the installer
run: cpack -C ${{env.BUILD_TYPE}}
- name: Upload Linux installer
id: upload-linux-installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{github.workspace}}/build/Moordyn-${{steps.moordyn_version.outputs.moordyn_version}}-Linux.sh
asset_name: Moordyn-${{steps.moordyn_version.outputs.moordyn_version}}-Linux.sh
asset_content_type: application/exe
if: ${{ (github.event_name == 'push') && (runner.os == 'Linux') }}
- name: Upload MacOS installer
id: upload-macos-installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{github.workspace}}/build/Moordyn-${{steps.moordyn_version.outputs.moordyn_version}}-Darwin.sh
asset_name: Moordyn-${{steps.moordyn_version.outputs.moordyn_version}}-Darwin.sh
asset_content_type: application/exe
if: ${{ (github.event_name == 'push') && (runner.os == 'MacOS') }}
- name: Upload Windows installer
id: upload-windows-installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{github.workspace}}/build/Moordyn-${{steps.moordyn_version.outputs.moordyn_version}}-win64.exe
asset_name: Moordyn-${{steps.moordyn_version.outputs.moordyn_version}}-win64.exe
asset_content_type: application/exe
if: ${{ (github.event_name == 'push') && (runner.os == 'Windows') }}