-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework the release CI to be less fragile
Use official "actions" for building and publishing packages. Do the uploading in a separate job. Run tests on each binary wheel built.
- Loading branch information
Showing
1 changed file
with
63 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,86 @@ | ||
--- | ||
name: Python Release | ||
name: Release to PyPI | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
release: | ||
name: PyPI Release | ||
build_sdist: | ||
name: Build source package | ||
runs-on: ubuntu-latest | ||
container: fedora:latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
- name: Install / upgrade dependencies | ||
run: | | ||
sudo dnf -y install dnf-plugins-core | ||
sudo dnf -y install dnf-plugins-core python3-pip | ||
sudo dnf -y builddep libcomps.spec | ||
pip install --upgrade pip | ||
pip install pytest twine scikit-build | ||
- name: Build Python sdist | ||
run: python3 setup.py sdist | ||
|
||
- name: Build manylinux Python wheels | ||
uses: RalfG/[email protected]_x86_64 | ||
with: | ||
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39' | ||
build-requirements: 'scikit-build' | ||
system-packages: 'make cmake bzip2-devel expat-devel libxml2-devel xz-devel' | ||
python3 -m pip install --upgrade pip scikit-build | ||
- name: Install and Test Python source package | ||
- name: Build and install Python source package | ||
run: | | ||
pip install --user dist/*.tar.gz | ||
pushd libcomps/src/python/tests/ | ||
pytest --verbose --color=yes ./ | ||
popd | ||
python3 setup.py sdist | ||
python3 -m pip install dist/*.tar.gz | ||
- name: Install and Test Python universal binary wheel package | ||
- name: Run tests | ||
run: | | ||
pip install --user dist/libcomps-*-cp39-cp39-manylinux2014_x86_64.whl | ||
python3 -m pip install pytest | ||
pushd libcomps/src/python/tests/ | ||
pytest --verbose --color=yes ./ | ||
popd | ||
- name: Publish packages to PyPI | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
path: dist/*.tar.gz | ||
|
||
|
||
build_bdist: | ||
name: Build binary wheels | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# setup Python for cibuildwheel | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
# for other architectures, see: https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation | ||
- name: Build wheels for CPython | ||
uses: pypa/[email protected] | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{secrets.PYPI_API_TOKEN}} | ||
run: | | ||
twine upload dist/*.tar.gz | ||
twine upload wheelhouse/*-manylinux*.whl | ||
CIBW_ARCHS: auto64 # only 64-bit | ||
CIBW_SKIP: "pp*" # no PyPy builds | ||
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 # centos 7 | ||
CIBW_BEFORE_ALL: yum install -y make cmake bzip2-devel expat-devel libxml2-devel xz-devel | ||
CIBW_BEFORE_BUILD: python -m pip install scikit-build | ||
CIBW_TEST_REQUIRES: pytest | ||
CIBW_TEST_COMMAND: | | ||
pushd {project}/libcomps/src/python/tests/ | ||
pytest --verbose --color=yes ./ | ||
popd | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
path: ./wheelhouse/*.whl | ||
|
||
|
||
upload_pypi: | ||
name: Publish packages to PyPI | ||
# only publish packages once everything is successful | ||
needs: [build_bdist, build_sdist] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: artifact | ||
path: dist | ||
|
||
- uses: pypa/[email protected] | ||
with: | ||
user: __token__ | ||
password: ${{secrets.PYPI_API_TOKEN}} | ||
# To test: repository_url: https://test.pypi.org/legacy/ |