Use upload-download artifacts #26
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: PyPI Release | |
on: | |
release: | |
types: | |
- published | |
push: | |
branches: | |
- master | |
jobs: | |
# from: | |
# https://github.com/bitcoindevkit/bdk-python/blob/master/.github/workflows/build.yml | |
# MIT | |
build-manylinux2014-x86_64-wheel: | |
name: 'Build Manylinux 2014 x86_64 wheel' | |
runs-on: ubuntu-latest | |
container: | |
image: quay.io/pypa/manylinux2014_x86_64 | |
env: | |
PLAT: manylinux2014_x86_64 | |
PYBIN: '/opt/python/${{ matrix.python }}/bin' | |
strategy: | |
fail-fast: false | |
matrix: | |
python: # Update this list whenever the docker image is updated (check /opt/python/) | |
- cp38-cp38 | |
- cp39-cp39 | |
- cp310-cp310 | |
- cp311-cp311 | |
- cp312-cp312 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install python3-devel | |
run: yum install -y python3-devel wget | |
- name: Install SWIG | |
run: | | |
git clone https://github.com/swig/swig.git --branch v4.0.2 | |
cd swig | |
./autogen.sh | |
./configure | |
make | |
make install | |
cd .. | |
rm -rf swig/ | |
- name: Configure | |
run: | | |
cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON \ | |
-DBUILD_PYTHON=ON -DBUILD_SHARED_LIBS=ON \ | |
-DPython3_ROOT_DIR="/usr/" -DPython3_FIND_STRATEGY="LOCATION" | |
- name: Build | |
run: cmake --build build --config Release --target all -v | |
- name: install requirements | |
run: ${PYBIN}/pip install -r python/requirements.dev.txt | |
- name: build wheel | |
run: ${PYBIN}/pip wheel build/python/ --no-deps -w build/python/wheelhouse | |
- name: repair wheel | |
run: auditwheel repair build/python/wheelhouse/* --plat "$PLAT" -w build/python/wheelhouse-repaired | |
- name: test | |
run: | | |
"${PYBIN}/pip" install cspy --no-index -f build/python/wheelhouse-repaired/ | |
"${PYBIN}/python3" -m unittest discover -s test/python/ | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-wheels | |
path: build/python/wheelhouse-repaired/ | |
continue-on-error: true | |
macos-build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-12, macos-13, macos-14] | |
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install swig | |
run: | | |
brew update | |
brew install swig | |
- name: Configure | |
run: | | |
echo $pythonLocation | |
echo $pythonVersion | |
cmake -S . -Bbuild -DBUILD_TESTING=ON -DBUILD_PYTHON=ON -DBUILD_SHARED_LIBS=ON -DPython3_ROOT_DIR=${pythonLocation} -DPython_ROOT_DIR=${pythonLocation} -DPython3_FIND_STRATEGY=LOCATION | |
- name: Build | |
run: cmake --build build --config Release --target all -v | |
- name: Fix wheel and run python tests | |
run: | | |
python3 -m pip install delocate wheel | |
delocate-listdeps --all build/python/dist/*.whl | |
delocate-wheel -w wheelhouse -v build/python/dist/*.whl | |
cd build | |
ctest --verbose -R python_unittest | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: macos-wheels | |
path: wheelhouse/ | |
continue-on-error: true | |
windows-build: | |
runs-on: windows-2019 | |
env: | |
TWINE_USERNAME: "__token__" | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Configure | |
run: cmake -S. -Bbuild -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON=ON -DBUILD_TESTING=ON -DPython3_ROOT_DIR=$env:pythonLocation -DPython_ROOT_DIR=$env:pythonLocation -DPython3_FIND_STRATEGY=LOCATION -DPython3_FIND_REGISTRY=LAST | |
- name: Build | |
run: cmake --build build --config Release --target ALL_BUILD -- /verbosity:normal /maxcpucount | |
- name: Run python tests | |
run: | | |
cd build | |
ctest -C Release --verbose | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-wheels | |
path: build/python/dist/ | |
continue-on-error: true | |
pypi-publish: | |
name: Upload release to PyPI | |
needs: [build-manylinux2014-x86_64-wheel, macos-build, windows-build] | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/cspy | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
# retrieve your distributions here | |
- uses: actions/download-artifact@v4 | |
with: | |
name: linux-wheels | |
path: allwheels | |
- name: Display structure of Linux wheels | |
run: ls -R allwheels | |
- uses: actions/download-artifact@v4 | |
with: | |
name: macos-wheels | |
path: allwheels | |
- uses: actions/download-artifact@v4 | |
with: | |
name: windows-wheels | |
path: allwheels | |
- name: Display allwheels dir | |
run: ls -R allwheels | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: allwheels | |
verbose: true | |
skip-existing: true | |
password: ${{ secrets.PYPI_API_KEY }} |