Switch to trusted publishing for pypi #1249
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 M1 Wheels | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
tags: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}--${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
id-token: write | |
jobs: | |
build_wheels: | |
name: Build wheel on Mac M1 | |
runs-on: [MacOS, ARM64] | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: Chia-Network/actions/clean-workspace@main | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up rust | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust.sh | |
sh rust.sh -y | |
- name: Build m1 wheels | |
run: | | |
python3 -m venv venv | |
. ./venv/bin/activate | |
export PATH=~/.cargo/bin:$PATH | |
pip install maturin | |
maturin build -m wheel/Cargo.toml -i python --release --strip --features=openssl | |
- name: Install clvm_rs wheel | |
run: | | |
. ./venv/bin/activate | |
ls ./target/wheels/ | |
pip install ./target/wheels/clvm_rs*.whl | |
- name: Install other wheels | |
run: | | |
. ./venv/bin/activate | |
python -m pip install pytest | |
python -m pip install blspy | |
- name: install clvm & clvm_tools | |
run: | | |
. ./venv/bin/activate | |
git clone https://github.com/Chia-Network/clvm.git --branch=main --single-branch | |
python -m pip install ./clvm | |
git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch | |
python -m pip install ./clvm_tools | |
- name: Ensure clvm, clvm_rs, clvm_tools are installed | |
run: | | |
. ./venv/bin/activate | |
python -c 'import clvm' | |
python -c 'import clvm; print(clvm.__file__)' | |
python -c 'import clvm_rs; print(clvm_rs.__file__)' | |
python -c 'import clvm_tools; print(clvm_tools.__file__)' | |
- name: Run tests from clvm | |
run: | | |
. ./venv/bin/activate | |
cd clvm | |
pytest tests | |
- name: Run tests from clvm_tools | |
run: | | |
. ./venv/bin/activate | |
cd clvm_tools | |
pytest tests | |
- name: Run tests from wheel | |
run: | | |
. ./venv/bin/activate | |
cd wheel/python | |
pytest --import-mode append tests | |
# we use `append` because otherwise the `clvm_rs` source is added | |
# to `sys.path` and it uses that instead of the wheel (and so | |
# ignoring `clvm_rs.so`, which is pretty important) | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: ./target/wheels | |
- name: Install twine | |
run: | | |
. ./venv/bin/activate | |
pip install twine | |
- name: Publish distribution to PyPI | |
if: startsWith(github.event.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: target/wheels/ | |
skip-existing: true |