Skip to content

Commit 162bfaa

Browse files
author
Tobias Wood
committed
BLD Add Github Action
1 parent 17369d2 commit 162bfaa

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

.github/workflows/build.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Build
2+
# This workflow is triggered on pushes to the repository.
3+
on: push
4+
5+
env:
6+
BUILD_TYPE: Release
7+
VCPKG_PATH: ${{github.workspace}}/vcpkg
8+
9+
jobs:
10+
build:
11+
name: ${{matrix.config.name}}
12+
runs-on: ${{matrix.config.os}}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
config:
17+
- {
18+
name: "Ubuntu GCC", artifact: "nanconvert-linux.tar.gz",
19+
os: ubuntu-16.04,
20+
cc: "gcc-9", cxx: "g++-9"
21+
}
22+
- {
23+
name: "macOS", artifact: "nanconvert-macos.tar.gz",
24+
os: macos-10.15,
25+
cc: "clang", cxx: "clang++"
26+
}
27+
28+
steps:
29+
- uses: actions/checkout@v2
30+
with:
31+
submodules: 'true'
32+
33+
- name: Install GNU tar
34+
shell: bash
35+
run: |
36+
if [ "${{runner.os}}" == "macOS" ]; then
37+
brew install gnu-tar
38+
fi
39+
40+
- name: vcpkg
41+
env:
42+
CC: ${{matrix.config.cc}}
43+
CXX: ${{matrix.config.cxx}}
44+
uses: lukka/run-vcpkg@v5
45+
with:
46+
setupOnly: true
47+
48+
- name: CMake
49+
uses: lukka/run-cmake@v2
50+
id: runcmake
51+
env:
52+
CC: ${{matrix.config.cc}}
53+
CXX: ${{matrix.config.cxx}}
54+
with:
55+
cmakeListsTxtPath: '${{github.workspace}}/CMakeLists.txt'
56+
useVcpkgToolchainFile: true
57+
buildDirectory: build
58+
cmakeBuildType: Release
59+
60+
- name: Save release
61+
run: |
62+
mv ./build/{nanconvert_bruker,nanconvert_dicom} ./
63+
cp Scripts/{nanbruker,nanbruker_sge.qsub,nandicom} ./
64+
ALL="nanconvert_bruker nanbruker nanbruker_sge.qsub nanconvert_dicom nandicom"
65+
if [ "${{runner.os}}" == "macOS" ]; then
66+
echo "Using GNU tar"
67+
gtar -cvzf ${{matrix.config.artifact}} $ALL
68+
else
69+
echo "Using system tar"
70+
tar -cvzf ${{matrix.config.artifact}} $ALL
71+
fi
72+
shell: bash
73+
74+
- name: Upload
75+
uses: actions/upload-artifact@v1
76+
with:
77+
path: ./${{matrix.config.artifact}}
78+
name: ${{matrix.config.artifact}}
79+
80+
release:
81+
if: contains(github.ref, 'tags/v')
82+
runs-on: ubuntu-latest
83+
needs: build
84+
85+
steps:
86+
- name: Create Release
87+
id: create_release
88+
uses: actions/create-release@v1.0.0
89+
env:
90+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
91+
with:
92+
tag_name: ${{github.ref}}
93+
release_name: Release ${{github.ref}}
94+
draft: true
95+
prerelease: false
96+
97+
- name: Store Release URL
98+
run: |
99+
echo "${{steps.create_release.outputs.upload_url}}" > ./upload_url
100+
101+
- uses: actions/upload-artifact@v1
102+
with:
103+
path: ./upload_url
104+
name: upload_url
105+
106+
publish:
107+
if: contains(github.ref, 'tags/v')
108+
name: ${{matrix.config.name}}
109+
runs-on: ${{matrix.config.os}}
110+
strategy:
111+
fail-fast: false
112+
matrix:
113+
config:
114+
- {
115+
name: "Ubuntu GCC", artifact: "nanconvert-linux.tar.gz",
116+
os: ubuntu-16.04
117+
}
118+
- {
119+
name: "macOS", artifact: "nanconvert-macos.tar.gz",
120+
os: macos-10.15
121+
}
122+
needs: release
123+
124+
steps:
125+
- name: Download Artifact
126+
uses: actions/download-artifact@v1
127+
with:
128+
name: ${{matrix.config.artifact}}
129+
path: ./
130+
131+
- name: Download URL
132+
uses: actions/download-artifact@v1
133+
with:
134+
name: upload_url
135+
path: ./
136+
137+
- name: Set Upload URL
138+
id: set_upload_url
139+
run: |
140+
URL=`cat ./upload_url`
141+
echo ${URL}
142+
echo "::set-output name=upload_url::${URL}"
143+
144+
- name: Upload to Release
145+
id: upload_to_release
146+
uses: actions/upload-release-asset@v1.0.1
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
with:
150+
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
151+
asset_path: ./${{ matrix.config.artifact }}
152+
asset_name: ${{ matrix.config.artifact }}
153+
asset_content_type: application/gzip

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "vcpkg"]
22
path = vcpkg
33
url = https://github.com/spinicist/vcpkg
4+
ignore = dirty

Scripts/nandicom

100644100755
File mode changed.

0 commit comments

Comments
 (0)