Skip to content

Commit d62798c

Browse files
authored
Merge pull request #56 from akhundMurad/feat/ci
feat(ci): create pipeline to publish package to PyPI on each release
2 parents 2f18e3f + 1c801af commit d62798c

File tree

5 files changed

+176
-8
lines changed

5 files changed

+176
-8
lines changed

.github/workflows/docs.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
name: Docs
1+
name: Publish Docs
22

33
on:
44
push:
5-
branches: [main]
6-
workflow_dispatch:
5+
tags:
6+
- "v*"
77

88
permissions:
99
contents: write
1010

1111
jobs:
12+
test:
13+
uses: ./.github/workflows/test.yml
14+
1215
deploy:
1316
runs-on: ubuntu-latest
17+
needs: test
18+
1419
steps:
1520
- uses: actions/checkout@v4
1621

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

33
on:
44
pull_request:

.github/workflows/publish.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
test:
14+
uses: ./.github/workflows/test.yml
15+
16+
docs:
17+
uses: ./.github/workflows/docs.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 PyPI
115+
uses: pypa/gh-action-pypi-publish@release/v1
116+
with:
117+
packages-dir: out
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 --all-extras
37+
38+
- name: Build & install Rust extension (maturin develop)
39+
uses: PyO3/maturin-action@v1
40+
with:
41+
command: develop
42+
args: --release
43+
working-directory: rust-base32
44+
45+
- name: Sanity check (import extension)
46+
run: |
47+
uv run python -c "import typeid_base32; print('typeid_base32 OK')"
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Run Tests
22

33
on:
44
release:
@@ -7,14 +7,13 @@ on:
77
branches:
88
- main
99
paths-ignore:
10-
- README.md
11-
- CHANGELOG.md
10+
- '**.md'
1211

1312
env:
1413
PROJECT_NAME: typeid-python
1514

1615
jobs:
17-
build:
16+
test:
1817
runs-on: ubuntu-latest
1918
strategy:
2019
fail-fast: false

0 commit comments

Comments
 (0)