Merge branch 'main' into build-py #76
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: Release | |
on: | |
push: | |
create: | |
tags: | |
- 'v*' | |
jobs: | |
# Build CLI tool. | |
build-cli: | |
env: | |
CARGO_TERM_COLOR: always | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- linux | |
- macos | |
- windows | |
include: | |
- build: linux | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
vcpkg_openssl_triplet: x64-linux-release | |
- build: macos | |
os: macos-latest | |
target: x86_64-apple-darwin | |
vcpkg_openssl_triplet: x64-osx-release | |
- build: windows | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
vcpkg_openssl_triplet: x64-windows-static | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Check version number | |
shell: bash | |
run: | | |
set -ex | |
version=`cargo pkgid --manifest-path lib/Cargo.toml | cut -d "@" -f2` | |
if [ "${{ github.ref_name }}" != "v$version" ]; then | |
exit 1 | |
fi | |
- name: Install dependencies | |
id: vcpkg | |
uses: johnwason/vcpkg-action@v6 | |
with: | |
pkgs: openssl | |
triplet: ${{ matrix.vcpkg_openssl_triplet }} | |
token: ${{ github.token }} | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Build | |
run: cargo build --bin yr --profile release-lto --target ${{ matrix.target }} | |
env: | |
RUSTFLAGS: "-C target-feature=+crt-static" | |
OPENSSL_DIR: "${{ github.workspace }}/vcpkg/installed/${{ matrix.vcpkg_openssl_triplet }}" | |
- name: Build archive | |
shell: bash | |
run: | | |
set -ex | |
pkgname=yara-x-${{ github.ref_name }}-${{ matrix.target }} | |
if [ "${{ matrix.build }}" = "windows" ]; then | |
7z a $pkgname.zip ./target/${{ matrix.target }}/release-lto/yr.exe | |
else | |
tar czf $pkgname.gzip -C target/${{ matrix.target }}/release-lto yr | |
fi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: yr-${{ matrix.target }} | |
path: yara-x-* | |
# Build Python extension. | |
build-py: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- cp310 | |
- pp38 | |
- pp39 | |
build: | |
- linux | |
#- macos | |
- windows | |
include: | |
- build: linux | |
os: ubuntu-latest | |
#- build: macos | |
# os: macos-latest | |
# arch: alt | |
# alt_arch_name: 'arm64 universal2' | |
- build: windows | |
os: windows-latest | |
arch: 'x86 AMD64' | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- run: rustup target add aarch64-apple-darwin | |
if: matrix.build == 'macos' | |
#- run: rustup toolchain install stable-i686-pc-windows-msvc | |
# if: matrix.build == 'windows' | |
#- run: rustup target add i686-pc-windows-msvc | |
# if: matrix.build == 'windows' | |
- name: Install Python dependencies | |
run: pip install -U setuptools wheel twine cibuildwheel platformdirs | |
- name: Build sdist | |
if: matrix.build == 'linux' && matrix.python-version == 'cp310' | |
run: | | |
pip install maturin build | |
python -m build --sdist -o wheelhouse py | |
- name: Setup tmate session | |
if: matrix.build == 'windows' | |
uses: mxschmitt/action-tmate@v3 | |
- name: Build ${{ matrix.platform || matrix.os }} binaries | |
run: cibuildwheel --output-dir wheelhouse py | |
env: | |
CIBW_BUILD: '${{ matrix.python-version }}-*' | |
# wasmtime doesn't support i686 | |
CIBW_SKIP: '*_i686 *-musllinux* *-win32' | |
# we build for "arch" if it exists, else 'auto' | |
CIBW_ARCHS: ${{ matrix.arch || 'auto' }} | |
CIBW_BEFORE_BUILD_LINUX: > | |
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y && | |
rustup show && | |
yum install -y openssl-static | |
CIBW_BEFORE_BUILD_WINDOWS: vcpkg install openssl:x86-windows-static | |
CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH" OPENSSL_LIB_DIR="/usr/lib64" OPENSSL_INCLUDE_DIR="/usr/include/openssl"' | |
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH" OPENSSL_DIR="$VCPKG_INSTALLATION_ROOT\\packages\\openssl_x86-windows-static"' | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: 'pytest {project}/py' | |
CIBW_TEST_SKIP: '*-macosx_arm64 *-macosx_universal2:arm64' | |
CIBW_BUILD_VERBOSITY: 1 | |
publish: | |
needs: [ build-cli, build-py ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: yr-* | |
- name: ls | |
shell: bash | |
run: ls | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
files: yr-*/yara-x-* |