Update GHA workflow structure to match other repos (workflow-dispatch
, NodeJS 12 actions, etc.)
#22
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package SCT C++ binaries | |
on: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
release_title: | |
description: 'Release title (e.g. rYYYYMMDD)' | |
required: true | |
# all this does is collect three dependencies, | |
# - spinalcordtoolbox-ants which essentially a more minimal fork of https://github.com/ANTsX/ANTs | |
# - spinalcordtoolbox-dev, which comes from https://github.com/neuropoly/spinalcordtoolbox/blob/master/dev | |
# - ctrDetect, from https://www.creatis.insa-lyon.fr/site7/en/ctrDetect | |
# and squish them together in a single file. | |
# while making sure they all have the prefix "isct_" on them. | |
# TODO: include some checksums; the ctrDetect upstream doesn't even use TLS. | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [linux, osx, windows] | |
runs-on: ubuntu-latest | |
steps: | |
# upstream: https://github.com/neuropoly/ANTs, which has had its build reduced to only output 4 programs. | |
- name: get spinalcordtoolbox-ants | |
run: | | |
# TODO: this is currently at kousu/ANTs; get it moved to neuropoly/ANTs | |
case "${{ matrix.os }}" in | |
linux) | |
URL="https://github.com/spinalcordtoolbox/build_ANTs/releases/download/r20220516-2/sct-apps_centos7.tar.gz" | |
;; | |
osx) | |
URL="https://github.com/spinalcordtoolbox/build_ANTs/releases/download/r20220516-2/sct-apps_macos-10.15.tar.gz" | |
;; | |
windows) | |
URL="https://github.com/spinalcordtoolbox/build_ANTs/releases/download/r20220516-2/sct-apps_windows-2019.tar.gz" | |
;; | |
esac | |
curl -L "$URL" -o spinalcordtoolbox-ants.tar.gz | |
mkdir -p spinalcordtoolbox-ants && tar -zxvf spinalcordtoolbox-ants.tar.gz -C spinalcordtoolbox-ants | |
mkdir -p pkg && cp -rp spinalcordtoolbox-ants/sct-apps/* pkg/ | |
mkdir -p pkg/copyright | |
mv pkg/COPYING.txt pkg/copyright/LICENSE_ANTs.txt | |
# upstream: hhttps://github.com/biomedia-mira/stitching | |
- name: get stitching | |
run: | | |
case "${{ matrix.os }}" in | |
linux) | |
URL="https://github.com/spinalcordtoolbox/build_biomedia_stitching/releases/download/r20221109/stitching_centos-7.tar.gz" | |
;; | |
osx) | |
URL="https://github.com/spinalcordtoolbox/build_biomedia_stitching/releases/download/r20221018/stitching_macos-10.15.tar.gz" | |
;; | |
windows) | |
URL="https://github.com/spinalcordtoolbox/build_biomedia_stitching/releases/download/r20221018/stitching_windows-2019.tar.gz" | |
;; | |
esac | |
curl -L "$URL" -o stitching.tar.gz | |
mkdir -p stitching && tar -zxvf stitching.tar.gz -C stitching | |
mkdir -p pkg && cp -rp stitching/archive/* pkg/ | |
# upstream: https://github.com/neuropoly/spinalcordtoolbox/blob/master/dev/{isct_propseg,isct_dice_coefficient} | |
- name: get spinalcordtoolbox-dev | |
run: | | |
# TODO: get this building, then building in CI, and use the release from there. | |
# These URLs contain a version that hasn't been recompiled since 2016. | |
case "${{ matrix.os }}" in | |
linux) | |
URL="https://github.com/spinalcordtoolbox/spinalcordtoolbox-binaries/releases/download/binaries_dev/20160716_sct_binaries_dev_linux.tar.gz" | |
;; | |
osx) | |
URL="https://github.com/spinalcordtoolbox/spinalcordtoolbox-binaries/releases/download/binaries_dev/20161123_sct_binaries_dev_osx.tar.gz" | |
;; | |
windows) | |
URL="https://github.com/spinalcordtoolbox/spinalcordtoolbox-binaries/releases/download/binaries_dev/20220225_sct_binaries_dev_windows.tar.gz" | |
;; | |
esac | |
curl -L "$URL" -o spinalcordtoolbox-dev.tar.gz | |
mkdir -p pkg | |
mkdir -p spinalcordtoolbox-dev && tar -zxvf spinalcordtoolbox-dev.tar.gz -C spinalcordtoolbox-dev | |
cp -rp spinalcordtoolbox-dev/* pkg/ | |
# upstream: https://www.creatis.insa-lyon.fr/site7/en/ctrDetect | |
- name: get ctrDetect | |
run: | | |
echo "test test trying to build for ${{ matrix.os }}" | |
mkdir -p pkg | |
case "${{ matrix.os }}" in | |
linux) | |
URL="http://www.creatis.insa-lyon.fr/~sdika/soft/ctrDetect-v1_x86_64.tar.gz" | |
curl -L "$URL" -o ctrDetect.tar.gz | |
tar -zxvf ctrDetect.tar.gz | |
cp -p ctrDetect/{spine_detect,spine_train_svm} pkg/ | |
mv pkg/spine_train_svm pkg/train_svm # we have this one named unusually | |
;; | |
osx) | |
URL="http://www.creatis.insa-lyon.fr/~sdika/soft/ctrDetect-v1_macos10.11.tar.gz" | |
curl -L "$URL" -o ctrDetect.tar.gz | |
tar -zxvf ctrDetect.tar.gz | |
cp -p ctrDetect/{spine_detect,spine_train_svm} pkg/ | |
mv pkg/spine_train_svm pkg/train_svm # we have this one named unusually | |
;; | |
windows) | |
URL="http://www.creatis.insa-lyon.fr/~sdika/soft/ctrDetect-v1_win.zip" | |
curl -L "$URL" -o ctrDetect.zip | |
unzip ctrDetect.zip | |
mv ctrDetect-win/ ctrDetect | |
cp -p ctrDetect/{spine_detect,spine_train_svm}.exe pkg/ | |
mv pkg/spine_train_svm.exe pkg/train_svm.exe # we have this one named unusually | |
;; | |
esac | |
cp -p ctrDetect/LICENSE.txt pkg/copyright/LICENSE_ctrDetect.txt | |
cp -p ctrDetect/LICENSE_opencv.txt pkg/copyright/ | |
chmod -x pkg/copyright/* # upstream accidentally marked the licenses as programs, oops. | |
- name: "'isct_' prefix" | |
run: | | |
# TODO: there's gotta be a shorter way to do this | |
# add the isct_ to programs that don't already have it | |
cd pkg | |
find ./ -type f -executable ! -name "isct_*" -maxdepth 1 | while read fname; do mv "$fname" $(dirname "$fname")/isct_$(basename "$fname"); done | |
- name: package | |
run: | | |
# Github Artifacts only make .zips, so make a .tar.gz manually to preserve permissions/dates/etc | |
tar -zcvf spinalcordtoolbox-binaries_${{ matrix.os }}.tar.gz -C pkg ./ | |
- name: upload result | |
uses: actions/upload-artifact@v3 | |
with: | |
name: spinalcordtoolbox-binaries_${{ matrix.os }} | |
path: spinalcordtoolbox-binaries_${{ matrix.os }}.tar.gz | |
release: | |
needs: [build] | |
runs-on: ubuntu-latest | |
# Only attach to release if workflow is run manually. (This allows the workflow to double as a PR test.) | |
if: github.event_name == 'workflow_dispatch' | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: spinalcordtoolbox-binaries_linux | |
- uses: actions/download-artifact@v3 | |
with: | |
name: spinalcordtoolbox-binaries_osx | |
- uses: actions/download-artifact@v3 | |
with: | |
name: spinalcordtoolbox-binaries_windows | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.event.inputs.release_title }} | |
name: Release ${{ github.sha }} | |
draft: true | |
artifacts: "spinalcordtoolbox-binaries_linux.tar.gz,spinalcordtoolbox-binaries_osx.tar.gz,spinalcordtoolbox-binaries_windows.tar.gz" | |
artifactContentType: application/gzip |