Skip to content

Commit 2defa26

Browse files
authored
Merge pull request #3 from matrix-org/quenting/wheels
2 parents 85104f1 + da5d124 commit 2defa26

File tree

10 files changed

+408
-25
lines changed

10 files changed

+408
-25
lines changed

.github/workflows/python.yaml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
name: Python
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- "*"
8+
pull_request:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
collect-sdist:
16+
name: "Collect sdist"
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout the code
20+
uses: actions/checkout@v3
21+
22+
- name: Install Python 3.10
23+
uses: actions/setup-python@v4
24+
id: cpy310
25+
with:
26+
python-version: "3.10"
27+
architecture: x64
28+
29+
- name: Install build
30+
run: pip install build
31+
32+
- name: Collect sdist
33+
run: python -m build -o dist --sdist synapse
34+
35+
- name: Upload sdist
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: sdist
39+
path: dist
40+
41+
build-wheels:
42+
name: "Build Python wheels"
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- os: macos-latest
48+
target: x86_64-apple-darwin
49+
compatibility: manylinux2014 # Ignored on macOS
50+
51+
- os: macos-latest
52+
target: aarch64-apple-darwin
53+
compatibility: manylinux2014 # Ignored on macOS
54+
55+
- os: ubuntu-latest
56+
target: aarch64-unknown-linux-gnu
57+
compatibility: manylinux2014
58+
59+
- os: ubuntu-latest
60+
target: x86_64-unknown-linux-gnu
61+
compatibility: manylinux2014
62+
63+
- os: ubuntu-latest
64+
target: aarch64-unknown-linux-musl
65+
compatibility: musllinux_1_2
66+
67+
- os: ubuntu-latest
68+
target: x86_64-unknown-linux-musl
69+
compatibility: musllinux_1_2
70+
71+
runs-on: ${{ matrix.os }}
72+
steps:
73+
- name: Checkout the code
74+
uses: actions/checkout@v3
75+
76+
- name: Install Python 3.10
77+
uses: actions/setup-python@v4
78+
id: cpy310
79+
with:
80+
python-version: "3.10"
81+
architecture: x64
82+
update-environment: false
83+
84+
- name: Install maturin (macOS)
85+
if: runner.os == 'macOS'
86+
run: |
87+
mkdir -p "${HOME}/.local/bin"
88+
curl -sL https://github.com/PyO3/maturin/releases/download/v0.13.6/maturin-x86_64-apple-darwin.tar.gz | tar xzf - -C "${HOME}/.local/bin"
89+
echo "$HOME/.local/bin" >> $GITHUB_PATH
90+
91+
- name: Install maturin (Linux)
92+
if: runner.os == 'Linux'
93+
run: |
94+
mkdir -p "${HOME}/.local/bin"
95+
curl -sL https://github.com/PyO3/maturin/releases/download/v0.13.6/maturin-x86_64-unknown-linux-musl.tar.gz | tar xzf - -C "${HOME}/.local/bin"
96+
echo "$HOME/.local/bin" >> $GITHUB_PATH
97+
98+
- name: Setup Zig
99+
uses: goto-bus-stop/setup-zig@v1
100+
with:
101+
version: 0.9.1
102+
103+
- name: Install Rust toolchain
104+
uses: actions-rs/toolchain@v1
105+
with:
106+
toolchain: stable
107+
profile: minimal
108+
default: true
109+
target: ${{ matrix.target }}
110+
111+
- name: Setup Rust build cache
112+
uses: Swatinem/rust-cache@v2
113+
with:
114+
shared-key: ${{ matrix.target }}
115+
116+
- name: Build wheels
117+
run: |
118+
maturin build \
119+
--release \
120+
--out dist \
121+
--manifest-path synapse/Cargo.toml \
122+
-i ${{ steps.cpy310.outputs.python-path }} \
123+
--compatibility ${{ matrix.compatibility }} \
124+
--target ${{ matrix.target }} \
125+
--zig
126+
127+
- name: Upload wheels
128+
uses: actions/upload-artifact@v3
129+
with:
130+
name: wheels
131+
path: dist
132+
133+
upload:
134+
name: "Upload to PyPI"
135+
runs-on: ubuntu-latest
136+
137+
permissions: {}
138+
if: startsWith(github.ref, 'refs/tags')
139+
140+
needs: [ collect-sdist, build-wheels ]
141+
steps:
142+
- name: Download wheels
143+
uses: actions/download-artifact@v3
144+
with:
145+
name: wheels
146+
path: dist
147+
148+
- name: Download sdist
149+
uses: actions/download-artifact@v3
150+
with:
151+
name: sdist
152+
path: dist
153+
154+
- name: Publish distribution to PyPI
155+
if: startsWith(github.ref, 'refs/tags')
156+
uses: pypa/gh-action-pypi-publish@release/v1
157+
with:
158+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/ci.yaml renamed to .github/workflows/rust.yaml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: CI
1+
name: Rust
22

33
on:
44
push:
55
branches: [ main ]
6+
tags:
7+
- '*'
68
pull_request:
79
branches: [ main ]
810

@@ -162,3 +164,33 @@ jobs:
162164
with:
163165
files: target/coverage/*.lcov
164166
flags: unit
167+
168+
publish:
169+
name: Publish on crates.io
170+
needs: [rustfmt, clippy, test, coverage]
171+
runs-on: ubuntu-latest
172+
173+
# Publish on tags
174+
if: startsWith(github.ref, 'refs/tags/')
175+
176+
permissions:
177+
contents: read
178+
179+
steps:
180+
- name: Checkout the code
181+
uses: actions/checkout@v3
182+
183+
- name: Install toolchain
184+
id: toolchain
185+
uses: actions-rs/toolchain@v1
186+
with:
187+
toolchain: stable
188+
override: true
189+
profile: minimal
190+
191+
- name: Publish on crates.io
192+
uses: actions-rs/cargo@v1
193+
with:
194+
command: publish
195+
env:
196+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
/Cargo.lock
3+
/dist

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
[package]
2-
name = "rendezvous"
2+
name = "matrix-http-rendezvous"
33
version = "0.1.0"
4+
authors = ["Quentin Gliech <[email protected]>"]
45
edition = "2021"
6+
license = "Apache-2.0"
7+
description = "A Tower service which implements MSC3886"
8+
repository = "https://github.com/matrix-org/rust-http-rendezvous-server/"
9+
rust-version = "1.61"
10+
exclude = ["/.github", ".gitignore"]
511

612
[dependencies]
713
axum = { version = "0.6.0-rc.2", features = ["headers"] }

0 commit comments

Comments
 (0)