Skip to content

chore: Release

chore: Release #536

Workflow file for this run

name: CI
on:
push:
branches:
- master
tags:
- '*'
pull_request:
jobs:
format:
runs-on: ubuntu-20.04
steps:
- name: install stable toolchain with rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
- uses: actions/checkout@v1
- name: rustfmt check
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
xen:
runs-on: ubuntu-20.04
steps:
- name: install Xen headers and libraries
run: sudo apt-get install -y libxen-dev
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build Xen driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features xen
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy xen
token: ${{ secrets.GITHUB_TOKEN }}
args: --features xen -- -D warnings
kvm:
runs-on: ubuntu-20.04
steps:
- name: clone libkvmi
uses: actions/checkout@v2
with:
repository: bitdefender/libkvmi
path: libkvmi
ref: bf5776319e1801b59125c994c459446f0ed6837e
- name: build and install libkvmi
run: |
./bootstrap
./configure
make
sudo make install
working-directory: libkvmi
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build KVM driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features kvm
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy kvm
token: ${{ secrets.GITHUB_TOKEN }}
args: --features kvm -- -D warnings
- name: remove compilation artifacts from stable toolchain
uses: actions-rs/cargo@v1
with:
command: clean
- name: install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: test KVM driver
uses: actions-rs/cargo@v1
with:
command: test
# The target arg is a workaround in order to prevent build.rs files from being compiled with RUSTFLAGS
# -Cpanic=abort can lead to issues with bindgen during compile time
# --lib only unit tests in the library, avoid integration tests
args: --lib --features kvm --no-fail-fast --target x86_64-unknown-linux-gnu
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
- name: install grcov
uses: actions-rs/[email protected]
with:
crate: grcov
version: latest
use-tool-cache: true
- name: generate coverage report
id: coverage
uses: actions-rs/[email protected]
- name: upload coverage report to codecov.io
uses: codecov/codecov-action@v1
with:
file: ${{ steps.coverage.outputs.report }}
flags: unittests
fail_ci_if_error: true
memflow:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04, windows-2022 ]
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build Memflow driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features mflow
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy memflow
token: ${{ secrets.GITHUB_TOKEN }}
args: --features mflow -- -D warnings
virtualbox_linux:
runs-on: ubuntu-20.04
steps:
- name: clone Icebox repository
run: git clone https://github.com/thalium/icebox --depth 1
- name: Compile and install FDP library
run: |
cd icebox/src/FDP
g++ -std=c++11 -shared -fPIC FDP.cpp -o libFDP.so -lrt
sudo cp include/* /usr/local/include
sudo cp libFDP.so /usr/local/lib
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build VirtualBox driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features virtualbox
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy virtualbox
token: ${{ secrets.GITHUB_TOKEN }}
args: --features virtualbox -- -D warnings
virtualbox_windows:
runs-on: windows-2022
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- name: Clone Icebox repository
uses: actions/checkout@v2
with:
repository: thalium/icebox
path: icebox
- uses: actions/checkout@v2
with:
path: libmicrovmi
# adds cl.exe in the PATH
- name: Setup command prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1
- name: Compile and install FDP library
run: |
# install in C:\FDP to avoid issues with quotes etc
cl /c FDP.cpp /out:FDP.obj
cl /LD FDP.obj /link /out:FDP.dll
lib /NOLOGO FDP.obj /OUT:FDP.lib
dir
New-Item -Path "C:\FDP" -ItemType "directory"
copy FDP.dll "C:\FDP"
copy FDP.lib "C:\FDP"
copy "include\*" "C:\FDP"
working-directory: icebox/src/FDP
- name: Install Clang
run: choco install llvm
- name: build VirtualBox driver
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path libmicrovmi/Cargo.toml --features virtualbox
env:
BINDGEN_EXTRA_CLANG_ARGS: -I"C:\FDP" -L"C:\FDP"
CARGO_BUILD_RUSTFLAGS: -L C:\FDP
c_api:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2022]
steps:
- name: install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: actions/checkout@v1
- name: build libmicrovmi
uses: actions-rs/cargo@v1
with:
command: build
- name: build C API
run: |
cd c_examples
cmake -B build
cmake --build build
examples:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2022]
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build examples with clippy
uses: actions-rs/clippy-check@v1
with:
name: clippy examples
token: ${{ secrets.GITHUB_TOKEN }}
args: --examples -- -D warnings
release_python:
# build a libmicrovmi python bindings release
# and upload it as artifact
runs-on: ubuntu-20.04
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- name: Set up Python 3.8 🐍
uses: actions/setup-python@v1
with:
python-version: '3.8'
- uses: actions/checkout@v1
- name: install nox and check formatting, linting, type checking and testing
run: |
pip install nox
nox -r
working-directory: python
- name: build Python extension
uses: actions-rs/cargo@v1
with:
command: build
args: -p pymicrovmi
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy python
token: ${{ secrets.GITHUB_TOKEN }}
args: -p pymicrovmi -- -D warnings
- name: install Python package
run: |
python -m pip install -r requirements.txt
./setup.py install
working-directory: python
- name: smoke test
run: python3 -c 'from microvmi import Microvmi, DriverType, CommonInitParamsPy, DriverInitParamsPy, KVMInitParamsPy'
- name: Build Wheels with manylinux
run: nox -r -s generate_wheels -- --features xen,kvm,virtualbox,mflow --release
working-directory: python
# upload all generated wheels *.whl
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: python_wheels
path: python/dist/manylinux/*
release_debian_package:
# create a debian package with libmicrovmi release
# and upload it as artifact
needs: [format, xen, kvm, virtualbox_linux, memflow]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: install Xen headers
run: sudo apt-get install -y libxen-dev
- name: clone Icebox
uses: actions/checkout@v2
with:
repository: thalium/icebox
path: icebox
- name: install VirtualBox's FDP headers
run: |
g++ -std=c++11 -shared -fPIC FDP.cpp -o libFDP.so -lrt
sudo cp include/* /usr/local/include
sudo cp libFDP.so /usr/local/lib
working-directory: icebox/src/FDP
- name: clone libkvmi
uses: actions/checkout@v2
with:
repository: bitdefender/libkvmi
path: libkvmi
ref: bf5776319e1801b59125c994c459446f0ed6837e
- name: build and install libkvmi
run: |
./bootstrap
./configure
make
sudo make install
working-directory: libkvmi
- name: install cargo deb dependencies
run: sudo apt-get install -y dpkg liblzma-dev
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo
- name: install cargo deb
run: cargo install cargo-deb
- name: build debian package
# must keep --no-strip because cargo metadata doesn't expose
# workspace profiles
# also --release is already added by cargo deb
run: cargo deb --no-strip -- --features xen,kvm,virtualbox,mflow
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: microvmi_deb
# microvmi_x.x.x_amd64.deb
path: target/debian/*
release_windows:
# build libmicrovmi release with all windows drivers
# and upload it as an artefact
needs: [virtualbox_windows, memflow]
runs-on: windows-2022
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- name: Clone Icebox repository
uses: actions/checkout@v2
with:
repository: thalium/icebox
path: icebox
- uses: actions/checkout@v2
with:
path: libmicrovmi
# adds cl.exe in the PATH
- name: Setup command prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1
- name: Compile and install FDP library
run: |
# install in C:\FDP to avoid issues with quotes etc
cl /c FDP.cpp /out:FDP.obj
cl /LD FDP.obj /link /out:FDP.dll
lib /NOLOGO FDP.obj /OUT:FDP.lib
dir
New-Item -Path "C:\FDP" -ItemType "directory"
copy FDP.dll "C:\FDP"
copy FDP.lib "C:\FDP"
copy "include\*" "C:\FDP"
working-directory: icebox/src/FDP
- name: Install Clang
run: choco install llvm
- name: build libmicrovmi with virtualbox and memflow driver
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path libmicrovmi/Cargo.toml --features virtualbox,mflow --release
env:
BINDGEN_EXTRA_CLANG_ARGS: -I"C:\FDP" -L"C:\FDP"
CARGO_BUILD_RUSTFLAGS: -L C:\FDP
- name: create output directory and copy artifact content
run: |
mkdir output
copy ./target/release/microvmi.dll output
copy ./target/release/capi/libmicrovmi.h output
working-directory: libmicrovmi
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: microvmi_win32
path: libmicrovmi/output/*
github_release:
# create a Github release
# only when
# - push on master
# - tag starts with 'v*'
needs: [c_api, examples, release_python, release_debian_package, release_windows]
runs-on: ubuntu-20.04
# output these value to be used by other jobs so they can add assets
outputs:
upload_url: ${{ steps.step_upload_url.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v1
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo
- name: Create a Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ steps.get_version.outputs.version }}
- id: step_upload_url
run: echo "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}"
publish_debian_package:
# publish the debian package in the Github Release
needs: github_release
runs-on: ubuntu-20.04
steps:
# the deploy action below depends on a checkout of the repo
# otherwise it fails trying to remote the 'origin' remote
# https://github.com/JamesIves/github-pages-deploy-action/issues/335
- uses: actions/checkout@v2
# download artifacts
- uses: actions/download-artifact@v2
id: download
with:
name: microvmi_deb
- name: get artifact path and name
id: artefact
run: |
PATHNAME=$(find . -maxdepth 1 -name '*.deb')
NAME=$(basename $PATHNAME)
echo ::set-output name=path::${PATHNAME}
echo ::set-output name=name::${NAME}
- name: Upload Debian package as Release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.github_release.outputs.upload_url }}
asset_path: ${{ steps.artefact.outputs.path }}
asset_name: ${{ steps.artefact.outputs.name }}
asset_content_type: application/vnd.debian.binary-package
publish_windows:
# publish the windows release on Github Release
runs-on: ubuntu-20.04
needs: github_release
steps:
- uses: actions/checkout@v1
# download artifacts
- uses: actions/download-artifact@v2
id: download
with:
# download to tmp_dir
name: microvmi_win32
path: tmp_dir
# create zip archive of tmp_dir content without including the folder itself
- name: create zip archive
run: zip -r ../microvmi_win32.zip *
working-directory: tmp_dir
- name: Upload Zip folder as Release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.github_release.outputs.upload_url }}
asset_path: ./microvmi_win32.zip
asset_name: microvmi_win32.zip
asset_content_type: application/zip
publish_book:
# build and publish the book on Github pages
needs: github_release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-mdbook
- name: install mdbook
run: cargo install mdbook
- name: build book
run: mdbook build doc
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
# note: FOLDER doesn't care about the job's working directory
folder: doc/book
single_commit: true
publish_crates_io:
needs: github_release
runs-on: ubuntu-20.04
# publish on crates.io
# this should be triggered by cargo release, which creates a new tag and pushes to the repo
# cargo release --no-dev-version --skip-publish minor
steps:
- name: Install Xen headers and libraries
run: sudo apt-get install -y libxen-dev
- uses: actions/checkout@v1
- name: Publish
shell: bash
run: |
cargo publish --features xen --token ${{ secrets.CRATES_TOKEN }}
publish_pypi:
needs: github_release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
# download all wheels into a new manylinux directory
- uses: actions/download-artifact@v2
id: download
with:
name: python_wheels
path: manylinux
- name: Publish on PyPI 🚀
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_ACCESS_TOKEN }}
packages_dir: manylinux