Skip to content

Commit a55df15

Browse files
committed
use github actions for builds
1 parent 9714e2f commit a55df15

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

.github/workflows/build.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
strategy:
10+
fail-fast: true # Stop all builds if one fails
11+
matrix:
12+
include:
13+
- os: windows-latest
14+
name: win
15+
artifact: dcm2niix_win.zip
16+
- os: ubuntu-20.04
17+
name: linux
18+
artifact: dcm2niix_lnx.zip
19+
- os: macos-latest
20+
name: mac
21+
artifact: dcm2niix_mac.zip
22+
23+
runs-on: ${{ matrix.os }}
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 1
30+
31+
- name: Set version
32+
id: version
33+
shell: bash
34+
run: |
35+
DATE=$(date +'%d-%b-%Y')
36+
GITHASH=$(git rev-parse --short=7 HEAD)
37+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
38+
GITTAG="_${{ github.ref_name }}"
39+
else
40+
GITTAG=""
41+
fi
42+
VERSION="${DATE}_g${GITHASH}${GITTAG}"
43+
RELEASE_VERSION=$(date +'%d-%B-%Y')
44+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
45+
echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
46+
echo "Build version: ${VERSION}"
47+
48+
# Windows build
49+
- name: Build (Windows)
50+
if: matrix.name == 'win'
51+
shell: cmd
52+
run: |
53+
cmake -Wno-dev -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON -B build
54+
cmake --build build --config Release
55+
56+
- name: Package (Windows)
57+
if: matrix.name == 'win'
58+
shell: cmd
59+
run: 7z a dcm2niix_win.zip .\build\bin\*
60+
61+
# Linux build
62+
- name: Setup GCC (Linux)
63+
if: matrix.name == 'linux'
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y gcc-8 g++-8
67+
68+
- name: Build (Linux)
69+
if: matrix.name == 'linux'
70+
run: |
71+
export CC=gcc-8
72+
export CXX=g++-8
73+
cmake -Wno-dev -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON -B build
74+
cmake --build build
75+
76+
- name: Package (Linux)
77+
if: matrix.name == 'linux'
78+
run: |
79+
strip -sx build/bin/*
80+
7z a dcm2niix_lnx.zip ./build/bin/*
81+
82+
# macOS build
83+
- name: Build (macOS)
84+
if: matrix.name == 'mac'
85+
run: |
86+
# Build Intel version
87+
cmake -Wno-dev -DCMAKE_OSX_ARCHITECTURES=x86_64 -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON -B intel
88+
cmake --build intel
89+
90+
# Build ARM version
91+
cmake -Wno-dev -DCMAKE_OSX_ARCHITECTURES=arm64 -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON -B apple
92+
cmake --build apple
93+
94+
- name: Package (macOS)
95+
if: matrix.name == 'mac'
96+
run: |
97+
mkdir -p build/bin
98+
lipo -create -output build/bin/dcm2niix intel/bin/dcm2niix apple/bin/dcm2niix
99+
strip -Sx build/bin/*
100+
7z a dcm2niix_mac.zip ./build/bin/*
101+
102+
- name: Upload artifact
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: ${{ matrix.name }}-artifact
106+
path: ${{ matrix.artifact }}

0 commit comments

Comments
 (0)