Skip to content

Commit 6b49fba

Browse files
committed
Use uv for PyPI publishing
1 parent 75e0bba commit 6b49fba

File tree

9 files changed

+253
-170
lines changed

9 files changed

+253
-170
lines changed

.github/workflows/main.yml

Lines changed: 119 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,135 @@
1-
name: CI
1+
name: Release to PyPI
22

33
on:
4+
workflow_dispatch: # Manual trigger only
45
push:
5-
branches: ["main"]
6-
pull_request:
7-
branches: ["main"]
8-
concurrency:
9-
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
10-
cancel-in-progress: true
6+
tags:
7+
- "v[0-9]*" # Trigger on version tags like v1.0.0
118

12-
env:
13-
CARGO_TERM_COLOR: always
9+
permissions:
10+
# IMPORTANT: this permission is mandatory for Trusted Publishing
11+
id-token: write
12+
contents: read
1413

1514
jobs:
16-
build:
17-
name: Build (Linux x86-64)
18-
runs-on: ubuntu-latest
15+
publish-binaries:
16+
name: Publish binaries
17+
runs-on: ${{ matrix.build.os }}
18+
environment: pypi_release
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
build:
23+
- {
24+
NAME: linux-x64-glibc,
25+
OS: ubuntu-24.04,
26+
TOOLCHAIN: stable,
27+
TARGET: x86_64-unknown-linux-gnu,
28+
}
29+
- {
30+
NAME: linux-x64-musl,
31+
OS: ubuntu-24.04,
32+
TOOLCHAIN: stable,
33+
TARGET: x86_64-unknown-linux-musl,
34+
}
35+
- {
36+
NAME: linux-arm64-glibc,
37+
OS: ubuntu-24.04-arm,
38+
TOOLCHAIN: stable,
39+
TARGET: aarch64-unknown-linux-gnu,
40+
}
41+
- {
42+
NAME: linux-arm64-musl,
43+
OS: ubuntu-24.04-arm,
44+
TOOLCHAIN: stable,
45+
TARGET: aarch64-unknown-linux-musl,
46+
}
47+
- {
48+
NAME: win32-x64-msvc,
49+
OS: windows-2025,
50+
TOOLCHAIN: stable,
51+
TARGET: x86_64-pc-windows-msvc,
52+
}
53+
- {
54+
NAME: darwin-arm64,
55+
OS: macos-15,
56+
TOOLCHAIN: stable,
57+
TARGET: aarch64-apple-darwin,
58+
}
1959
steps:
20-
- uses: actions/checkout@v4
21-
22-
- name: Install Rust 1.90.0
23-
uses: dtolnay/rust-toolchain@1.90.0
24-
25-
- name: Build with locked dependencies
26-
run: cargo build --locked
60+
- name: Checkout
61+
uses: actions/checkout@v4
2762

28-
format:
29-
name: Format Check
30-
runs-on: ubuntu-latest
31-
steps:
32-
- uses: actions/checkout@v4
33-
34-
- name: Install Rust stable
35-
uses: dtolnay/rust-toolchain@stable
63+
- name: Install dependencies
64+
shell: bash
65+
run: |
66+
if [[ "${{ matrix.build.NAME }}" = *"-musl" ]]; then
67+
sudo apt-get update
68+
sudo apt-get install -y --no-install-recommends \
69+
--allow-unauthenticated musl-tools
70+
fi
71+
72+
- name: Install Rust ${{ matrix.build.TOOLCHAIN }}
73+
uses: dtolnay/rust-toolchain@master
3674
with:
37-
components: rustfmt
38-
39-
- name: Check formatting
40-
run: cargo fmt --all -- --check
75+
toolchain: ${{ matrix.build.TOOLCHAIN }}
76+
targets: ${{ matrix.build.TARGET }}
4177

42-
clippy:
43-
name: Clippy
44-
runs-on: ubuntu-latest
45-
steps:
46-
- uses: actions/checkout@v4
47-
48-
- name: Install Rust 1.90.0
49-
uses: dtolnay/rust-toolchain@1.90.0
78+
- name: Build Python wheels (linux x86-64 with sdist)
79+
if: matrix.build.TARGET == 'x86_64-unknown-linux-gnu'
80+
uses: PyO3/maturin-action@v1
5081
with:
51-
components: clippy
52-
53-
- name: Run Clippy
54-
run: cargo clippy --all-targets --all-features -- -D warnings
82+
working-directory: pypi
83+
target: ${{ matrix.build.TARGET }}
84+
args: --release --sdist --out dist
85+
sccache: "true"
86+
manylinux: auto
5587

