120 lines (106 loc) · 3.58 KB
/
build-m1-wheel.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Build M1 Wheels
on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'
jobs:
build_wheels:
name: Build wheel on Mac M1
runs-on: [m1]
strategy:
fail-fast: false
steps:
- name: Cancel previous runs on the same branch
if: ${{ github.ref != 'refs/heads/main' }}
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Brew update Python
run: |
arch -arm64 brew upgrade python@3.9
arch -arm64 brew upgrade python@3.10
arch -arm64 brew info python@3.9
arch -arm64 brew info python@3.10
- name: Build m1 wheels for 3.9 and 3.10
run: |
rm -rf venv
arch -arm64 /usr/local/opt/python@3.9/libexec/bin/python -m venv venv
arch -arm64 source venv/bin/activate
arch -arm64 /usr/local/opt/python@3.9/libexec/bin/pip wheel -w dist --no-deps .
arch -arm64 delocate-wheel -v dist/*cp39*.whl
deactivate
rm -rf venv
arch -arm64 /usr/local/opt/python@3.10/libexec/bin/python -m venv venv
arch -arm64 source venv/bin/activate
arch -arm64 /usr/local/opt/python@3.10/libexec/bin/pip wheel -w dist --no-deps .
arch -arm64 delocate-wheel -v dist/*cp310*.whl
deactivate
rm -rf venv
- name: Test wheel
run: |
rm -rf venv
arch -arm64 /usr/local/opt/python@3.9/libexec/bin/python -m venv venv
arch -arm64 source venv/bin/activate
arch -arm64 pip install ./dist/*cp-39*.whl
arch -arm64 pip install pytest
arch -arm64 ./venv/bin/pytest -v ./python-bindings/test.py
deactivate
rm -rf venv
arch -arm64 /usr/local/opt/python@3.10/libexec/bin/python -m venv venv
arch -arm64 source venv/bin/activate
arch -arm64 pip install ./dist/*cp-310*.whl
arch -arm64 pip install pytest
arch -arm64 ./venv/bin/pytest -v ./python-bindings/test.py
deactivate
rm -rf venv
- name: Create sha256 hash
run: |
mkdir hashes
cd ./dist
shasum -a 256 *
shasum -a 256 * > ../hashes/blspy-wheel-m1-sha256.txt
- name: Upload hashes
uses: actions/upload-artifact@v2
with:
name: blspy-hashes
path: ./hashes
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./dist
- name: Test for secrets access
id: check_secrets
shell: bash
run: |
unset HAS_SECRET
if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi
echo ::set-output name=HAS_SECRET::${HAS_SECRET}
env:
SECRET: "${{ secrets.test_pypi_password }}"
- name: Install twine
run: arch -arm64 pip install twine
- name: Publish distribution to PyPI
if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET
env:
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*'
- name: Publish distribution to Test PyPI
if: steps.check_secrets.outputs.HAS_SECRET
env:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
TWINE_PASSWORD: ${{ secrets.test_pypi_password }}
run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*'