Cross-platform release binaries #9
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: Cross-platform release binaries | |
on: | |
release: | |
types: [created] | |
env: | |
CMAKE_VERSION: 3.23.1 | |
jobs: | |
build: | |
name: ${{ matrix.config.name }} | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Centos7-GCC", | |
os_desc: centos7, | |
image: "centos/devtoolset-7-toolchain-centos7:7", | |
build_type: "Release", | |
cc: "gcc", | |
cxx: "g++", | |
generators: "Unix Makefiles" | |
} | |
- { | |
name: "Ubuntu-18.04-GCC", | |
os_desc: ubuntu-18.04, | |
image: "ubuntu:18.04", | |
build_type: "Release", | |
cc: "gcc", | |
cxx: "g++", | |
generators: "Ninja" | |
} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Get ANTs version and set artifact name | |
run: | | |
echo "ANTS_VERSION=${ANTS_TAG#v}" >> $GITHUB_ENV | |
echo "ARTIFACT=ants-${ANTS_TAG}-${{ matrix.config.os }}-${{ runner.arch }}-${{ matrix.config.cc }}.zip" >> $GITHUB_ENV | |
env: | |
ANTS_TAG: ${{ github.ref_name }} | |
- name: Set up build container | |
run: | | |
docker pull ${{ matrix.config.image }} | |
docker create --name build_container -v ${{ github.workspace }}:/workspace -v ${{ runner.temp }}/artifact:/artifact ${{ matrix.config.image }} sleep infinity | |
docker start build_container | |
- name: Install dependencies on Centos | |
if: startsWith(matrix.config.name, 'Centos7') | |
run: | | |
docker exec --user root build_container bash -c " | |
yum -y update && yum clean all | |
yum -y install devtoolset-7 git zlib-devel | |
curl -OL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh | |
chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh | |
./cmake-${CMAKE_VERSION}-linux-x86_64.sh --skip-license --prefix=/usr/local | |
" | |
- name: Install dependencies on Ubuntu | |
if: startsWith(matrix.config.name, 'Ubuntu-18.04') | |
run: | | |
docker exec --user root build_container bash -c " | |
apt-get update | |
apt-get install -y --no-install-recommends \ | |
apt-transport-https \ | |
bc \ | |
build-essential \ | |
ca-certificates \ | |
gnupg \ | |
ninja-build \ | |
git \ | |
software-properties-common \ | |
wget \ | |
zip | |
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - | |
apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main' | |
apt-get update | |
apt-get -y install cmake=${CMAKE_VERSION}-0kitware1ubuntu18.04.1 cmake-data=${CMAKE_VERSION}-0kitware1ubuntu18.04.1 | |
ninja --version | |
cmake --version | |
gcc --version | |
" | |
- name: Configure | |
run: | | |
docker exec --user root build_container bash -c " | |
mkdir -p /workspace/build | |
cd /workspace/build | |
cmake \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ | |
-G '${{ matrix.config.generators }}' \ | |
-DBUILD_TESTING=ON \ | |
-DRUN_SHORT_TESTS=ON \ | |
-DRUN_LONG_TESTS=OFF \ | |
-DCMAKE_INSTALL_PREFIX:PATH=/workspace/install/ants-${{ env.ANTS_VERSION }} \ | |
/workspace | |
" | |
- name: Build | |
run: | | |
docker exec --user root build_container bash -c " | |
cd /workspace/build | |
cmake --build . --config ${{ matrix.config.build_type }} --parallel 1 | |
" | |
- name: Test | |
run: | | |
docker exec --user root build_container bash -c " | |
cd /workspace/build/ANTS-build | |
ctest | |
" | |
- name: Install | |
run: | | |
docker exec --user root build_container bash -c " | |
cd /workspace/build/ANTS-build | |
cmake --install . | |
" | |
- name: Pack | |
run: | | |
docker exec --user root build_container bash -c " | |
cd /workspace/install | |
zip -r /artifact/${{ env.ARTIFACT }} . | |
" | |
- name: Upload release asset | |
uses: ncipollo/[email protected] | |
with: | |
allowUpdates: true | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
artifacts: "${{ runner.temp }}/artifact/${{ env.ARTIFACT }}" | |
artifactContentType: application/zip | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Clean up | |
run: | | |
docker stop build_container | |
docker rm build_container |