56-
test:
57-
name: Test
58-
needs: [build, format, clippy]
59-
strategy:
60-
fail-fast: false
61-
matrix:
62-
include:
63-
- os: ubuntu-latest
64-
target: x86_64-unknown-linux-gnu
65-
rust: stable
66-
- os: ubuntu-24.04-arm
67-
target: aarch64-unknown-linux-gnu
68-
rust: stable
69-
- os: macos-latest
70-
target: aarch64-apple-darwin
71-
rust: stable
72-
- os: windows-latest
73-
target: x86_64-pc-windows-msvc
74-
rust: stable
75-
runs-on: ${{ matrix.os }}
76-
steps:
77-
- uses: actions/checkout@v4
78-
79-
- name: Install Rust ${{ matrix.rust }}
80-
uses: dtolnay/rust-toolchain@master
88+
- name: Build Python wheels (linux non-x86-64)
89+
if: startsWith(matrix.build.NAME, 'linux') && matrix.build.TARGET != 'x86_64-unknown-linux-gnu'
90+
uses: PyO3/maturin-action@v1
8191
with:
82-
toolchain: ${{ matrix.rust }}
83-
targets: ${{ matrix.target }}
84-
85-
- name: Run tests
86-
run: cargo test --target ${{ matrix.target }}
92+
working-directory: pypi
93+
target: ${{ matrix.build.TARGET }}
94+
args: --release --out dist
95+
sccache: "true"
96+
manylinux: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' && '2_28' || (endsWith(matrix.build.TARGET, 'musl') && 'musllinux_1_2' || 'auto') }}
8797

