Update publishing job #317
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: Builds | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
env: | |
NB_CPU: 1 | |
VERSION: '0.4.0' | |
BOCHS_REV: 3cf98b28541d337270c34b1068113fef294551a2 | |
jobs: | |
bochscpu: | |
strategy: | |
fail-fast: false | |
matrix: | |
variant: | |
- {os: windows-2019, arch: x64} | |
- {os: windows-2022, arch: x64} | |
- {os: ubuntu-22.04, arch: x64} | |
- {os: ubuntu-24.04, arch: x64} | |
- {os: ubuntu-24.04-arm, arch: arm64} | |
- {os: macos-13, arch: x64} | |
- {os: macos-14, arch: arm64} | |
- {os: macos-15, arch: arm64} | |
runs-on: ${{ matrix.variant.os }} | |
name: bochscpu / ${{ matrix.variant.os }} / ${{ matrix.variant.arch }} | |
steps : | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache Artifacts | |
id: cache-artifacts | |
uses: actions/cache@v4 | |
with: | |
path: artifact | |
key: bochscpu-libs-${{ matrix.variant.os }}-${{ matrix.variant.arch }}-${{ env.BOCHS_REV }} | |
- if: steps.cache-artifacts.outputs.cache-hit != 'true' && startsWith(matrix.variant.os, 'windows-') | |
run: echo NB_CPU=$env:NUMBER_OF_PROCESSORS | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- if: steps.cache-artifacts.outputs.cache-hit != 'true' && startsWith(matrix.variant.os, 'ubuntu-') | |
run: echo "NB_CPU=$(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV | |
- if: steps.cache-artifacts.outputs.cache-hit != 'true' && startsWith(matrix.variant.os, 'macos-') | |
run: echo NB_CPU=$(sysctl -n hw.ncpu) >> $GITHUB_ENV | |
- uses: microsoft/setup-msbuild@v2 | |
if: steps.cache-artifacts.outputs.cache-hit != 'true' && startsWith(matrix.variant.os, 'windows-') | |
- uses: ilammy/msvc-dev-cmd@v1 | |
if: steps.cache-artifacts.outputs.cache-hit != 'true' && startsWith(matrix.variant.os, 'windows-') | |
- name: Setup | |
run: | | |
rustup update | |
- name: Build BochsCPU (Windows) | |
if: steps.cache-artifacts.outputs.cache-hit != 'true' && startsWith(matrix.variant.os, 'windows-') | |
run: | | |
.\.github\build-bochscpu.ps1 | |
mkdir artifact; mkdir artifact/release; mkdir artifact/debug; mkdir artifact/relwithdebinfo | |
cp -Verbose bxbuild/bochscpu-ffi/target/release/*.lib artifact/release/ | |
cp -Verbose bxbuild/bochscpu-ffi/target/debug/*.lib artifact/debug/ | |
cp -Verbose bxbuild/bochscpu-ffi/target/debug/*.lib artifact/relwithdebinfo/ | |
- name: Build BochsCPU (Linux & MacOS) | |
if: steps.cache-artifacts.outputs.cache-hit != 'true' && startsWith(matrix.variant.os, 'windows-') == false | |
run: | | |
bash .github/build-bochscpu.sh | |
mkdir artifact artifact/Release artifact/Debug artifact/RelWithDebInfo | |
cp -v bxbuild/bochscpu-ffi/target/release/lib*.a artifact/Release/ | |
cp -v bxbuild/bochscpu-ffi/target/debug/lib*.a artifact/Debug/ | |
cp -v bxbuild/bochscpu-ffi/target/debug/lib*.a artifact/RelWithDebInfo/ | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: bochscpu-libs-${{ matrix.variant.os }}-${{ matrix.variant.arch }}-${{ env.BOCHS_REV }} | |
path: artifact | |
bindings: | |
needs: bochscpu | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
variant: | |
- {os: windows-2019, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: windows-2022, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-22.04, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-24.04, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-24.04-arm, arch: arm64, config: RelWithDebInfo, py-arch: arm64} | |
- {os: macos-13, arch: x64, config: Release, py-arch: x64} | |
- {os: macos-14, arch: arm64, config: Release, py-arch: arm64} | |
- {os: macos-15, arch: arm64, config: Release, py-arch: arm64} | |
runs-on: ${{ matrix.variant.os }} | |
name: bindings / ${{ matrix.variant.os }} / ${{ matrix.python-version }} / ${{ matrix.variant.config }} | |
env: | |
CMAKE_FLAGS: "" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download BochsCPU libs | |
uses: actions/download-artifact@v4 | |
id: download_artifact | |
with: | |
name: bochscpu-libs-${{ matrix.variant.os }}-${{ matrix.variant.arch }}-${{ env.BOCHS_REV }} | |
path: bochscpu-artifact | |
- name: Setup BochsCPU libs | |
run: | | |
mv ${{steps.download_artifact.outputs.download-path}}/* bochscpu/lib/ | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.variant.py-arch }} | |
- name: Install Python pre-requisites | |
run: | | |
python -m pip install --user --upgrade nanobind | |
- name: Environment Setup (Windows) | |
if: startsWith(matrix.variant.os, 'windows-') | |
run: | | |
echo NB_CPU=$env:NUMBER_OF_PROCESSORS | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
echo CMAKE_ARCH='-A ${{ matrix.variant.arch }}' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
Import-Module .\.github\Invoke-VisualStudio.ps1 | |
Invoke-VisualStudio2022${{ matrix.variant.arch }} | |
- name: Environment Setup (Linux) | |
if: startsWith(matrix.variant.os, 'ubuntu-') | |
run: | | |
echo "NB_CPU=$(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV | |
sudo apt-get -y update | |
sudo apt install -y g++ ninja-build | |
echo CC=gcc >> $GITHUB_ENV | |
echo CXX=g++ >> $GITHUB_ENV | |
- name: Environment Setup (MacOS) | |
if: startsWith(matrix.variant.os, 'macos-') | |
run: | | |
echo NB_CPU=$(sysctl -n hw.ncpu) >> $GITHUB_ENV | |
echo CC=gcc >> $GITHUB_ENV | |
echo CXX=g++ >> $GITHUB_ENV | |
- name: Build PYD and WHL | |
run: | | |
mkdir build | |
mkdir artifact | |
mkdir wheel | |
cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} | |
cmake --build ./build --verbose --config ${{ matrix.variant.config }} --parallel ${{ env.NB_CPU }} | |
cmake --install ./build --verbose --config ${{ matrix.variant.config }} --prefix ./artifact | |
- name: Install | |
run: | | |
python -m pip install .[tests] --user --upgrade | |
- name: Build wheelhouse (x64) | |
if: matrix.python-version == '3.13' && matrix.variant.arch == 'x64' && matrix.variant.os == 'ubuntu-24.04' | |
run: | | |
python -m pip install cibuildwheel==2.22.0 | |
python -m cibuildwheel --output-dir wheelhouse --archs x86_64 | |
- name: Build wheelhouse (arm64) | |
if: matrix.python-version == '3.13' && matrix.variant.arch == 'arm64' && matrix.variant.os == 'ubuntu-24.04-arm' | |
run: | | |
python -m pip install cibuildwheel==2.22.0 | |
python -m cibuildwheel --output-dir wheelhouse --archs aarch64 | |
- name: Build wheel (other) | |
if: matrix.variant.os != 'ubuntu-24.04' || matrix.variant.os != 'ubuntu-24.04-arm' | |
run: | | |
python -m pip wheel . -w ./wheel | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bochscpu-${{ env.VERSION }}-py${{ matrix.python-version }}-${{ matrix.variant.os }}.${{ matrix.variant.config }}-${{ matrix.variant.arch }} | |
path: | | |
artifact/ | |
wheel/ | |
wheelhouse/ | |
tests: | |
needs: bindings | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.13'] | |
variant: | |
- {os: windows-2022, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-24.04, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-24.04-arm, arch: arm64, config: RelWithDebInfo, py-arch: arm64} | |
- {os: macos-15, arch: arm64, config: Release, py-arch: arm64} | |
runs-on: ${{ matrix.variant.os }} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: bochscpu-${{ env.VERSION }}-py${{ matrix.python-version }}-${{ matrix.variant.os }}.${{ matrix.variant.config }}-${{ matrix.variant.arch }} | |
path: . | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.variant.py-arch }} | |
- name: Install | |
shell: bash | |
run: | | |
python -m pip install wheel/*.whl --user --upgrade | |
python -m pip install capstone keystone-engine --user --upgrade | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Tests | |
run: | | |
python -c "import bochscpu" | |
python examples/long_mode_fibonacci.py | |
python examples/real_mode_print_hello_world.py --debug | |
publish: | |
needs: tests | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
variant: | |
- {os: windows-2019, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: windows-2022, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-22.04, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-24.04, arch: x64, config: RelWithDebInfo, py-arch: x64} | |
- {os: ubuntu-24.04-arm, arch: arm64, config: RelWithDebInfo, py-arch: arm64} | |
- {os: macos-13, arch: x64, config: Release, py-arch: x64} | |
- {os: macos-14, arch: arm64, config: Release, py-arch: arm64} | |
- {os: macos-15, arch: arm64, config: Release, py-arch: arm64} | |
runs-on: ubuntu-24.04 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
name: PyPI upload of ${{ matrix.variant.os }}/${{ matrix.variant.arch }}/${{ matrix.variant.config }}/py${{ matrix.python-version }} | |
environment: | |
name: pypi | |
url: https://pypi.org/p/bochscpu-python | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifact for ${{ matrix.variant.os }}/${{ matrix.variant.arch }}/${{ matrix.python-version }}/${{ matrix.variant.config }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: bochscpu-${{ env.VERSION }}-py${{ matrix.python-version }}-${{ matrix.variant.os }}.${{ matrix.variant.config }}-${{ matrix.variant.arch }} | |
path: wheel | |
- name: Cleanup | |
run: | | |
rm wheel/wheel/nanobind-* | |
rm wheel/wheel/setuptools-* | |
rm wheel/wheel/wheel-* | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: wheel/wheel/ | |
print-hash: true |