Skip to content

Merge pull request #114 from itamarst/102-speed-up #224

Merge pull request #114 from itamarst/102-speed-up

Merge pull request #114 from itamarst/102-speed-up #224

Workflow file for this run

# Build sdist+wheel packages using GitHub Actions. Mostly adopted
# from https://cibuildwheel.readthedocs.io/en/stable/setup/
name: "Packages"
on:
push:
branches:
# Do build on pushes to master.
- "master"
tags:
# Do build on pushes to any release tag See
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
# for documentation about how patterns are matched.
- "zfec-*"
# Do build on pushes to any branch with an open pull request.
pull_request:
# Do build on different release events
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
release:
types: [published, created, edited]
jobs:
build_wheels:
name: "${{ matrix.wheel-selector }} wheel on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
# NOTE: when updating the matrix below, be sure to keep OS and
# Python versions in sync with the ones in test.yml.
matrix:
os:
- "macos-12"
- "ubuntu-22.04"
- "windows-2022"
wheel-selector:
- "cp39-*"
- "cp310-*"
- "cp311-*"
- "cp312-*"
- "cp313-*"
- "pp38-*"
- "pp39-*"
- "pp310-*"
steps:
- name: Check out zfec sources
uses: actions/checkout@v3
with:
# Check out the full history, including tags. This is necessary to
# construct non-release version numbers.
fetch-depth: 0
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: wheelhouse
env:
# Configure cibuildwheel to build just some of the total wheels we
# could build for this architecture. This yields better parallelism
# on GitHub Actions execution.
CIBW_BUILD: "${{ matrix.wheel-selector }}"
# Just make sure that Python can use zfec package.
CIBW_TEST_COMMAND: python -c "import zfec; print(zfec.__version__)"
# Build `universal2` and `arm64` wheels on an Intel runner.
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
# Skip testing arm64 builds on Intel Macs.
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
# Use newer manylinux so we get newer gcc and can take advantage of
# speed boost from x86-64-v2, at the cost of not supporting some old
# patch releases of Python 3.9 if they haven't updated pip in their
# virtualenv.
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
- uses: actions/upload-artifact@v3
name: Upload artifacts
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Check out zfec sources
with:
# Check out the full history, including tags. This is necessary to
# construct non-release version numbers.
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.11'
- name: Build sdist
run: |
python3 setup.py sdist
- uses: actions/upload-artifact@v3
name: Upload artifacts
with:
path: dist/*.tar.gz
upload_pypi:
needs:
- "build_wheels"
- "build_sdist"
# It only needs to run once. It will fetch all of the other build
# artifacts created by the other jobs and then upload them.
runs-on: "ubuntu-latest"
# Select the GitHub Actions environment that contains the PyPI tokens
# necessary to perform uploads. This was configured manually using the
# GitHub web interface.
environment: "release"
steps:
# Download all artifacts previously built by this workflow to the dist
# directory where the publish step can find them. These are the sdist
# and all of the wheels build by the other jobs.
- uses: "actions/download-artifact@v3"
with:
name: "artifact"
path: "dist"
# Define a conditional step to upload packages to the testing instance
# of PyPI.
#
# The overall workflow is already restricted so that it runs for:
# 1) pushes to master
# 2) pushes to release tags
# 3) pushes to branches with associated PRs
#
# The conditional in this step should cause it to run only for case (3).
- name: "Publish to TEST PyPI"
uses: "pypa/[email protected]"
if: >-
github.event_name == 'pull_request'
with:
# Authenticate using a token from a PyPI account with upload
# permission to the project. See https://pypi.org/help/#apitoken
user: "__token__"
# Read it from a GitHub Actions "environment" secret. See
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
password: "${{ secrets.testpypi_token }}"
# Override the default in order to upload it to the testing
# deployment.
repository_url: "https://test.pypi.org/legacy/"
# Now define a conditional step to upload packages to the production
# instance of PyPI.
#
# The cases to consider are the same as for the upload to the testing
# instance. This time, we have a conditional that runs only for case
# (2).
- name: "Publish to LIVE PyPI"
uses: "pypa/[email protected]"
if: >-
github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags/zfec-')
with:
user: "__token__"
password: "${{ secrets.pypi_token }}"