Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with release.yaml due to breaking changes in actions/upload-artifact and actions/download-artifact #173

Open
wants to merge 11 commits into
base: fastsim-2
Choose a base branch
from
86 changes: 52 additions & 34 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,46 @@ on:
types: [published]
workflow_dispatch:

# NOTE: parts inspired by https://cibuildwheel.pypa.io/en/stable/setup/

jobs:
build:
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu
- macos
- windows
- ubuntu-latest
- macos-13 # Intel runner
- macos-latest # Apple Silicon runner
- windows-latest
python-version:
- "8"
- "9"
- "10"
include:
- os: ubuntu
- os: ubuntu-latest
platform: linux
- os: windows
- os: windows-latest
ls: dir

env:
FASTSIM_DISABLE_NETWORK_TESTS: 1

runs-on: ${{ format('{0}-latest', matrix.os) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: set up rust
if: matrix.os != 'ubuntu'
if: matrix.os != 'ubuntu-latest'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- run: rustup target add aarch64-apple-darwin
if: matrix.os == 'macos'
if: matrix.os == 'macos-latest'

- name: run cargo tests
uses: actions-rs/toolchain@v1
Expand All @@ -54,27 +57,35 @@ jobs:
- name: set up python
uses: actions/setup-python@v4
with:
# NOTE: future versions of cibuildwheel need python 3.11+
python-version: "3.10"

- name: Upgrade to latest pip
run: python -m pip install --upgrade pip

- name: install Python dependencies
run: pip install -U setuptools wheel twine cibuildwheel pytest

- name: build source distribution
if: matrix.os == 'ubuntu' && matrix.python-version == '10'
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '10'
run: |
pip install -U setuptools-rust
python -c "import setuptools; setuptools.setup()" sdist

- name: Update minimum supported MacOS for Wheels for MacOS 13 (Intel Mac)
run: echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV
if: matrix.os == 'macos-13'

- name: build ${{ matrix.platform || matrix.os }} binaries
run: cibuildwheel --output-dir dist
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_BUILD: "cp3${{ matrix.python-version }}-*"
CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64"
CIBW_PLATFORM: ${{ matrix.platform || matrix.os }}
# CIBW_PLATFORM: ${{ matrix.platform || matrix.os }}
# TODO: why doesn't pytest work with cibuildwheel?
# CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests"
CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests"
CIBW_ARCHS_MACOS: "universal2"
# CIBW_ARCHS_MACOS: "universal2"
# see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2
CIBW_TEST_SKIP: "*_universal2:arm64"
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
Expand All @@ -92,41 +103,48 @@ jobs:
rustup show
CIBW_BEFORE_BUILD_MACOS: >
rustup target add x86_64-apple-darwin
# - name: build windows 32bit binaries
# if: matrix.os == 'windows'
# run: cibuildwheel --output-dir dist
# env:
# CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32'
# CIBW_PLATFORM: windows
# CIBW_TEST_REQUIRES: 'pytest'
# CIBW_TEST_COMMAND: 'pytest {project}/tests -s'
# CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"'
# CIBW_BEFORE_BUILD: >
# pip install -U setuptools-rust &&
# rustup toolchain install nightly-i686-pc-windows-msvc &&
# rustup default nightly-i686-pc-windows-msvc &&
# rustup override set nightly-i686-pc-windows-msvc &&
# rustup show

- name: list dist files
run: ${{ matrix.ls || 'ls -lh' }} dist/
# - name: build windows 32bit binaries
# if: matrix.os == 'windows'
# run: cibuildwheel --output-dir dist
# env:
# CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32'
# CIBW_PLATFORM: windows
# CIBW_TEST_REQUIRES: 'pytest'
# CIBW_TEST_COMMAND: 'pytest {project}/tests -s'
# CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"'
# CIBW_BEFORE_BUILD: >
# pip install -U setuptools-rust &&
# rustup toolchain install nightly-i686-pc-windows-msvc &&
# rustup default nightly-i686-pc-windows-msvc &&
# rustup override set nightly-i686-pc-windows-msvc &&
# rustup show

- name: list wheelhouse files
run: ${{ matrix.ls || 'ls -lh' }} ./wheelhouse/

- uses: actions/upload-artifact@v4
with:
path: ./dist/*
name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

release:
needs: build
name: release files to PyPI
runs-on: ubuntu-latest
# Protection Strategies -- use ONE of the following two lines:
if: github.event_name == 'release' && github.event.action == 'published' # publish on via explicit publish
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # publish on tag starting w/ 'v'
steps:
- name: download files
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: artifact

- name: set up Python 3.10
- name: set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- run: pip install twine

Expand Down
Loading