Skip to content

Eurymyrmex

Eurymyrmex #6

name: Cross-platform release binaries
# Use Docker to build on platforms other than Ubuntu
on:
release:
types: [created]
env:
CMAKE_VERSION: 3.23.1
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ubuntu-latest
container:
image: ${{ matrix.config.image }}
options: ${{ matrix.config.container_options }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Centos7-GCC",
# os_desc used to name output
os_desc: centos7,
# Use image that already has gcc installed
image: "centos/devtoolset-7-toolchain-centos7:7",
container_options: "--user root",
build_type: "Release",
cc: "gcc",
cxx: "g++",
generators: "Unix Makefiles"
}
- {
name: "Ubuntu-18.04-GCC",
# os_desc used to name output
os_desc: ubuntu-18.04,
# This is a minimal image, need to add many dependencies
image: "ubuntu:18.04",
container_options: "--user root",
build_type: "Release",
cc: "gcc",
cxx: "g++",
generators: "Ninja"
}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Get ANTs version
run:
echo "ANTS_VERSION=${ANTS_TAG#v}" >> $GITHUB_ENV
env:
ANTS_TAG: ${{ github.ref_name }}
- name: Define env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
echo "CC=${{ matrix.config.cc }}" >> $GITHUB_ENV
echo "CXX=${{ matrix.config.cxx }}" >> $GITHUB_ENV
echo "ARTIFACT=${{ runner.temp }}/ants-${{ env.ANTS_VERSION }}-${{ matrix.config.os_desc }}-${{ runner.arch }}-${{ matrix.config.cc }}.zip" >> $GITHUB_ENV
- name: Install dependencies on Centos
if: startsWith(matrix.config.name, 'Centos7')
run: |
yum -y update && yum clean all
# Need devtoolset-7 to get zip and other goodies, though GCC is installed by default
# Also need to add python3 if that ever becomes necessary
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" >> $GITHUB_PATH
- name: Install dependencies on ubuntu
if: startsWith(matrix.config.name, 'Ubuntu-18.04')
run: |
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
shell: bash
run: |
mkdir -p /opt/build
cd /opt/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=/opt/install/ants-${{ env.ANTS_VERSION }} \
${GITHUB_WORKSPACE}
- name: Build
shell: bash
run: |
cd /opt/build
cmake --build . --config ${{ matrix.config.build_type }} --parallel 1
- name: Test
shell: bash
working-directory: ${{ runner.temp }}
run: |
cd /opt/build/ANTS-build
ctest
- name: Install
shell: bash
run: |
cd /opt/build/ANTS-build
cmake --install .
- name: Pack
shell: bash
run: |
cd /opt/install
zip -r ${ARTIFACT} .
- name: Upload release asset
uses: ncipollo/[email protected]
with:
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
artifacts: "${{ env.ARTIFACT }}"
artifactContentType: application/zip
token: ${{ secrets.GITHUB_TOKEN }}