Skip to content

Build and publish wheels #394

Build and publish wheels

Build and publish wheels #394

Workflow file for this run

name: Build and publish wheels
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 0 * * 0,3' # run twice a week
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-22.04, macos-13]
platform: [x64]
env:
REPO_DIR: httpstan
# BUILD_COMMIT is set in a step below to the most recent tagged version
BUILD_DEPENDS: ""
MB_PYTHON_VERSION: ${{ matrix.python-version }}
# test dependencies from the [tool.poetry.dev-dependencies] section in pyproject.toml
TEST_DEPENDS: "pytest~=5.4 pytest-cov~=2.8 pytest-asyncio<0.11,>=0.10 apispec[yaml,validation]~=3.1"
MB_ML_VER: "2014"
DOCKER_TEST_IMAGE: "multibuild/focal_x86_64"
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
TRAVIS_REPO_SLUG: ${{ github.repository }}
TRAVIS_BRANCH: ${{ github.head_ref }}
TRAVIS_PULL_REQUEST: ${{ github.event.number }}
TRAVIS_BUILD_DIR: ${{ github.workspace }}
steps:
- uses: actions/checkout@v4
with:
# fetch-depth: 0 fetches all commits (and tags). Needed for httpstan subrepo.
# submodule fetching inherits this parameter. See https://github.com/actions/checkout/issues/367
fetch-depth: 0
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install virtualenv
run: |
python -m pip install --upgrade pip
pip install virtualenv
- name: Set multibuild environment variables
run: |
if [ "macos-11" == "${{ matrix.os }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
if [ "macos-11" == "${{ matrix.os }}" ]; then echo "ARCHFLAGS=-arch x86_64" >> $GITHUB_ENV; fi
if [ "macos-11" == "${{ matrix.os }}" ]; then echo "MB_PYTHON_OSX_VER=10.9" >> $GITHUB_ENV; fi
- name: Use most recent tag as BUILD_COMMIT
run: echo "BUILD_COMMIT=$(cd httpstan && git tag --sort version:refname | tail -1)" >> $GITHUB_ENV
- name: Print environment variables
run: |
echo "TRAVIS_BRANCH: ${TRAVIS_BRANCH}"
echo "TRAVIS_PULL_REQUEST: ${TRAVIS_PULL_REQUEST}"
echo "TRAVIS_REPO_SLUG: ${TRAVIS_REPO_SLUG}"
echo "TRAVIS_EVENT_TYPE: ${TRAVIS_EVENT_TYPE}"
echo "TRAVIS_OS_NAME: ${TRAVIS_OS_NAME}"
echo "PLAT: ${PLAT}"
echo "ARCHFLAGS: ${ARCHFLAGS}"
echo "MB_PYTHON_OSX_VER: ${MB_PYTHON_OSX_VER}"
echo "DOCKER_TEST_IMAGE: ${DOCKER_TEST_IMAGE}"
echo "BUILD_DEPENDS: ${BUILD_DEPENDS}"
echo "TEST_DEPENDS: ${TEST_DEPENDS}"
echo "BUILD_COMMIT: ${BUILD_COMMIT}"
- name: Build wheel
run: |
source multibuild/common_utils.sh
source multibuild/travis_steps.sh
echo "------- BEFORE INSTALL --------"
before_install
echo "------- CLEAN CODE --------"
clean_code $REPO_DIR $BUILD_COMMIT
echo "------- BUILD WHEEL --------"
build_wheel $REPO_DIR $PLAT
- name: Upload wheels
if: always()
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
if [[ $GITHUB_EVENT_NAME != "pull_request" ]]; then
python3 -m pip install twine
python3 -m twine upload --skip-existing -u __token__ -p "$PYPI_TOKEN" ${TRAVIS_BUILD_DIR}/wheelhouse/*.whl
else
echo "This build is connected to a pull request. Not uploading to PyPI."
fi