Skip to content

Build ANTs

Build ANTs #19

Workflow file for this run

name: Build ANTs
on:
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
git_ref:
description: 'Upstream ANTsX/ANTs commit ref to check out when building'
required: true
default: 'b37e8b56e4e518b0f2947f80d0e3701a5ddfe120'
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
# first, rewrite OS names to be safe for github artifacts.
- name: names
run: |
OS="${{ matrix.os }}"
OS=$(echo "$OS" | sed s/://)
echo "ARTIFACT=$OS" >> $GITHUB_ENV
- name: package
run: |
# download and extract pre-built ants
case "${{ env.ARTIFACT }}" in
ubuntu-latest)
URL="https://github.com/spinalcordtoolbox/build_ANTs/releases/download/r20220516-2/sct-apps_centos7.tar.gz"
;;
macos-latest)
URL="https://github.com/spinalcordtoolbox/build_ANTs/releases/download/r20220516-2/sct-apps_macos-10.15.tar.gz"
;;
curl -L "$URL" -o ants-unix.tar.gz
unzip ants-unix.tar.gz
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
mkdir sct-apps/
cp ants-unix/ants-2.4.4/bin/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform} sct-apps
(cd sct-apps; for i in *; do mv $i isct_$i; done)
cp COPYING.txt sct-apps
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
continue-on-error: true
- name: results (DEBUG)
run: find .
- name: Upload result
uses: actions/upload-artifact@v4
with:
name: sct-apps_${{ env.ARTIFACT }}
#path: fakeroot/ # this is 2.3G large in this build
path: sct-apps_${{ env.ARTIFACT }}.tar.gz
build-manylinuxes: # Github only supports Ubuntu natively; for other Linuxes, we need to use Docker
strategy:
matrix:
os: ['quay.io/centos/centos:stream8']
runs-on: ubuntu-latest
container: ${{ matrix.os }}
steps:
- name: package
run: |
# download and extract pre-built ants
curl -L "https://github.com/ANTsX/ANTs/releases/download/v2.4.4/ants-2.4.4-centos7-X64-gcc.zip" -o ants-centos.tar.gz
unzip ants-centos.tar.gz
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
mkdir sct-apps/
cp ants-centos/ants-2.4.4/bin/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform} sct-apps
(cd sct-apps; for i in `ls`; do mv $i isct_$i; done)
cp COPYING.txt sct-apps
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
continue-on-error: true
- name: results (DEBUG)
run: find .
- name: Upload result
uses: actions/upload-artifact@v4
with:
name: sct-apps_centos-8
#path: fakeroot/ # this is 2.3G large in this build
path: sct-apps_centos-8.tar.gz
build-windows:
strategy:
matrix:
os: [ windows-latest ]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
# first, rewrite OS names to be safe for github artifacts.
- name: names
run: |
OS="${{ matrix.os }}"
OS=$(echo "$OS" | sed s/://)
echo "ARTIFACT=$OS" >> $GITHUB_ENV
- name: package
run: |
curl -L "https://github.com/ANTsX/ANTs/releases/download/v2.4.4/ants-2.4.4-ubuntu-22.04-X64-gcc.zip" -o ants-windows.tar.gz
unzip ants-windows.tar.gz
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
mkdir sct-apps/
cp ants-windows/ants-2.4.4/bin/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform}.exe sct-apps
(cd sct-apps; for i in `ls`; do mv $i isct_$i; done)
cp COPYING.txt sct-apps
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
continue-on-error: true
- name: results (DEBUG)
run: find .
- name: Upload result
uses: actions/upload-artifact@v4
with:
name: sct-apps_${{ env.ARTIFACT }}
path: sct-apps_${{ env.ARTIFACT }}.tar.gz
release:
needs: [build, build-manylinuxes, build-windows]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: sct-apps_centos-8
continue-on-error: true
- name: checkin # DEBUG
run: find .
# - uses: actions/download-artifact@v4
# with:
# name: sct-apps_centos8
# continue-on-error: true
# - name: checkin # DEBUG
# run: find .
# - uses: actions/download-artifact@v4
# with:
# name: sct-apps_archlinux
# continue-on-error: true
- uses: actions/download-artifact@v4
with:
name: sct-apps_ubuntu-latest
continue-on-error: true
- uses: actions/download-artifact@v4
with:
name: sct-apps_macos-latest
continue-on-error: true
- uses: actions/download-artifact@v4
with:
name: sct-apps_windows-latest
continue-on-error: true
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# name the release with the run_id to allow multiple builds on the same branch/tag
# https://github.com/actions/create-release/issues/2#issuecomment-613591846
tag: ${{ github.ref }}-${{github.run_id }}
name: Release ${{ github.sha }}
draft: true
prerelease: true
artifacts: 'sct-apps_centos-8/sct-apps_centos-8.tar.gz,sct-apps_ubuntu-latest/sct-apps_ubuntu-latest.tar.gz,sct-apps_macos-latest/sct-apps_macos-latest.tar.gz,sct-apps_windows-latest/sct-apps_windows-latest.tar.gz'