This repository has been archived by the owner on May 2, 2024. It is now read-only.
Github actions to publish to pypi #316
Workflow file for this run
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: build wheels | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
detect-changes: | |
uses: ./.github/workflows/check_diff.yml | |
with: | |
pattern: ^crates/hyperdrivepy/ | |
# TODO combine this with cibuildwheels | |
build-linux: | |
needs: detect-changes | |
# Run in PRs if changes are detected | |
# Run on main if version has changed | |
# if: > | |
# needs.detect-changes.outputs.changed == 'true' || | |
# (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.version_changed == 'true') | |
name: build on linux | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{github.token}} | |
- name: setup rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: setup foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: set up python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: "pip" | |
token: ${{github.token}} | |
- name: set up pip | |
run: python -m pip install --upgrade pip | |
- name: check out hyperdrive | |
uses: actions/checkout@master | |
with: | |
repository: delvtech/hyperdrive | |
ref: "v0.9.0" | |
path: "./hyperdrive" | |
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} | |
- name: build hyperdrivepy | |
shell: bash | |
run: source scripts/build_python.sh | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-linux | |
path: ./wheelhouse/*.whl | |
build-cibuildwheels: | |
needs: detect-changes | |
# Run in PRs if changes are detected | |
# Run on main if version has changed | |
# if: > | |
# needs.detect-changes.outputs.changed == 'true' || | |
# (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.version_changed == 'true') | |
name: Build on ${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }} | |
runs-on: ${{ matrix.buildplat[0] }} | |
strategy: | |
fail-fast: false | |
matrix: | |
buildplat: | |
- [macos-12, macosx_x86_64] | |
- [macos-12, macosx_arm64] | |
#- [macos-12, macosx_universal2] | |
- [windows-2019, win_amd64] | |
python-version: [cp310] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: check out hyperdrive | |
uses: actions/checkout@master | |
with: | |
repository: delvtech/hyperdrive | |
ref: "v0.9.0" | |
path: "./hyperdrive" | |
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} | |
- name: setup rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
# NOTE: This is needed to ensure that hyperdrive-wrappers builds correctly. | |
- name: install foundry | |
uses: foundry-rs/[email protected] | |
with: | |
version: nightly | |
- name: set up python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: install python dependencies | |
run: python -m pip install --upgrade pip && python -m pip install --upgrade -r requirements-dev.txt | |
- name: build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: "${{ matrix.python-version }}-*" | |
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$HOME/.foundry/bin:$HOME/.cargo/env:$PATH" CARGO_TERM_COLOR="always"' | |
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$UserProfile\.foundry\bin;$UserProfile\.cargo\env;$PATH"' | |
CIBW_ARCHS_MACOS: x86_64 arm64 | |
CIBW_BEFORE_ALL_MACOS: > | |
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y && | |
rustup show && | |
rustup target add aarch64-apple-darwin && | |
curl -L https://foundry.paradigm.xyz | sh && | |
foundryup | |
CIBW_BUILD_VERBOSITY: 1 | |
with: | |
output-dir: wheelhouse | |
package-dir: crates/hyperdrivepy | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.buildplat[0]}}-${{ matrix.buildplat[1] }}-${{ strategy.job-index }} | |
path: ./wheelhouse/*.whl | |
build-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build sdist | |
run: pipx run build crates/hyperdrivepy --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: crates/hyperdrivepy/dist/*.tar.gz | |
upload_pypi: | |
needs: [build-linux, build-cibuildwheels, build-sdist, detect-changes] | |
runs-on: ubuntu-latest | |
environment: pypi | |
permissions: | |
id-token: write | |
# Upload only if on main and version has changed | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.version_changed == 'true' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://pypi.org/project/hyperdrivepy/ |