-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (113 loc) · 5.04 KB
/
build-and-publish-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
name: Set up valve rust bindings
on:
release:
types: [released]
env:
CARGO_TERM_COLOR: always
jobs:
publish-wheels:
strategy:
matrix:
target: [
{ runner: "macos-11", arch: "x86_64-apple-darwin" },
{ runner: "macos-11", arch: "aarch64-apple-darwin" },
{ runner: "windows-2022", arch: "x86_64-pc-windows-msvc" },
{ runner: "ubuntu-20.04", arch: "x86_64-unknown-linux-gnu" },
{ runner: "ubuntu-20.04", arch: "x86_64-unknown-linux-musl" },
]
runs-on: ${{ matrix.target.runner }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install musl-tools (MUSL)
if: ${{ matrix.target.runner == 'ubuntu-20.04' && matrix.target.arch == 'x86_64-unknown-linux-musl' }}
run: |
sudo apt-get update
sudo apt-get install musl-tools
- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target.arch }}
default: true
override: true
- name: Set environment variables corresponding to the valve.rs and valve.py versions.
shell: bash
run: |
echo "VALVE_PY_VERSION=$(grep valve\.py VALVE.VERSION |awk '{print $2}')" >> $GITHUB_ENV
echo "VALVE_RS_VERSION=$(grep valve\.rs VALVE.VERSION |awk '{print $2}')" >> $GITHUB_ENV
# Note that we need to specify the bash shell here in order for the string interpolation to
# work on the Windows runner.
- name: Retrieve and extract the right version of valve.rs from crates.io.
shell: bash
run: |
curl -L -o valve.tar https://crates.io/api/v1/crates/ontodev_valve/$VALVE_RS_VERSION/download
tar xvf valve.tar
mv ontodev_valve-$VALVE_RS_VERSION valve.rs
- name: Override the valve.rs version in Cargo.toml with the valve.py version
shell: bash
run: |
python3 override_valve_version.py $VALVE_PY_VERSION valve.rs/Cargo.toml > valve.rs/Cargo.toml.new
mv -f valve.rs/Cargo.toml.new valve.rs/Cargo.toml
- name: Create a soft-link to the valve rust library source code file.
shell: bash
working-directory: ./valve.rs
run: |
ln -s ../../valve_py.rs src/
- name: Edit lib.rs and add dependencies to Cargo.toml
working-directory: ./valve.rs
run: |
echo "mod valve_py;" >> src/lib.rs
cat ../extra_cargo_entries.toml >> Cargo.toml
- name: Override valve.rs's README.md with valve.py's
working-directory: ./valve.rs
run: |
cp ../README.md .
- name: Build wheels for Python 3.8 (MUSL)
if: ${{ matrix.target.runner == 'ubuntu-20.04' && matrix.target.arch == 'x86_64-unknown-linux-musl' }}
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target.arch }}
manylinux: musllinux_1_2
args: --release --interpreter python3.8 --out dist -m valve.rs/Cargo.toml
- name: Build wheels for Python 3.8 (non-MUSL)
if: ${{ matrix.target.runner != 'ubuntu-20.04' || matrix.target.arch != 'x86_64-unknown-linux-musl' }}
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target.arch }}
args: --release --interpreter python3.8 --out dist -m valve.rs/Cargo.toml
- name: Build wheels for Python 3.9 (MUSL)
if: ${{ matrix.target.runner == 'ubuntu-20.04' && matrix.target.arch == 'x86_64-unknown-linux-musl' }}
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target.arch }}
manylinux: musllinux_1_2
args: --release --interpreter python3.9 --out dist -m valve.rs/Cargo.toml
- name: Build wheels for Python 3.9 (non-MUSL)
if: ${{ matrix.target.runner != 'ubuntu-20.04' || matrix.target.arch != 'x86_64-unknown-linux-musl' }}
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target.arch }}
args: --release --interpreter python3.9 --out dist -m valve.rs/Cargo.toml
- name: Build wheels for Python 3.10 (MUSL)
if: ${{ matrix.target.runner == 'ubuntu-20.04' && matrix.target.arch == 'x86_64-unknown-linux-musl' }}
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target.arch }}
manylinux: musllinux_1_2
args: --release --interpreter python3.10 --out dist -m valve.rs/Cargo.toml
- name: Build wheels for Python 3.10 (non-MUSL)
if: ${{ matrix.target.runner != 'ubuntu-20.04' || matrix.target.arch != 'x86_64-unknown-linux-musl' }}
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target.arch }}
args: --release --interpreter python3.10 --out dist -m valve.rs/Cargo.toml
- name: Install twine
run: |
pip install twine
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*