-
Notifications
You must be signed in to change notification settings - Fork 22
203 lines (183 loc) · 7.84 KB
/
main.yml
File metadata and controls
203 lines (183 loc) · 7.84 KB
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
200
201
202
203
name: CI
# builds and (manually) releases the contrib for mac, linux and windows
# note: prepare job is run first to determine a tag that can be used by all OS runners
on:
push:
workflow_dispatch: # This allows you to manually trigger the workflow from the GitHub UI
jobs:
prepare: # separate job to generate tag name exactly once based on the date
runs-on: ubuntu-latest
outputs:
TAG_NAME: ${{ steps.generate_tag_name.outputs.TAG_NAME }} # map step output to job output
steps:
- name: Generate tag name
id: generate_tag_name
run: echo "TAG_NAME=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT
build:
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
CMAKE_ARGS: ""
- os: macos-latest
CMAKE_ARGS: -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_OSX_DEPLOYMENT_TARGET=14
- os: windows-latest
CMAKE_ARGS: -G"Visual Studio 17 2022" -A"x64"
- os: ubuntu-24.04-arm
CMAKE_ARGS: ""
steps:
- name: Transfer variable TAG_NAME between jobs to be available as step output in this job
id: generate_tag_name
run: echo "TAG_NAME=${{needs.prepare.outputs.TAG_NAME}}" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/checkout@v4
with:
path: contrib
- name: Setup cmake
if: ${{ !endsWith(matrix.os, '-arm') }}
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.29.x'
- name: Install CMake (Ubuntu arm64)
if: ${{ endsWith(matrix.os, '-arm') }}
run: |
sudo apt-get update
sudo apt-get install -y cmake
- name: Install prerequisites
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get -y install make autoconf automake tar patch libtool gcc
elif [ "$RUNNER_OS" == "Windows" ]; then
# choco install important_windows_software
echo "Nothing to install"
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install autoconf automake libtool
else
echo "$RUNNER_OS not supported"
exit 1
fi
# Normalize path to only contain front slashes
- name: Normalize path on windows
if: startsWith(matrix.os, 'windows')
id: normalize_ws
run: |
$normalizedWorkspace = $env:GITHUB_WORKSPACE -replace '\\', '/'
Write-Output "NORMALIZED_WORKSPACE=$normalizedWorkspace" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Build contrib (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$NPROC = $env:NUMBER_OF_PROCESSORS
if (-not $NPROC) { $NPROC = 4 }
$env:CMAKE_BUILD_PARALLEL_LEVEL = $NPROC
New-Item -ItemType Directory -Force -Path "${{ github.workspace }}\contrib-build"
Set-Location "${{ github.workspace }}\contrib-build"
cmake ${{ matrix.CMAKE_ARGS }} -DBUILD_TYPE=ALL "${{ github.workspace }}\contrib"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
New-Item -ItemType Directory -Force -Path "${{ github.workspace }}\contrib-build-openmp"
Set-Location "${{ github.workspace }}\contrib-build-openmp"
cmake ${{ matrix.CMAKE_ARGS }} -DBUILD_TYPE=OPENMP "${{ github.workspace }}\contrib"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Build contrib (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
NPROC=$(sysctl -n hw.ncpu 2>/dev/null) || NPROC=4
else
NPROC=$(nproc 2>/dev/null) || NPROC=4
fi
export CMAKE_BUILD_PARALLEL_LEVEL=${NPROC:-4}
mkdir -p "$GITHUB_WORKSPACE/contrib-build"
cd "$GITHUB_WORKSPACE/contrib-build"
cmake ${{ matrix.CMAKE_ARGS }} -DBUILD_TYPE=ALL "$GITHUB_WORKSPACE/contrib"
mkdir -p "$GITHUB_WORKSPACE/contrib-build-openmp"
cd "$GITHUB_WORKSPACE/contrib-build-openmp"
cmake ${{ matrix.CMAKE_ARGS }} -DBUILD_TYPE=OPENMP "$GITHUB_WORKSPACE/contrib"
- name: Configure Git for Tagging
if: github.event_name == 'workflow_dispatch'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
- name: Create and Push Tag
if: github.event_name == 'workflow_dispatch'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd "${{ github.workspace }}/contrib"
git tag ${{ steps.generate_tag_name.outputs.TAG_NAME }}
git push origin ${{ steps.generate_tag_name.outputs.TAG_NAME }}
shell: bash
- name: Clean build and package
if: github.event_name == 'workflow_dispatch'
run: |
cd "${{ github.workspace }}/contrib-build"
rm -rf archives src CMakeFiles
tar -czvf "contrib_build-${{ runner.os }}.tar.gz" $(ls -d lib) $(ls -d bin) $(ls -d include) $(ls -d share)
shell: bash
- name: Create Release (Windows)
if: github.event_name == 'workflow_dispatch' && startsWith(matrix.os, 'windows')
id: create_release_win
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.generate_tag_name.outputs.TAG_NAME }}
files: |
${{ steps.normalize_ws.outputs.NORMALIZED_WORKSPACE }}/contrib-build/contrib_build-${{runner.os}}.tar.gz
- name: Create Release (Mac and Linux)
if: github.event_name == 'workflow_dispatch' && !startsWith(matrix.os, 'windows')
id: create_release_mac_linux
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.generate_tag_name.outputs.TAG_NAME }}
files: |
${{ github.workspace }}/contrib-build/contrib_build-${{runner.os}}.tar.gz
- name: Determine platform name
if: always()
id: platform
shell: bash
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
echo "name=linux" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.os }}" == "ubuntu-24.04-arm" ]]; then
echo "name=linux_arm" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
echo "name=macos" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "name=windows" >> $GITHUB_OUTPUT
else
echo "name=${{ matrix.os }}" >> $GITHUB_OUTPUT
fi
- name: Collect build logs
if: always()
shell: bash
run: |
mkdir -p "${{ github.workspace }}/build-logs"
# Copy and rename logs to distinguish between ALL and OPENMP builds
if [ -f "${{ github.workspace }}/contrib-build/contrib_build.log" ]; then
cp "${{ github.workspace }}/contrib-build/contrib_build.log" "${{ github.workspace }}/build-logs/contrib_build_all.log"
fi
if [ -f "${{ github.workspace }}/contrib-build-openmp/contrib_build.log" ]; then
cp "${{ github.workspace }}/contrib-build-openmp/contrib_build.log" "${{ github.workspace }}/build-logs/contrib_build_openmp.log"
fi
- name: Upload build logs
if: always()
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ steps.platform.outputs.name }}
path: ${{ github.workspace }}/build-logs/
if-no-files-found: warn