88-
docs:
89-
name: Documentation
90-
needs: [build, format, clippy]
91-
runs-on: ubuntu-latest
92-
steps:
93-
- uses: actions/checkout@v4
94-
95-
- name: Install Rust stable
96-
uses: dtolnay/rust-toolchain@stable
97-
98-
- name: Build documentation
99-
run: cargo doc --no-deps --all-features
100-
env:
101-
RUSTDOCFLAGS: "-D warnings"
102-
103-
- name: Upload documentation
98+
- name: Build Python wheels (macos & windows)
99+
if: startsWith(matrix.build.OS, 'macos') || startsWith(matrix.build.OS, 'windows')
100+
uses: PyO3/maturin-action@v1
101+
with:
102+
working-directory: pypi
103+
target: ${{ matrix.build.TARGET }}
104+
args: --release --out dist
105+
sccache: "true"
106+
107+
- name: Upload Python wheels
104108
uses: actions/upload-artifact@v4
105109
with:
106-
name: documentation
107-
path: target/doc/
108-
retention-days: 1
110+
name: "wheels-${{ matrix.build.TARGET }}"
111+
path: pypi/dist
112+
113+
publish-pypi:
114+
name: Publish PyPI package
115+
runs-on: ubuntu-24.04
116+
needs: publish-binaries
117+
environment: pypi_release
118+
permissions:
119+
id-token: write
120+
contents: read
121+
steps:
122+
- name: Download all wheels
123+
uses: actions/download-artifact@v4
124+
with:
125+
path: dist
126+
pattern: wheels-*
127+
merge-multiple: true
128+
129+
- name: Install uv
130+
uses: astral-sh/setup-uv@v5
131+
with:
132+
version: "0.9.22"
133+
134+
- name: Publish to PyPI
135+
run: uv publish --trusted-publishing always dist/*

.github/workflows/release_pypi.yml

Lines changed: 29 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ on:
77
- "v[0-9]*" # Trigger on version tags like v1.0.0
88

99
permissions:
10-
# IMPORTANT: this permission is mandatory for Trusted Publishing
11-
id-token: write
10+
# IMPORTANT: this permission is mandatory for Trusted Publishing
11+
id-token: write
12+
contents: read
1213

1314
jobs:
1415
publish-binaries:
@@ -31,12 +32,6 @@ jobs:
3132
TOOLCHAIN: stable,
3233
TARGET: x86_64-unknown-linux-musl,
3334
}
34-
#- {
35-
# NAME: linux-x86-musl,
36-
# OS: ubuntu-24.04,
37-
# TOOLCHAIN: stable,
38-
# TARGET: i686-unknown-linux-musl,
39-
# }
4035
- {
4136
NAME: linux-arm64-glibc,
4237
OS: ubuntu-24.04-arm,
@@ -55,18 +50,6 @@ jobs:
5550
TOOLCHAIN: stable,
5651
TARGET: x86_64-pc-windows-msvc,
5752
}
58-
# - {
59-
# NAME: win32-x86-msvc,
60-
# OS: windows-2025,
61-
# TOOLCHAIN: stable,
62-
# TARGET: i686-pc-windows-msvc,
63-
# }
64-
# - {
65-
# NAME: darwin-x64,
66-
# OS: macos-15,
67-
# TOOLCHAIN: stable,
68-
# TARGET: x86_64-apple-darwin,
69-
# }
7053
- {
7154
NAME: darwin-arm64,
7255
OS: macos-15,
@@ -76,6 +59,7 @@ jobs:
7659
steps:
7760
- name: Checkout
7861
uses: actions/checkout@v4
62+
7963
- name: Install dependencies
8064
shell: bash
8165
run: |
@@ -84,62 +68,34 @@ jobs:
8468
sudo apt-get install -y --no-install-recommends \
8569
--allow-unauthenticated musl-tools
8670
fi
87-
- name: Install Rust toolchain
88-
uses: actions-rs/toolchain@v1
71+
72+
- name: Install Rust ${{ matrix.build.TOOLCHAIN }}
73+
uses: dtolnay/rust-toolchain@stable
8974
with:
9075
toolchain: ${{ matrix.build.TOOLCHAIN }}
91-
target: ${{ matrix.build.TARGET }}
92-
override: true
93-
- name: Build Python wheels (linux)
94-
if: startsWith(matrix.build.NAME, 'linux')
95-
uses: PyO3/maturin-action@v1
96-
with:
97-
working-directory: pypi
98-
target: ${{ matrix.build.TARGET }}
99-
args: --release --sdist --out wheels
100-
sccache: "true"
101-
# https://github.com/PyO3/maturin-action/issues/245
102-
manylinux: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' && '2_28' || 'auto' }}
103-
- name: Build Python wheels (macos & windows)
104-
if: |
105-
(startsWith(matrix.build.OS, 'macos') || startsWith(matrix.build.OS, 'windows'))
106-
uses: PyO3/maturin-action@v1
107-
with:
108-
working-directory: pypi
109-
target: ${{ matrix.build.TARGET }}
110-
args: --release --sdist --out wheels
111-
sccache: "true"
112-
- name: Build Python wheels (musl)
113-
if: endsWith(matrix.build.OS, 'musl')
114-
uses: PyO3/maturin-action@v1
115-
with:
116-
working-directory: pypi
117-
target: ${{ matrix.build.TARGET }}
118-
args: --release --sdist --out wheels
119-
sccache: "true"
120-
manylinux: musllinux_1_2
121-
- name: Upload Python wheels
122-
uses: actions/upload-artifact@v4
76+
targets: ${{ matrix.build.TARGET }}
77+
78+
- name: Install uv
79+
uses: astral-sh/setup-uv@v7
12380
with:
124-
name: "wheels-${{ matrix.build.TARGET }}"
125-
working-directory: pypi
126-
path: pypi/wheels
81+
version: "0.9.22"
12782

128-
publish-pypi:
129-
name: Publish PyPI package
130-
runs-on: ubuntu-24.04
131-
needs: publish-binaries
132-
steps:
133-
- uses: actions/download-artifact@v4
83+
- name: Build Python wheels (linux x86-64 with sdist)
84+
if: matrix.build.TARGET == 'x86_64-unknown-linux-gnu'
85+
working-directory: pypi
86+
run: |
87+
uv build --wheel --sdist --out-dir dist
88+
89+
- name: Build Python wheels (other platforms)
90+
if: matrix.build.TARGET != 'x86_64-unknown-linux-gnu'
91+
working-directory: pypi
92+
run: |
93+
uv build --wheel --out-dir dist
94+
95+
- name: Install uv
96+
uses: astral-sh/setup-uv@v7
13497
with:
135-
path: pypi/wheels
136-
pattern: wheels-*
137-
merge-multiple: true
98+
version: "0.9.22"
99+
138100
- name: Publish to PyPI
139-
uses: PyO3/maturin-action@v1
140-
env:
141-
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
142-
MATURIN_REPOSITORY: 'pypi'
143-
with:
144-
command: upload
145-
args: --skip-existing pypi/wheels/*
101+
run: uv publish --trusted-publishing always pypi/dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ target
2424
# Added by cargo
2525

2626
/target
27+
.DS_Store

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "celq"
33
description = "A CEL command-line query tool for JSON data"
4-
version = "0.1.1-alpha.7"
4+
version = "0.1.1-alpha.8"
55
edition = "2024"
66
rust-version = "1.90"
77
authors = ["Ivan Carvalho <ivancarvalho@gatech.edu>"]

pypi/LICENSE-APACHE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-APACHE

pypi/LICENSE-MIT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-MIT

0 commit comments

Comments
 (0)