-
Notifications
You must be signed in to change notification settings - Fork 65
133 lines (116 loc) · 4.21 KB
/
Copy pathcmake-linux.yml
File metadata and controls
133 lines (116 loc) · 4.21 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
name: CI Linux
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
release:
types: [ published ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
deployments: write
packages: write
jobs:
build-linux:
runs-on: ubuntu-latest
timeout-minutes: 40
permissions:
contents: write
actions: write
packages: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: '3.10.11'
- name: "Install jsondiff"
run: pip install jsondiff
- name: "Install cmake"
run: |
sudo apt-get update
sudo apt-get install rsync
sudo apt-get install cmake
# Set up Docker Buildx for better caching support
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
# Cache the build directory containing all external dependencies
- name: Cache build directory
id: cache-build-dir
uses: actions/cache@v6
env:
cache-name: cache-build-artifacts
with:
path: |
build/
/tmp/dockcross
# Cache key includes hash of CMakeExternals files and Makefile
# to invalidate when dependencies or build process changes
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('CMakeExternals/DCMTK.cmake', 'CMakeExternals/ITK.cmake', 'CMakeExternals/zlib.cmake', 'docker/Makefile') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
# Report cache status
- name: Report cache status
run: |
if [ "${{ steps.cache-build-dir.outputs.cache-hit }}" == "true" ]; then
echo "✓ Cache hit! Using cached build artifacts"
echo "Cache key: ${{ steps.cache-build-dir.outputs.cache-primary-key }}"
if [ -d build ]; then
echo "Build directory size:"
du -sh build/ 2>/dev/null || true
echo "Build directory contents:"
ls -lh build/ 2>/dev/null || true
fi
if [ -f /tmp/dockcross ]; then
echo "✓ Dockcross script cached"
fi
else
echo "✗ Cache miss. Will build all dependencies from source"
fi
- name: "Build dcmqi"
run: |
cd docker && make dcmqi
- name: "Test dcmqi"
run: |
cd docker && make dcmqi.test
- name: "Publish docker image"
# Only run if the event is not a pull request and the repository owner is QIICR.
# The latter is to prevent forks from publishing packages even if the owner's token
# would have sufficient privileges.
if: ${{ (github.event_name != 'pull_request') && (github.repository_owner == 'QIICR')}}
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }} && \
docker push qiicr/dcmqi:`git describe --tags --exact-match 2> /dev/null || echo "latest"` \
|| echo "skipping docker push"
- name: "Upload package as artifact"
id: upload-artifact
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: dcmqi-linux-package
path: build/dcmqi-build/dcmqi-*-linux*.tar.gz
- name: "Upload package as artifact (retry)"
if: steps.upload-artifact.outcome == 'failure'
uses: actions/upload-artifact@v7
with:
name: dcmqi-linux-package
path: build/dcmqi-build/dcmqi-*-linux*.tar.gz
- name: "Publish linux package"
# Publish tagged (stable) releases only. The rolling "latest" prerelease is
# (re)created by the finalize-latest workflow once all platforms finish building.
# The repository-owner check prevents forks from publishing packages even if the
# owner's token would have sufficient privileges.
if: ${{ (github.event_name == 'release') && (github.repository_owner == 'QIICR') }}
env:
GH_TOKEN: ${{ secrets.GA_TOKEN }}
run: |
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
if [ -n "$TAG" ] && [ "$TAG" != "latest" ]; then
gh release upload "$TAG" \
build/dcmqi-build/dcmqi-*-linux.tar.gz \
--clobber
fi