cmake-ninja #167
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: cmake-ninja | |
on: | |
push: | |
#pull_request: | |
release: | |
types: published | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# 20:00 every Sunday UTC (which is 21:00 CET or 22:00 CEST) | |
- cron: '0 20 * * 0' | |
jobs: | |
build: | |
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | |
# You can convert this to a matrix build if you need cross-platform coverage. | |
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
runs-on: ubuntu-latest | |
# Use centos7 | |
container: | |
image: centos:7 | |
options: --privileged | |
steps: | |
- name: Install GIT | |
run: | | |
date | |
yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm | |
yum -y install git | |
git --version | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Dependencies | |
run: | | |
git config --global --add safe.directory '*' | |
git status | |
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.sh | |
chmod +x cmake-3.16.4-Linux-x86_64.sh | |
./cmake-3.16.4-Linux-x86_64.sh --skip-license --prefix=/usr/local | |
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-16.02-20.el7.x86_64.rpm | |
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-plugins-16.02-20.el7.x86_64.rpm | |
rpm -U --quiet p7zip-16.02-20.el7.x86_64.rpm | |
rpm -U --quiet p7zip-plugins-16.02-20.el7.x86_64.rpm | |
yum install -y epel-release | |
yum install -y make libasan gcc-gfortran gcc-c++ unzip openblas-devel lapack-devel zlib-devel tree fuse-sshfs fuse-libs file | |
groupadd fuse | |
user="$(whoami)" | |
usermod -a -G fuse "$user" | |
curl -L -O https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip | |
unzip ninja-linux.zip | |
mv ./ninja /usr/bin | |
- name: Configure CMake | |
shell: bash | |
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | |
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | |
run: cmake -G Ninja -B build -DHOPR_INSTRUCTION=-mtune=generic -DCMAKE_BUILD_TYPE=Release -DLIBS_USE_MPI=OFF -DCMAKE_INSTALL_PREFIX=/usr | |
- name: Build | |
shell: bash | |
# Build your program with the given configuration | |
run: cmake --build build | |
- name: Create AppImage | |
shell: bash | |
run: | | |
cd build | |
DESTDIR=AppDir ninja install | |
mkdir -p AppDir/usr/share/icons | |
cp ../docs/Meshformat/pics/HOPR_logo.png AppDir/usr/share/icons/hopr.png | |
curl -L -O https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage | |
chmod +x linuxdeploy-x86_64.AppImage | |
mkdir -p AppDir/usr/share/icons/hicolor/64x64/apps/ | |
ln -sf ../../../hopr.png AppDir/usr/share/icons/hicolor/64x64/apps/ | |
tree AppDir | |
./linuxdeploy-x86_64.AppImage --appdir AppDir --output appimage --desktop-file=../hopr.desktop | |
- name: Set env | |
run: | | |
echo "BINARYPATH=$(ls build/hopr*x86_64.AppImage)" >> $GITHUB_ENV | |
echo "BINARYNAME=$(basename $(ls build/hopr*x86_64.AppImage))" >> $GITHUB_ENV | |
#- name: Test env variable | |
#run: | | |
#echo ${BINARYPATH} | |
#echo ${{env.BINARYPATH}} | |
#echo ${BINARYNAME} | |
#echo ${{env.BINARYNAME}} | |
#cat src/buildinfo.h | |
- name: Check file existence | |
id: check_files | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: "${{ env.BINARYPATH }}" | |
- name: Fail if binary does not exist | |
if: steps.check_files.outputs.files_exists == 'false' | |
uses: actions/github-script@v3 | |
with: | |
script: | | |
core.setFailed('no binary found under build/hopr*x86_64.AppImage.') | |
- name: Create archives | |
run: | | |
mkdir artifacts | |
mkdir assets | |
cp ${BINARYPATH} . | |
md5sum ${BINARYNAME} > md5sum.txt | |
7z a assets/hopr-linux64.zip ${BINARYNAME} md5sum.txt | |
mv ${BINARYNAME} md5sum.txt artifacts/. | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: hopr-binary-v1.2.1 | |
path: artifacts | |
- name: Upload release asset | |
if: github.event.action == 'published' | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./assets/hopr-linux64.zip | |
asset_name: hopr-linux64.zip | |
asset_content_type: application/zip | |