|
| 1 | +name: 'Install Packages' |
| 2 | +description: 'Install required packages' |
| 3 | +runs: |
| 4 | + using: composite |
| 5 | + steps: |
| 6 | + - env: |
| 7 | + package_matrix: | |
| 8 | + _os | Linux | macOS | |
| 9 | + _update | sudo apt-get update | brew update | cmd to update pkg mgr database |
| 10 | + _install | sudo apt-get install --no-upgrade | brew install | cmd to install pkg |
| 11 | + boost/ | libboost-dev | boost | bulk of boost lib |
| 12 | + boost/boost/date_time/ | libboost-date-time-dev | | boost date-time lib |
| 13 | + boost/libs/system/ | libboost-system-dev | | boost system lib |
| 14 | + boost/libs/thread/ | libboost-thread-dev | | boost thread lib |
| 15 | + freetype/ | libfreetype-dev | freetype | |
| 16 | + jpeg/ | libjpeg-dev | libjpeg | |
| 17 | + openexr/ | libopenexr-dev | openexr | |
| 18 | + png/ | libpng-dev | libpng | |
| 19 | + | libsdl-dev | sdl | simple direct media layer |
| 20 | + tiff/ | libtiff-dev | libtiff | |
| 21 | + zlib/ | libz-dev | zlib | |
| 22 | + | automake | automake | |
| 23 | + | pkg-config | pkg-config | |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + echo "Preparing to install packages for ${{ runner.os }}" |
| 27 | + package_matrix=`echo "${package_matrix}" | sed 's/ *| */|/g'` |
| 28 | + col_list=`echo "${package_matrix}" | head -n1 | tr '|' '\n'` |
| 29 | + col_os=`echo "${col_list}" | grep -nx "${{ runner.os }}" || true` |
| 30 | + if test -z "${col_os}" ; then |
| 31 | + echo "::error::Operating system not found in matrix." |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | + col_index=`echo "${col_os}" | cut -d':' -f1` |
| 35 | + package_matrix=`echo "${package_matrix}" | cut -d'|' -f"1,${col_index}"` |
| 36 | + do_update=`echo "${package_matrix}" | grep '_update' | cut -d'|' -f2` |
| 37 | + do_install=`echo "${package_matrix}" | grep '_install' | cut -d'|' -f2` |
| 38 | + echo "::group::Determine packages to install" |
| 39 | + cp /dev/null ~PACKAGE_LIST |
| 40 | + echo "${package_matrix}" | while read line ; do |
| 41 | + key=`echo ${line} | cut -d'|' -f1` |
| 42 | + value=`echo ${line} | cut -d'|' -f2` |
| 43 | + if test -z "${value}" ; then |
| 44 | + continue |
| 45 | + fi |
| 46 | + case "${key}" in |
| 47 | + _*) continue ;; |
| 48 | + '') condition="true" ;; |
| 49 | + */) condition="test -d 'libraries/${key}'" ;; |
| 50 | + *) echo "::warning::Ignoring unexpected key '${key}' in package matrix." ; continue ;; |
| 51 | + esac |
| 52 | + if eval "${condition}" ; then |
| 53 | + echo "${value}" | tee -a ~PACKAGE_LIST |
| 54 | + else |
| 55 | + echo "(${value} not required for this version)" |
| 56 | + fi |
| 57 | + done |
| 58 | + package_list=`cat ~PACKAGE_LIST` |
| 59 | + rm ~PACKAGE_LIST |
| 60 | + echo "::endgroup::" |
| 61 | + if test -n "${do_update}" ; then |
| 62 | + echo "::group::Update package manager database" |
| 63 | + ${do_update} |
| 64 | + echo "::endgroup::" |
| 65 | + else |
| 66 | + echo "::warning::No package manager update command found in matrix." |
| 67 | + fi |
| 68 | + if test -n "${do_install}" ; then |
| 69 | + echo "::group::Install packages" |
| 70 | + ${do_install} ${package_list} |
| 71 | + echo "::endgroup::" |
| 72 | + elif test -n "${package_list}" ; then |
| 73 | + echo "::error::No package manager install command found in matrix." |
| 74 | + else |
| 75 | + echo "::warning::No package manager install command found in matrix (nor packages to install)." |
| 76 | + fi |
0 commit comments