|
| 1 | +name: Build M1 Wheels |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build_wheels: |
| 7 | + name: Build wheel on Mac M1 |
| 8 | + runs-on: [m1] |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Cancel previous runs on the same branch |
| 14 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 15 | + |
| 16 | + with: |
| 17 | + access_token: ${{ github.token }} |
| 18 | + |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v2 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Ensure dependencies are present |
| 25 | + run: | |
| 26 | + brew install gmp boost |
| 27 | +
|
| 28 | + - name: Lint source with flake8 |
| 29 | + run: | |
| 30 | + arch -arm64 python -m pip install --upgrade pip |
| 31 | + arch -arm64 pip install flake8 |
| 32 | + arch -arm64 flake8 tests setup.py |
| 33 | +
|
| 34 | + - name: Lint source with mypy |
| 35 | + run: | |
| 36 | + arch -arm64 pip install mypy |
| 37 | + arch -arm64 mypy --config-file mypi.ini setup.py tests |
| 38 | +
|
| 39 | + - name: Build m1 wheels |
| 40 | + run: | |
| 41 | + export BUILD_VDF_CLIENT=N |
| 42 | + arch -arm64 pip wheel -w dist --no-deps . |
| 43 | + arch -arm64 delocate-wheel -v dist/*.whl |
| 44 | +
|
| 45 | + - name: Test wheel |
| 46 | + run: | |
| 47 | + arch -arm64 python3 -m venv venv |
| 48 | + . ./venv/bin/activate |
| 49 | + arch -arm64 pip install ./dist/*.whl |
| 50 | + arch -arm64 pip install pytest |
| 51 | + arch -arm64 ./venv/bin/pytest -v ./tests |
| 52 | +
|
| 53 | + - name: Create sha256 hash |
| 54 | + run: | |
| 55 | + mkdir hashes |
| 56 | + cd ./dist |
| 57 | + shasum -a 256 * |
| 58 | + shasum -a 256 * > ../hashes/chiavdf-wheel-m1-sha256.txt |
| 59 | +
|
| 60 | + - name: Upload hashes |
| 61 | + uses: actions/upload-artifact@v2 |
| 62 | + with: |
| 63 | + name: blspy-hashes |
| 64 | + path: ./hashes |
| 65 | + |
| 66 | + - name: Upload wheels |
| 67 | + uses: actions/upload-artifact@v2 |
| 68 | + with: |
| 69 | + name: wheels |
| 70 | + path: ./dist |
| 71 | + |
| 72 | + - name: Test for secrets access |
| 73 | + id: check_secrets |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + unset HAS_SECRET |
| 77 | + if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi |
| 78 | + echo ::set-output name=HAS_SECRET::${HAS_SECRET} |
| 79 | + env: |
| 80 | + SECRET: "${{ secrets.test_pypi_password }}" |
| 81 | + |
| 82 | + - name: Install twine |
| 83 | + run: arch -arm64 pip install twine |
| 84 | + |
| 85 | + - name: Publish distribution to PyPI |
| 86 | + if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET |
| 87 | + env: |
| 88 | + TWINE_USERNAME: __token__ |
| 89 | + TWINE_NON_INTERACTIVE: 1 |
| 90 | + TWINE_PASSWORD: ${{ secrets.pypi_password }} |
| 91 | + run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*' |
| 92 | + |
| 93 | + - name: Publish distribution to Test PyPI |
| 94 | + if: steps.check_secrets.outputs.HAS_SECRET |
| 95 | + env: |
| 96 | + TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ |
| 97 | + TWINE_USERNAME: __token__ |
| 98 | + TWINE_NON_INTERACTIVE: 1 |
| 99 | + TWINE_PASSWORD: ${{ secrets.test_pypi_password }} |
| 100 | + run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*' |
0 commit comments