Skip to content

Commit 6b29f60

Browse files
authored
ci: add python release pipeline (#212)
1 parent e8c98d9 commit 6b29f60

2 files changed

Lines changed: 116 additions & 11 deletions

File tree

.github/workflows/release-rust.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
# Trigger: push a version tag (e.g. v0.1.0, v0.1.0-rc1).
2121
# Pre-release tags (containing '-') only run dry-run checks without publishing.
2222
#
23-
# Auth: set repo variable CARGO_USE_TOKEN_AUTH = 'true' and add secret CARGO_REGISTRY_TOKEN
24-
# for token-based auth. Otherwise, Trusted Publishing (OIDC) is used.
23+
# Token auth: add secret CARGO_REGISTRY_TOKEN for crates.io publishing.
2524

2625
name: Release Rust
2726

@@ -37,7 +36,6 @@ jobs:
3736
runs-on: ubuntu-latest
3837
permissions:
3938
contents: read
40-
id-token: write
4139
strategy:
4240
# Publish crates sequentially to respect dependency order
4341
max-parallel: 1
@@ -55,15 +53,8 @@ jobs:
5553
- name: Dry run
5654
run: cargo publish -p ${{ matrix.package }} --all-features --dry-run
5755

58-
- name: Get crates.io token (OIDC)
59-
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-') && vars.CARGO_USE_TOKEN_AUTH != 'true'
60-
uses: rust-lang/crates-io-auth-action@v1
61-
id: auth
62-
with:
63-
token-type: publish
64-
6556
- name: Publish ${{ matrix.package }} to crates.io
6657
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-')
6758
run: cargo publish -p ${{ matrix.package }} --all-features
6859
env:
69-
CARGO_REGISTRY_TOKEN: "${{ vars.CARGO_USE_TOKEN_AUTH == 'true' && secrets.CARGO_REGISTRY_TOKEN || steps.auth.outputs.token }}"
60+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# Publish the paimon Python binding to PyPI.
19+
# Trigger: push tag only (e.g. v0.1.0).
20+
# Pre-release tags (containing '-') publish to TestPyPI; release tags publish to PyPI.
21+
#
22+
# Token auth: add secrets PYPI_API_TOKEN / TEST_PYPI_API_TOKEN for publishing.
23+
24+
name: Release Python Binding
25+
26+
on:
27+
push:
28+
tags:
29+
- "v[0-9]+.[0-9]+.[0-9]+"
30+
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
31+
workflow_dispatch:
32+
33+
concurrency:
34+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
35+
cancel-in-progress: true
36+
37+
permissions:
38+
contents: read
39+
40+
jobs:
41+
sdist:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v6
45+
46+
- uses: PyO3/maturin-action@v1
47+
with:
48+
working-directory: bindings/python
49+
command: sdist
50+
args: -o dist
51+
52+
- name: Upload sdist
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: wheels-sdist
56+
path: bindings/python/dist
57+
58+
wheels:
59+
runs-on: ${{ matrix.os }}
60+
strategy:
61+
matrix:
62+
include:
63+
- { os: windows-latest }
64+
- { os: macos-15-intel, target: "x86_64-apple-darwin" }
65+
- { os: macos-latest, target: "aarch64-apple-darwin" }
66+
- { os: ubuntu-latest, target: "x86_64" }
67+
- { os: ubuntu-latest, target: "aarch64", manylinux: "manylinux_2_28" }
68+
steps:
69+
- uses: actions/checkout@v6
70+
71+
- uses: PyO3/maturin-action@v1
72+
with:
73+
working-directory: bindings/python
74+
target: ${{ matrix.target }}
75+
command: build
76+
args: --release -o dist
77+
manylinux: ${{ matrix.manylinux || 'auto' }}
78+
79+
- name: Upload wheels
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: wheels-${{ matrix.os }}-${{ matrix.target || 'native' }}
83+
path: bindings/python/dist
84+
85+
release:
86+
name: Publish to PyPI
87+
runs-on: ubuntu-latest
88+
permissions:
89+
contents: read
90+
needs: [sdist, wheels]
91+
if: startsWith(github.ref, 'refs/tags/')
92+
steps:
93+
- uses: actions/download-artifact@v4
94+
with:
95+
pattern: wheels-*
96+
merge-multiple: true
97+
path: bindings/python/dist
98+
99+
- name: Publish to TestPyPI
100+
if: contains(github.ref, '-')
101+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
102+
with:
103+
repository-url: https://test.pypi.org/legacy/
104+
skip-existing: true
105+
packages-dir: bindings/python/dist
106+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
107+
108+
- name: Publish to PyPI
109+
if: ${{ !contains(github.ref, '-') }}
110+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
111+
with:
112+
skip-existing: true
113+
packages-dir: bindings/python/dist
114+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)