Skip to content

Cross-platform release binaries #13

Cross-platform release binaries

Cross-platform release binaries #13

name: Cross-platform release binaries
on:
release:
types: [created]
env:
CMAKE_VERSION: 3.23.1
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ubuntu-latest
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
run: |
echo "ANTS_VERSION=${ANTS_TAG#v}" >> $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 ${{ matrix.config.image }} sleep infinity
docker start build_container
- name: Install dependencies on Centos
if: startsWith(matrix.config.name, 'Centos7')
run: |
docker exec 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
mkdir -p /opt/cmake/bin
./cmake-${CMAKE_VERSION}-linux-x86_64.sh --skip-license --prefix=/opt/cmake
echo /opt/cmake/bin >> /etc/profile.d/cmake.sh
"
- name: Install dependencies on Ubuntu
if: startsWith(matrix.config.name, 'Ubuntu-18.04')
run: |
docker exec 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 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 build_container bash -c "
cd /workspace/build
cmake --build . --config ${{ matrix.config.build_type }} --parallel 1
"
- name: Test
run: |
docker exec build_container bash -c "
cd /workspace/build/ANTS-build
ctest
"
- name: Install
run: |
docker exec build_container bash -c "
cd /workspace/build/ANTS-build
cmake --install .
"
- name: Pack
run: |
docker exec build_container bash -c "
cd /workspace/install
zip -r /workspace/${{ env.ARTIFACT }} .
"
- name: Upload release asset
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
artifacts: "${{ env.ARTIFACT }}"
artifactContentType: application/zip
token: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up
run: |
docker stop build_container
docker rm build_container