Skip to content

Publish Python distribution to PyPI #8

Publish Python distribution to PyPI

Publish Python distribution to PyPI #8

Workflow file for this run

name: Publish Python distribution to PyPI
on:
push:
branches:
- master
tags:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
arch: x86_64
- os: ubuntu-22.04
arch: i686
- os: ubuntu-22.04
arch: aarch64
- os: macos-12
arch: x86_64 universal2
- os: windows-2022
arch: x86
before: vcpkg install openssl:x86-windows-static
env: LIB="C:\\vcpkg\\packages\\openssl_x86-windows-static\\lib" INCLUDE="C:\\vcpkg\\packages\\openssl_x86-windows-static\\include"
- os: windows-2022
arch: AMD64
before: vcpkg install openssl:x64-windows-static
env: LIB="C:\\vcpkg\\packages\\openssl_x64-windows-static\\lib" INCLUDE="C:\\vcpkg\\packages\\openssl_x64-windows-static\\include"
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: dist
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BEFORE_ALL_LINUX: |
if [[ ! -z "$(which yum)" ]]; then
yum install -y make gcc perl-core pcre-devel wget zlib-devel git automake
wget https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz
tar xf openssl*.gz
cd openssl*
./config --prefix=/usr --openssldir=/etc/ssl zlib-dynamic
make -j$(nproc)
make install
elif [[ ! -z "$(which apk)" ]]; then
apk add openssl-dev
fi
CIBW_BEFORE_ALL_WINDOWS: ${{ matrix.before }}
CIBW_BUILD_FRONTEND: build
CIBW_CONFIG_SETTINGS: --enable-cuckoo --enable-magic --enable-dex --enable-macho --enable-openssl
CIBW_ENVIRONMENT: ${{ matrix.env }}
CIBW_SKIP: cp36-*
CIBW_TEST_COMMAND: python {package}/tests.py
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.os }}-${{ matrix.arch }}
path: dist/*.whl
publish-to-pypi:
needs: [build]
runs-on: ubuntu-latest
# Only publish to PyPI on tag pushes
if: startsWith(github.ref, 'refs/tags/')
environment:
name: pypi
url: https://pypi.org/p/yara-python
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
merge-multiple: true
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1