Added "patchlevel" to modified framework to distinguish from vanilla … #50
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: Build DigiLivolo software | |
on: | |
push: | |
branches: [ main, dev ] | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
pull_request: | |
branches: [ main, dev ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{ matrix.sys.os }} | |
container: ${{ matrix.sys.container }} | |
strategy: | |
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | |
fail-fast: false | |
matrix: | |
sys: | |
- { os: ubuntu-latest, container: 'ghcr.io/phusion/holy-build-box:4.0.1-amd64', shell: bash , c_compiler: gcc , binary_orig: digilivolo , binary_release: digilivolo-linux-hbb64 } | |
- { os: ubuntu-latest, container: 'debian:10' , shell: bash , c_compiler: gcc , binary_orig: digilivolo } | |
- { os: ubuntu-20.04 , shell: bash , c_compiler: gcc , binary_orig: digilivolo , binary_release: digilivolo-linux-x86_64 } | |
- { os: ubuntu-latest , shell: 'alpine.sh {0}', crosscompile: i386 , binary_orig: digilivolo , binary_release: digilivolo-linux-static-i386 } | |
- { os: ubuntu-latest, container: 'debian' , shell: bash , crosscompile: armhf, binary_orig: digilivolo , binary_release: digilivolo-linux-armhf } | |
- { os: ubuntu-latest, container: 'debian' , shell: bash , crosscompile: arm64, binary_orig: digilivolo , binary_release: digilivolo-linux-arm64 } | |
- { os: ubuntu-20.04 , shell: bash , c_compiler: clang , binary_orig: digilivolo } | |
- { os: windows-latest , shell: 'msys2 {0}' , c_compiler: gcc , binary_orig: digilivolo.exe, binary_release: digilivolo-win-x86_64.exe } | |
- { os: windows-latest , shell: pwsh , c_compiler: gcc , binary_orig: digilivolo.exe } | |
- { os: windows-latest , shell: pwsh , c_compiler: clang , binary_orig: digilivolo.exe } | |
build_type: [Release] | |
defaults: | |
run: | |
shell: ${{ matrix.sys.shell }} | |
steps: | |
- name: Install required prerequisite packages on the container and configure git | |
if: matrix.sys.container != '' | |
run: | | |
[ -x "`which apt 2>/dev/null`" ] && apt update || yum -y install https://packages.endpointdev.com/rhel/8/main/x86_64/endpoint-repo.noarch.rpm || echo "WARN: Endpoint repo add failed!" | |
[ -x "`which apt 2>/dev/null`" ] && apt -y full-upgrade || yum update -y | |
[ -x "`which apt 2>/dev/null`" ] && apt install -y sudo git dialog python3 python3-pip python3-setuptools curl wget || yum install -y sudo git dialog python3 python3-pip python3-setuptools make cmake3 libusb libudev-devel curl wget | |
git --version | |
git config --global --add safe.directory /__w/DigiLivolo/DigiLivolo | |
echo | |
cat /etc/os-release | |
- name: Install & configure Alpine Linux build environment for i386 build | |
uses: jirutka/setup-alpine@v1 | |
if: matrix.sys.crosscompile == 'i386' | |
with: | |
arch: x86 | |
packages: build-base cmake curl dialog eudev eudev-dev eudev-libs git libusb-dev linux-headers make ninja-build pkgconf pkgconf-dev py3-pip py3-setuptools python3 samurai sudo wget | |
- name: Install packages required for the workflow and build deps | |
uses: ConorMacBride/install-package@v1 | |
if: matrix.sys.container != 'ghcr.io/phusion/holy-build-box:4.0.1-amd64' | |
with: | |
apt: build-essential clang cmake file gcc libc6-dev libudev-dev make ninja-build pkg-config sudo | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Install Ninja | |
if: matrix.sys.shell == 'pwsh' || matrix.sys.container == 'ghcr.io/phusion/holy-build-box:4.0.1-amd64' | |
uses: turtlesec-no/get-ninja@main | |
- name: Setup MSYS2 UCRT64 | |
if: matrix.sys.shell == 'msys2 {0}' | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: UCRT64 | |
update: true | |
install: git make mingw-w64-ucrt-x86_64-gcc | |
pacboy: cmake:p ninja:p toolchain:p | |
- name: Install cross compiling toolchain and deps | |
if: matrix.sys.crosscompile != '' && matrix.sys.crosscompile != 'i386' | |
shell: bash | |
run: | | |
echo "Installing cross toolchain for ${{ matrix.sys.crosscompile }}" | |
sudo dpkg --add-architecture ${{ matrix.sys.crosscompile }} | |
sudo apt update | |
sudo apt install -y crossbuild-essential-${{ matrix.sys.crosscompile }} | |
sudo apt install -y libudev-dev:${{ matrix.sys.crosscompile }} libusb-dev:${{ matrix.sys.crosscompile }} libc6-dev:${{ matrix.sys.crosscompile }} pkg-config:${{ matrix.sys.crosscompile }} | |
- name: Configure CMake project | |
run: > | |
cmake -B software/build ${{ env.CMAKE_TOOLCHAIN_FILE_OPT }} ${{ env.CMAKE_C_COMPILER_OPT }} | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
-DUSE_SYSTEM_HIDAPI=false | |
-G Ninja | |
-S software | |
env: | |
CMAKE_TOOLCHAIN_FILE_OPT: ${{ matrix.sys.crosscompile == '' && ' ' || format('-DCMAKE_TOOLCHAIN_FILE=cmake/{0}-linux-toolchain.cmake', matrix.sys.crosscompile) }} | |
CMAKE_C_COMPILER_OPT: ${{ matrix.sys.c_compiler == '' && ' ' || format('-DCMAKE_C_COMPILER={0}', matrix.sys.c_compiler) }} | |
- name: Build software | |
run: cmake --build software/build | |
- name: Print some info on compiled binary | |
shell: bash | |
run: | | |
echo "=== objdump -x ===" | |
objdump -x software/build/${{ matrix.sys.binary_orig }} || /bin/true | |
echo "=== size -A ===" | |
size -A software/build/${{ matrix.sys.binary_orig }} || /bin/true | |
echo "=== ldd -v ===" | |
ldd -v software/build/${{ matrix.sys.binary_orig }} || /bin/true | |
echo "=== file & ls ===" | |
file software/build/${{ matrix.sys.binary_orig }} || /bin/true | |
ls -l software/build/${{ matrix.sys.binary_orig }} || /bin/true | |
- name: Rename binary to release target | |
if: ${{ matrix.sys.binary_release != '' }} | |
shell: bash | |
run: mv software/build/${{ matrix.sys.binary_orig }} software/build/${{ matrix.sys.binary_release }} | |
- name: Make and upload release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') && matrix.sys.binary_release != '' | |
with: | |
fail_on_unmatched_files: false | |
generate_release_notes: true | |
files: software/build/${{ matrix.sys.binary_release }} |