Skip to content

Commit 7780888

Browse files
committed
ci: create the "Publish to TestPyPI" workflow
1 parent 5f3c9e2 commit 7780888

File tree

5 files changed

+244
-8
lines changed

5 files changed

+244
-8
lines changed

.github/workflows/docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
tags:
66
- "v*"
7-
workflow_dispatch:
87

98
permissions:
109
contents: write

.github/workflows/pr.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR
1+
name: PR Tests
22

33
on:
44
pull_request:
@@ -55,3 +55,7 @@ jobs:
5555
- name: Run doc tests
5656
run: |
5757
make test-docs
58+
59+
test-rust-accel:
60+
uses: ./.github/workflows/test-rust-accel.yml
61+
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Publish to TestPyPI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: "Git ref to build (tag like v0.3.4-rc1, branch, or SHA). Default: current ref."
8+
required: false
9+
default: ""
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
jobs:
16+
pr:
17+
uses: ./.github/workflows/pr.yml
18+
19+
build-wheels:
20+
runs-on: ${{ matrix.os }}
21+
needs:
22+
- test
23+
- docs
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [ubuntu-latest, macos-latest, windows-latest]
28+
python-version: ["3.11"]
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v3
45+
46+
- name: Build wheels (Rust-enabled)
47+
uses: PyO3/maturin-action@v1
48+
with:
49+
command: build
50+
args: --release --out dist
51+
working-directory: rust-base32
52+
manylinux: auto
53+
54+
- name: Upload wheels
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: wheels-${{ matrix.os }}
58+
path: rust-base32/dist/*.whl
59+
60+
build-sdist:
61+
runs-on: ubuntu-latest
62+
needs:
63+
- test
64+
- docs
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v4
68+
with:
69+
fetch-depth: 0
70+
71+
- name: Set up Python
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: "3.11"
75+
76+
- name: Install uv
77+
uses: astral-sh/setup-uv@v3
78+
79+
- name: Sync deps (including build tools)
80+
run: |
81+
uv sync --all-extras --dev
82+
83+
- name: Build sdist
84+
run: |
85+
make build-sdist
86+
87+
- name: Upload sdist
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: sdist
91+
path: dist/*.tar.gz
92+
93+
publish:
94+
runs-on: ubuntu-latest
95+
needs:
96+
- build-wheels
97+
- build-sdist
98+
permissions:
99+
contents: read
100+
id-token: write
101+
steps:
102+
- name: Download all artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: dist
106+
107+
- name: Flatten dist directory
108+
shell: bash
109+
run: |
110+
mkdir -p out
111+
find dist -type f \( -name "*.whl" -o -name "*.tar.gz" \) -maxdepth 4 -print -exec cp {} out/ \;
112+
ls -la out
113+
114+
- name: Publish to TestPyPI
115+
uses: pypa/gh-action-pypi-publish@release/v1
116+
with:
117+
repository-url: https://test.pypi.org/legacy/
118+
packages-dir: out

.github/workflows/publish.yml

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,52 @@ jobs:
1616
docs:
1717
uses: ./.github/workflows/docs.yml
1818

19-
build-and-publish:
20-
runs-on: ubuntu-latest
21-
needs:
19+
build-wheels:
20+
runs-on: ${{ matrix.os }}
21+
needs:
2222
- test
2323
- docs
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [ubuntu-latest, macos-latest, windows-latest]
28+
python-version: ["3.11"]
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v3
45+
46+
- name: Build wheels (Rust-enabled)
47+
uses: PyO3/maturin-action@v1
48+
with:
49+
command: build
50+
args: --release --out dist
51+
working-directory: rust-base32
52+
manylinux: auto
53+
54+
- name: Upload wheels
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: wheels-${{ matrix.os }}
58+
path: rust-base32/dist/*.whl
2459

60+
build-sdist:
61+
runs-on: ubuntu-latest
62+
needs:
63+
- test
64+
- docs
2565
steps:
2666
- name: Checkout
2767
uses: actions/checkout@v4
@@ -40,11 +80,38 @@ jobs:
4080
run: |
4181
uv sync --all-extras --dev
4282
43-
- name: Build (sdist + wheel)
83+
- name: Build sdist
84+
run: |
85+
make build-sdist
86+
87+
- name: Upload sdist
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: sdist
91+
path: dist/*.tar.gz
92+
93+
publish:
94+
runs-on: ubuntu-latest
95+
needs:
96+
- build-wheels
97+
- build-sdist
98+
permissions:
99+
contents: read
100+
id-token: write
101+
steps:
102+
- name: Download all artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: dist
106+
107+
- name: Flatten dist directory
108+
shell: bash
44109
run: |
45-
make build
110+
mkdir -p out
111+
find dist -type f \( -name "*.whl" -o -name "*.tar.gz" \) -maxdepth 4 -print -exec cp {} out/ \;
112+
ls -la out
46113
47114
- name: Publish to PyPI
48115
uses: pypa/gh-action-pypi-publish@release/v1
49116
with:
50-
packages-dir: dist
117+
packages-dir: out
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Test Rust Acceleration
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
pull_request:
7+
push:
8+
branches: [main]
9+
10+
jobs:
11+
test-rust-accel:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
python-version: ["3.11"]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install Rust
29+
uses: dtolnay/rust-toolchain@stable
30+
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v3
33+
34+
- name: Sync deps (locked)
35+
run: |
36+
uv sync --locked --all-groups
37+
38+
- name: Build & install Rust extension (maturin develop)
39+
run: |
40+
uv run python -m pip install -U pip
41+
uv run python -m pip install -U maturin
42+
cd rust-base32
43+
uv run maturin develop --release
44+
cd ..
45+
46+
- name: Sanity check (import extension)
47+
run: |
48+
uv run python -c "import typeid_base32; print('typeid_base32 OK')"

0 commit comments

Comments
 (0)