Kola Python Linux #9
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: Kola Python Linux | |
on: | |
workflow_dispatch: | |
inputs: | |
# Latest commit to include with the release. If omitted, use the latest commit on the main branch. | |
sha: | |
description: Commit SHA | |
type: string | |
# Create the sdist and build the wheels, but do not publish to PyPI / GitHub. | |
dry-run: | |
description: Dry run | |
type: boolean | |
default: false | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
PYTHON_VERSION: "3.11" | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
RUSTUP_MAX_RETRIES: 10 | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
# create-sdist: | |
# runs-on: ubuntu-20.04 | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# package: [kola] | |
# steps: | |
# - uses: actions/checkout@v4 | |
# with: | |
# ref: ${{ inputs.sha }} | |
# - name: Set up Python | |
# uses: actions/setup-python@v4 | |
# with: | |
# python-version: ${{ env.PYTHON_VERSION }} | |
# - name: Build wheels | |
# uses: PyO3/maturin-action@v1 | |
# with: | |
# command: sdist | |
# args: > | |
# --manifest-path py-kola/Cargo.toml | |
# --out dist | |
# - name: Test sdist | |
# run: | | |
# pip install --force-reinstall --verbose dist/*.tar.gz | |
# python -c 'import kola' | |
# - name: Upload sdist | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: sdist | |
# path: dist/*.tar.gz | |
build-wheels: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
# manylinux aarch64 openssl doesn't work | |
# architecture: [x86-64, aarch64] | |
architecture: [x86-64] | |
python-version: ["3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.sha }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Set RUSTFLAGS for x86-64 | |
if: matrix.architecture == 'x86-64' && matrix.os != 'macos-latest' | |
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+avx2,+fma,+bmi1,+bmi2,+lzcnt" >> $GITHUB_ENV | |
- name: Set RUSTFLAGS for x86-64 MacOS | |
if: matrix.architecture == 'x86-64' && matrix.os == 'macos-latest' | |
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" >> $GITHUB_ENV | |
- name: Set Rust target for aarch64 | |
if: matrix.architecture == 'aarch64' | |
id: target | |
run: | | |
TARGET=${{ matrix.os == 'macos-latest' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu'}} | |
echo "target=$TARGET" >> $GITHUB_OUTPUT | |
- name: Set jemalloc for aarch64 Linux | |
if: matrix.architecture == 'aarch64' && matrix.os == 'ubuntu-20.04' | |
run: | | |
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: build | |
target: ${{ steps.target.outputs.target }} | |
# before-script-linux: /opt/_internal/build_scripts/build-openssl.sh | |
args: > | |
--release -i ${{ matrix.python-version }} | |
--manifest-path py-kola/Cargo.toml | |
--out dist | |
container: off | |
# manylinux: "2_28" | |
- name: Upload wheel | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist/*.whl | |
pypi-publish: | |
name: Upload release to PyPI | |
# needs: [create-sdist, build-wheels] | |
needs: [build-wheels] | |
environment: | |
name: pypi | |
url: https://pypi.org/project/kola | |
runs-on: ubuntu-20.04 | |
permissions: | |
id-token: write | |
steps: | |
# - name: Download sdist | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: sdist | |
# path: dist | |
- name: Download wheels | |
uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
- name: Publish to PyPI | |
if: inputs.dry-run == false | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true |