-
Notifications
You must be signed in to change notification settings - Fork 100
321 lines (277 loc) · 10.1 KB
/
CI.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
name: CI
on:
push:
pull_request:
release:
types: [published]
env:
CI: "ON" # We can detect this in the build system and other vendors implement it
HOMEBREW_NO_ANALYTICS: "ON" # Make Homebrew installation a little quicker
HOMEBREW_NO_AUTO_UPDATE: "ON"
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON"
HOMEBREW_NO_GITHUB_API: "ON"
HOMEBREW_NO_INSTALL_CLEANUP: "ON"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-12, windows-latest]
toolchain:
- {compiler: gcc, version: 10}
- {compiler: gcc, version: 11}
- {compiler: gcc, version: 12}
- {compiler: gcc, version: 13}
exclude:
- os: macos-12
toolchain: {compiler: gcc, version: 13}
include:
- os: ubuntu-latest
os-arch: linux-x86_64
release-flags: --flag '--static -g -fbacktrace -O3'
- os: macos-12
os-arch: macos-x86_64
release-flags: --flag '-g -fbacktrace -O3'
- os: windows-latest
os-arch: windows-x86_64
release-flags: --flag '--static -g -fbacktrace -O3'
exe: .exe
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Fortran compiler
uses: fortran-lang/[email protected]
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
# Phase 1: Bootstrap fpm with existing version
- name: Install fpm
uses: fortran-lang/setup-fpm@v5
with:
fpm-version: 'v0.8.0'
# Backport gfortran shared libraries to version 9 folder. This is necessary because the macOS release of fpm
# 0.10.0 used for bootstrapping has these paths hardcoded in the executable.
- name: MacOS patch libgfortran
if: contains(matrix.os, 'macos') && !contains(matrix.toolchain.version, '10')
run: |
which gfortran-${{ matrix.toolchain.version }}
which gfortran
mkdir /usr/local/opt/gcc@10
mkdir /usr/local/opt/gcc@10/lib
mkdir /usr/local/opt/gcc@10/lib/gcc
mkdir /usr/local/opt/gcc@10/lib/gcc/10
mkdir /usr/local/lib/gcc/10
ln -fs /usr/local/opt/gcc@${{ matrix.toolchain.version }}/lib/gcc/${{ matrix.toolchain.version }}/libquadmath.0.dylib /usr/local/opt/gcc@10/lib/gcc/10/libquadmath.0.dylib
ln -fs /usr/local/opt/gcc@${{ matrix.toolchain.version }}/lib/gcc/${{ matrix.toolchain.version }}/libgfortran.5.dylib /usr/local/opt/gcc@10/lib/gcc/10/libgfortran.5.dylib
ln -fs /usr/local/lib/gcc/${{ matrix.toolchain.version }}/libgcc_s.1.dylib /usr/local/lib/gcc/10/libgcc_s.1.dylib
# gcc and g++ will point to clang/clang++: use versioned alias for fpm
- name: MacOS patch C and C++ compilers
if: contains(matrix.os, 'macos')
run: |
echo "CC=gcc-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
echo "FPM_CC=gcc-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
echo "CXX=g++-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
echo "FPM_CXX=g++-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
echo "FPM_LDFLAGS=-lstdc++" >> $GITHUB_ENV
- name: Remove fpm from path
shell: bash
run: |
mv $(which fpm) fpm-bootstrap${{ matrix.exe }}
echo "BOOTSTRAP=$PWD/fpm-bootstrap" >> $GITHUB_ENV
- name: Build Fortran fpm (bootstrap)
shell: bash
run: |
${{ env.BOOTSTRAP }} build
- name: Run Fortran fpm (bootstrap)
shell: bash
run: |
${{ env.BOOTSTRAP }} run
${{ env.BOOTSTRAP }} run -- --version
${{ env.BOOTSTRAP }} run -- --help
- name: Test Fortran fpm (bootstrap)
shell: bash
run: |
${{ env.BOOTSTRAP }} test
- name: Install Fortran fpm (bootstrap)
shell: bash
run: |
${{ env.BOOTSTRAP }} install
# Phase 2: Bootstrap fpm with itself
- name: Replace bootstrapping version
shell: bash
run: |
${{ env.BOOTSTRAP }} run --runner cp -- fpm-debug${{ matrix.exe }}
rm -v ${{ env.BOOTSTRAP }}
echo "FPM=$PWD/fpm-debug" >> $GITHUB_ENV
- name: Get version (normal)
if: github.event_name != 'release'
shell: bash
run: |
VERSION=$(git rev-parse --short HEAD)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get version (release)
if: github.event_name == 'release'
shell: bash
run: |
VERSION=$(echo ${{ github.ref }} | cut -dv -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
FPM_VERSION=$(${{ env.FPM }} --version | grep -o '${{ env.REGEX }}')
[ "$VERSION" = "$FPM_VERSION" ]
env:
REGEX: '[0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}'
- name: Build Fortran fpm
shell: bash
run: |
${{ env.FPM }} build ${{ matrix.release-flags }}
- name: Run Fortran fpm
shell: bash
run: |
${{ env.FPM }} run ${{ matrix.release-flags }}
${{ env.FPM }} run ${{ matrix.release-flags }} -- --version
${{ env.FPM }} run ${{ matrix.release-flags }} -- --help
- name: Test Fortran fpm
shell: bash
run: |
${{ env.FPM }} test ${{ matrix.release-flags }}
- name: Install Fortran fpm
shell: bash
run: |
${{ env.FPM }} install ${{ matrix.release-flags }}
- name: Package release version
shell: bash
run: |
${{ env.FPM }} run ${{ matrix.release-flags }} --runner cp -- ${{ env.EXE }}
rm -v ${{ env.FPM }}
echo "FPM_RELEASE=${{ env.EXE }}" >> $GITHUB_ENV
env:
EXE: fpm-${{ env.VERSION }}-${{ matrix.os-arch }}-gcc-${{ matrix.toolchain.version }}${{ matrix.exe }}
- name: Run release version
shell: bash
run: |
ci/run_tests.sh "$PWD/${{ env.FPM_RELEASE }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.FPM_RELEASE }}
path: ${{ env.FPM_RELEASE }}
make-installer:
if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }}
runs-on: windows-latest
needs:
- build
strategy:
fail-fast: false
matrix:
gcc_v: [10,11,12]
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}
pattern: fpm-*-windows-*-gcc-${{ matrix.gcc_v }}.exe
- name: Get version (normal)
if: github.event_name != 'release'
shell: bash
run: |
VERSION=$(git rev-parse --short HEAD)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get version (release)
if: github.event_name == 'release'
shell: bash
run: |
VERSION=$(echo ${{ github.ref }} | cut -dv -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
env:
REGEX: '[0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}'
- name: Setup MinGW (MSYS2)
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
wget
unzip
- name: Fetch Windows executable
shell: msys2 {0}
run: |
cp fpm-*/fpm-*-windows-*-gcc-${{ matrix.gcc_v }}.exe ./ci/fpm.exe
- name: Fetch Git for Windows
shell: msys2 {0}
run: |
cd ./ci
wget ${{ env.git_download }} -O MinGit.zip
unzip MinGit.zip -d MinGit
env:
git_download: "https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/MinGit-2.33.1-64-bit.zip"
- name: Fetch EnVar Plugin for NSIS
shell: msys2 {0}
run: |
cd ./ci
wget ${{ env.envar_download }} -O EnVar-Plugin.zip
mkdir EnVar_plugin
unzip EnVar-Plugin.zip -d EnVar_plugin
env:
envar_download: "https://github.com/GsNSIS/EnVar/releases/download/v0.3.1/EnVar-Plugin.zip"
- name: Generate installer
run: |
cd ./ci
makensis fpm-installer.nsi
move fpm-installer.exe fpm-installer-${{ env.VERSION }}-gcc-${{ matrix.gcc_v }}.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: fpm-installer-gcc-${{ matrix.gcc_v }}
path: ci/fpm-installer-${{ env.VERSION }}-gcc-${{ matrix.gcc_v }}.exe
upload-artifacts:
if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }}
runs-on: ubuntu-latest
needs:
- build
- make-installer
steps:
- id: deploy-on-push
if: ${{ github.event_name == 'push' }}
run:
echo "::set-output name=result::${{ env.DEPLOY_BRANCH }}"
env:
DEPLOY_BRANCH: ${{ secrets.DEPLOY_BRANCH && contains(github.ref, secrets.DEPLOY_BRANCH) && 1 || 0 }}
- uses: actions/checkout@v4
if: ${{ github.event_name == 'push' }}
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: fpm-cd-artifacts
pattern: 'fpm-*-gcc-12*'
merge-multiple: true
- name: Normalize file names for continuous delivery
if: ${{ github.event_name == 'push' }}
run: |
cd fpm-cd-artifacts
for output in fpm-*; do
mv -v $(basename $output) $(basename $output | sed -E '${{ env.replace }}')
done
env:
replace: 's/-([0-9]+\.[0-9]+\.[0-9]+-[0-9]+-g)?[0-9a-f]+//'
- name: Create SHA256 checksums
run: |
cd fpm-cd-artifacts
for output in fpm-*; do
sha256sum $(basename "$output") | tee $(basename "$output").sha256
done
- name: Move/Create continuous tag
if: ${{ github.event_name == 'push' && steps.deploy-on-push.outputs.result != 0 }}
run: |
git tag --force 'current' ${{ github.sha }}
git push --tags --force
- name: Upload assets
uses: svenstaro/upload-release-action@v2
if: ${{ github.event_name == 'release' || steps.deploy-on-push.outputs.result != 0 }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: fpm-cd-artifacts/*
file_glob: true
tag: ${{ github.event_name == 'release' && github.ref || 'current'}}
overwrite: true