-
Notifications
You must be signed in to change notification settings - Fork 61
139 lines (131 loc) · 4.2 KB
/
build-pip-wheels.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Produce Arbor release artifacts
on:
push:
branches:
- ciwheel
tags:
- v*
schedule:
- cron: '0 3 * * 0'
jobs:
get_timestamp:
name: Prep pyproject.toml
runs-on: ubuntu-latest
steps:
- name: Get Arbor
uses: actions/checkout@v4
with:
submodules: recursive
- name: Create unique version in pyproject.toml
if: startsWith(github.ref, 'refs/tags/v') == false
run: python3 -c 'import time;f=open("pyproject.toml","r+");c = f.readlines();d=[i.split("#")[0].strip()[:-1]+time.strftime("%Y%m%d%H%I%S")+"\"\n" if i.startswith("version") else i for i in c];f.seek(0);f.writelines(d);f.truncate()'
- uses: actions/upload-artifact@v4
with:
name: arbver
path: ${{ github.workspace }}/pyproject.toml
build_binary_wheels:
name: Build wheels on ${{ matrix.os }}
needs: get_timestamp
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Get Arbor
uses: actions/checkout@v4
with:
submodules: recursive
- name: Delete pyproject.toml
run: rm -f pyproject.toml
- name: Get pyproject.toml
uses: actions/download-artifact@v4
with:
name: arbver
- name: Check pyproject.toml
run: cat pyproject.toml
- name: Move fast and...
run: python3 -m pip config set global.break-system-packages true
- name: Install cibuildwheel
run: python3 -m pip install cibuildwheel
- name: Build wheels
run: python3 -m cibuildwheel --output-dir dist
- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
path: dist/*.whl
build_sdist:
name: Build sdist
needs: get_timestamp
runs-on: ubuntu-latest
steps:
- name: Update pip and setup venv
run: python -m pip install --upgrade pip && python -m venv ~/env && . ~/env/bin/activate && echo PATH=$PATH >> $GITHUB_ENV
- name: Get packages
run: python3 -m pip install build
- name: Get Arbor
uses: actions/checkout@v4
with:
submodules: recursive
- name: Delete pyproject.toml
run: rm -f pyproject.toml
- name: Get pyproject.toml
uses: actions/download-artifact@v4
with:
name: arbver
- name: Check pyproject.toml
run: cat pyproject.toml
- name: Make sdist
run: python3 -m build -s
- name: Install sdist
run: python3 -m pip install dist/arbor*.tar.gz
- name: Run Python tests
run: python3 -m unittest discover -v -s python
- name: Run Python examples
run: scripts/run_python_examples.sh
- name: Test executables
run: scripts/test_executables.sh
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*.tar.gz
upload_test_pypi:
name: upload to test pypi
runs-on: ubuntu-latest
needs: [build_binary_wheels, build_sdist]
steps:
- uses: actions/download-artifact@v4
with:
name: dist
- name: Publish distribution 📦 to Test PyPI
run: |
pip install twine
twine upload -r testpypi ./*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_SECRET }}
make_release:
name: draft new GitHub release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build_binary_wheels, build_sdist]
steps:
- name: "Clone w/ submodules"
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
path: arbor
- name: Make full tarball
run: |
the_ref=${{ github.ref }}
the_tag="${the_ref/refs\/tags\//}"
$GITHUB_WORKSPACE/arbor/scripts/create_tarball $GITHUB_WORKSPACE/arbor $the_tag $GITHUB_WORKSPACE/arbor-$the_tag-full.tar.gz
- name: "Make Release"
uses: ncipollo/release-action@v1
with:
omitBody: false
draft: true
prerelease: false
generateReleaseNotes: true
artifacts: '*.whl,*full.tar.gz'
token: ${{ secrets.GITHUB_TOKEN }}