diff --git a/.github/actions/libvmi-setup/action.yml b/.github/actions/libvmi-setup/action.yml index 62e2f11..752461b 100644 --- a/.github/actions/libvmi-setup/action.yml +++ b/.github/actions/libvmi-setup/action.yml @@ -1,32 +1,52 @@ -name: 'Libvmi setup' -description: 'This actions installs LibVMI on the system' -author: 'Mathieu Tarral' +name: "Libvmi setup" +description: "This actions installs LibVMI on the system" +author: "Mathieu Tarral" runs: - using: 'composite' - steps: - - name: Ensure sudo is available (manylinux container compat) - shell: bash - run: | - if [ "$EUID" -eq 0 ]; then - apt-get update && apt-get install -y sudo - fi + using: "composite" + steps: + - name: Detect OS and Set Environment Variable + id: detect-os + shell: bash + run: | + . /etc/os-release + if [ "$ID" = "ubuntu" ]; then + echo "OS_TYPE=Ubuntu" >> $GITHUB_ENV + elif [ "$ID" = "centos" ]; then + echo "OS_TYPE=CentOS" >> $GITHUB_ENV + else + echo "Unsupported OS: $ID" + exit 1 + fi - - name: install dependencies - shell: bash - run: sudo apt-get update && sudo apt-get install -qq cmake flex bison libglib2.0-dev libvirt-dev libjson-c-dev libyajl-dev + - name: install dependencies + shell: bash + run: | + if [ "${{ env.OS_TYPE }}" = "Ubuntu" ]; then + sudo apt-get update && sudo apt-get install -qq cmake flex bison libglib2.0-dev libvirt-dev libjson-c-dev libyajl-dev + elif [ "${{ env.OS_TYPE }}" = "CentOS" ]; then + yum update && yum install -y cmake flex bison glib2-devel libvirt-devel json-c-devel yajl-devel libxen-devel + else + echo "Unknown OS" + fi - - name: clone libvmi - uses: actions/checkout@v2 - with: - repository: libvmi/libvmi - path: libvmi - # pinned to a specific commit to avoid breakage - ref: '45b32c0f0003b4037700a1b534879b7d8bee5de0' + - name: clone libvmi + uses: actions/checkout@v2 + with: + repository: libvmi/libvmi + path: libvmi + # pinned to a specific commit to avoid breakage + ref: "45b32c0f0003b4037700a1b534879b7d8bee5de0" - - name: install libvmi - shell: bash - run: | - cmake -B build -DCMAKE_INSTALL_PREFIX=/usr . - cmake --build build + - name: install libvmi + shell: bash + run: | + cmake -B build -DCMAKE_INSTALL_PREFIX=/usr . + cmake --build build + if [ "${{ env.OS_TYPE }}" = "Ubuntu" ]; then sudo cmake --build build --target install - working-directory: libvmi + elif [ "${{ env.OS_TYPE }}" = "CentOS" ]; then + cmake --build build --target install + else + echo "Unknown OS" + fi + working-directory: libvmi