libcellml-deploy-on-release #2
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: libcellml-deploy-on-release | |
on: | |
release: | |
types: | |
- created | |
- edited | |
env: | |
BUILD_TYPE: Release | |
MACOSX_DEPLOYMENT_TARGET: 10.15 | |
jobs: | |
setup-jobs: | |
runs-on: ubuntu-latest | |
outputs: | |
binaries-destination: ${{ steps.binaries-out.outputs.binaries-destination }} | |
allowed-jobs: ${{ steps.do-jobs.outputs.allowed-jobs }} | |
steps: | |
- name: Determine output location | |
id: binaries-out | |
shell: cmake -P {0} | |
run: | | |
set(_OUTPUT_LOCATION "nowhere") | |
set(PRERELEASE "${{ github.event.release.prerelease }}") | |
if (PRERELEASE STREQUAL "true") | |
set(_OUTPUT_LOCATION "Artifact") | |
else() | |
set(_OUTPUT_LOCATION "Publish") | |
endif() | |
if ("${{ github.event.action }}" STREQUAL "edited") | |
set(_OUTPUT_LOCATION "unknown") | |
set(RELEASE_BODY "${{ github.event.release.body }}") | |
string(REPLACE "\n" ";" _PARTS "${RELEASE_BODY}") | |
foreach(_PART ${_PARTS}) | |
string(STRIP "${_PART}" _PART) | |
string(REGEX MATCH "^[[]ODD ([a-zA-Z]+) ([a-zA-Z]+)[]]$" _RESULT "${_PART}") | |
if (CMAKE_MATCH_1 STREQUAL "Publish") | |
set(_OUTPUT_LOCATION Publish) | |
elseif(CMAKE_MATCH_1 STREQUAL "Artifact") | |
set(_OUTPUT_LOCATION Artifact) | |
endif() | |
endforeach() | |
endif() | |
message(STATUS "Setting binaries destination to '${_OUTPUT_LOCATION}'.") | |
#file(APPEND $ENV{GITHUB_OUTPUT} "binaries-destination=${_OUTPUT_LOCATION}") | |
file(APPEND $ENV{GITHUB_OUTPUT} "binaries-destination=Neither") | |
- name: Determine next jobs | |
id: do-jobs | |
shell: cmake -P {0} | |
run: | | |
set(_ALLOWED_JOBS "All") | |
if ("${{ github.event.action }}" STREQUAL "edited") | |
set(_ALLOWED_JOBS "none") | |
set(RELEASE_BODY "${{ github.event.release.body }}") | |
string(REPLACE "\n" ";" _PARTS "${RELEASE_BODY}") | |
foreach(_PART ${_PARTS}) | |
string(STRIP "${_PART}" _PART) | |
string(REGEX MATCH "^[[]ODD ([a-zA-Z]+) ([a-zA-Z]+)[]]$" _RESULT "${_PART}") | |
if (CMAKE_MATCH_2 STREQUAL "Installers") | |
set(_ALLOWED_JOBS Installers) | |
elseif(CMAKE_MATCH_2 STREQUAL "Wheels") | |
set(_ALLOWED_JOBS Wheels) | |
elseif(CMAKE_MATCH_2 STREQUAL "Javascript") | |
set(_ALLOWED_JOBS Javascript) | |
endif() | |
endforeach() | |
endif() | |
message(STATUS "Setting allowed jobs to '${_ALLOWED_JOBS}'.") | |
file(APPEND $ENV{GITHUB_OUTPUT} "allowed-jobs=${_ALLOWED_JOBS}") | |
os-binaries: | |
needs: setup-jobs | |
if: needs.setup-jobs.outputs.allowed-jobs == 'Installers' || needs.setup-jobs.outputs.allowed-jobs == 'All' | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Windows Server 2019 MSVC", | |
os: windows-2019, | |
libxml2_dir: '-D "LibXml2_DIR=$ENV{GITHUB_WORKSPACE}/usr/local/libxml2-2.9.10/CMake/"', | |
zlib_dir: '-D "ZLIB_DIR=$ENV{GITHUB_WORKSPACE}/usr/local/ZLIB-1.2.3/CMake/"', | |
cc: "cl", cxx: "cl", | |
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" | |
} | |
- { | |
name: "Ubuntu 20.04 GCC", | |
os: ubuntu-20.04, | |
build_type: "Release", cc: "gcc", cxx: "g++" | |
} | |
- { | |
name: "macOS 12 Clang", | |
os: macos-12, | |
cc: "clang", cxx: "clang++" | |
} | |
steps: | |
- name: Checkout libCellML | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
- name: Checkout zlib | |
uses: actions/checkout@v3 | |
with: | |
repository: OpenCMISS-Dependencies/zlib | |
path: zlib | |
ref: v1.2.3 | |
- name: Checkout LibXml2 | |
uses: actions/checkout@v3 | |
with: | |
repository: OpenCMISS-Dependencies/libxml2 | |
path: libxml2 | |
ref: v2.9.10 | |
- name: Add msbuild to PATH | |
uses: microsoft/[email protected] | |
if: runner.os == 'Windows' | |
- name: Prepare Windows environment | |
if: runner.os == 'Windows' | |
shell: cmake -P {0} | |
run: | | |
# Prepare environment script. | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
set(WIN_PATH) | |
file(TO_CMAKE_PATH "$ENV{PATH}" ENV_PATH) | |
set(PATH_LIST "") | |
foreach(_PATH ${ENV_PATH}) | |
if (NOT "${_PATH}" MATCHES ".*Strawberry") | |
list(APPEND WIN_PATH "${_PATH}") | |
endif() | |
endforeach() | |
file(TO_NATIVE_PATH "${WIN_PATH}" WIN_PATH) | |
set(ENV{PATH} "${WIN_PATH}") | |
execute_process(COMMAND ${CMAKE_COMMAND} -S "${ACTION_DIR}/zlib" -B "${ACTION_DIR}/build-zlib" -DBUILD_SHARED_LIBS=FALSE -DCMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/usr/local) | |
execute_process(COMMAND ${CMAKE_COMMAND} --build "${ACTION_DIR}/build-zlib" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-zlib") | |
execute_process(COMMAND ${CMAKE_COMMAND} --install "${ACTION_DIR}/build-zlib" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-zlib") | |
execute_process(COMMAND ${CMAKE_COMMAND} -S "${ACTION_DIR}/libxml2" -B "${ACTION_DIR}/build-libxml2" ${{ matrix.config.zlib_dir }} -DCMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/usr/local -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_TESTS=OFF -DLIBXML2_WITH_PROGRAMS=OFF | |
RESULT_VARIABLE _RESULT OUTPUT_VARIABLE _OUTPUT ERROR_VARIABLE _ERROR) | |
execute_process(COMMAND ${CMAKE_COMMAND} --build "${ACTION_DIR}/build-libxml2" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-libxml2") | |
execute_process(COMMAND ${CMAKE_COMMAND} --install "${ACTION_DIR}/build-libxml2" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-libxml2") | |
- name: Configure | |
shell: cmake -P {0} | |
run: | | |
# Configure library script | |
set(OPTIONAL_ARGUMENTS) | |
set(ENV{CC} ${{ matrix.config.cc }}) | |
set(ENV{CXX} ${{ matrix.config.cxx }}) | |
set(PYTHON_LOCATION $ENV{pythonLocation}) | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
if (NOT "${{ runner.os }}" STREQUAL "Windows") | |
list(APPEND OPTIONAL_ARGUMENTS -D BUILD_TYPE=$ENV{BUILD_TYPE}) | |
list(APPEND OPTIONAL_ARGUMENTS -D COVERAGE=OFF) | |
endif() | |
if ("${{ matrix.config.cc }}" STREQUAL "clang") | |
list(APPEND OPTIONAL_ARGUMENTS -D LLVM_COVERAGE=OFF) | |
endif() | |
if ("${{ matrix.config.os }}" STREQUAL "ubuntu-20.04") | |
list(APPEND OPTIONAL_ARGUMENTS -D PACKAGE_ANY_LINUX=TRUE) | |
endif() | |
list(APPEND OPTIONAL_ARGUMENTS ${{ matrix.config.libxml2_dir }}) | |
execute_process( | |
COMMAND ${CMAKE_COMMAND} | |
-S . | |
-B build | |
${OPTIONAL_ARGUMENTS} | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Configure failed.") | |
endif() | |
- name: Build | |
shell: cmake -P {0} | |
run: | | |
# Build library script | |
include(ProcessorCount) | |
ProcessorCount(N) | |
math(EXPR JOBS "${N} + 1") | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
set(BUILD_COMMMAND msbuild libCellML.sln /t:Build /p:Configuration=$ENV{BUILD_TYPE} /m:${N}) | |
else() | |
set(BUILD_COMMMAND make -j ${JOBS}) | |
endif() | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
execute_process( | |
COMMAND ${BUILD_COMMMAND} | |
WORKING_DIRECTORY "${ACTION_DIR}/build" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Build failed.") | |
endif() | |
- name: Test | |
shell: cmake -P {0} | |
run: | | |
# Test library script | |
include(ProcessorCount) | |
ProcessorCount(N) | |
math(EXPR JOBS "${N} + 1") | |
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
execute_process( | |
COMMAND ${CMAKE_CTEST_COMMAND} -j ${JOBS} -C $ENV{BUILD_TYPE} | |
WORKING_DIRECTORY "${ACTION_DIR}/build" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Tests failed.") | |
endif() | |
- name: Package | |
id: package | |
shell: cmake -P {0} | |
run: | | |
# Package library script | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
execute_process( | |
COMMAND ${CMAKE_CPACK_COMMAND} -C $ENV{BUILD_TYPE} | |
WORKING_DIRECTORY "${ACTION_DIR}/build" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Packaging failed.") | |
endif() | |
file(GLOB _DIST_FILES ${ACTION_DIR}/build/dist/*) | |
string(REPLACE ";" "\n" _DIST_FILES "${_DIST_FILES}") | |
file(APPEND $ENV{GITHUB_OUTPUT} "files<<EOF\n${_DIST_FILES}\nEOF") | |
- name: Publish libraries | |
# if: needs.setup-jobs.outputs.binaries-destination == 'Publish' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ steps.package.outputs.files }} | |
tag_name: ${{ github.event.release.tag_name }} | |
- name: Upload libraries as artifacts | |
if: needs.setup-jobs.outputs.binaries-destination == 'Artifact' | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ./build/dist/* |