Skip to content

Commit 4e903ac

Browse files
committed
merge #83 into openSUSE/libpathrs:main
Aleksa Sarai (5): gha: python: automate PyPI release of python bindings gha: run workflows on tag pushes gha: python: split build from smoke-tests gha: python: run twine check gha: python: test more versions LGTMs: cyphar
2 parents 46aebf4 + b999d01 commit 4e903ac

File tree

4 files changed

+79
-7
lines changed

4 files changed

+79
-7
lines changed

.github/workflows/bindings-c.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
on:
1818
push:
1919
branches: [ main ]
20+
tags:
21+
- 'v*'
2022
pull_request:
2123
branches: [ main ]
2224
release:

.github/workflows/bindings-go.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
on:
1818
push:
1919
branches: [ main ]
20+
tags:
21+
- 'v*'
2022
pull_request:
2123
branches: [ main ]
2224
release:

.github/workflows/bindings-python.yml

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717
on:
1818
push:
1919
branches: [ main ]
20+
tags:
21+
- 'v*'
2022
pull_request:
2123
branches: [ main ]
2224
release:
2325
types: [ published ]
2426
schedule:
2527
- cron: '0 0 * * *'
2628

29+
env:
30+
PYTHON_DIST: ${{ github.workspace }}/.tmp/python3-pathrs-${{ github.run_id }}-${{ github.run_attempt }}
31+
2732
name: bindings-python
2833

2934
jobs:
@@ -66,11 +71,11 @@ jobs:
6671
workdir: contrib/bindings/python/pathrs
6772
fail_on_error: true
6873

69-
smoke-test:
74+
build-pyproject:
7075
strategy:
7176
fail-fast: false
7277
matrix:
73-
python-version: ["3.8", "3.10", "3.12"]
78+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.x"]
7479
runs-on: ubuntu-latest
7580
steps:
7681
- uses: actions/checkout@v4
@@ -86,11 +91,12 @@ jobs:
8691
python-version: ${{ matrix.python-version }}
8792
- name: install pypa/build
8893
run: >-
89-
python3 -m pip install --user build
94+
python3 -m pip install --user build twine
9095
# Build and install our bindings.
91-
- name: build python-libpathrs bindings
96+
- name: build python-pathrs bindings
9297
run: make -C contrib/bindings/python dist
93-
- name: install python-libpathrs bindings
98+
- run: twine check contrib/bindings/python/dist/*
99+
- name: install python-pathrs bindings
94100
run: make -C contrib/bindings/python install
95101
# Verify that the crate and python bindings have the same version.
96102
# TODO: Move this to a "make check" we can run locally as well.
@@ -104,19 +110,79 @@ jobs:
104110
105111
[[ "$CRATE_VERSION" == "$PY_VERSION" ]] || exit 1
106112
# Include the dist/ in our artefacts.
107-
- name: upload python-libpathrs bindings dist/
113+
- name: upload python-pathrs bindings dist/
108114
uses: actions/upload-artifact@v4
109115
with:
110-
name: python-${{ matrix.python-version }}-libpathrs-dist
116+
name: python-${{ matrix.python-version }}-pathrs-dist
111117
path: contrib/bindings/python/dist/
118+
119+
smoke-test:
120+
strategy:
121+
fail-fast: false
122+
matrix:
123+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.x"]
124+
needs:
125+
- build-pyproject
126+
runs-on: ubuntu-latest
127+
steps:
128+
- uses: actions/checkout@v4
129+
# Build and install libpathrs.so.
130+
- uses: dtolnay/rust-toolchain@stable
131+
- name: build libpathrs
132+
run: make release
133+
- name: install libpathrs
134+
run: sudo ./install.sh --libdir=/usr/lib
135+
# Set up python venv.
136+
- uses: actions/setup-python@v5
137+
with:
138+
python-version: ${{ matrix.python-version }}
139+
# Download the pre-built python dist.
140+
- name: download built python-pathrs
141+
uses: actions/download-artifact@v4
142+
with:
143+
name: python-${{ matrix.python-version }}-pathrs-dist
144+
path: ${{ env.PYTHON_DIST }}
145+
- name: install python-pathrs
146+
run: |-
147+
python3 -m pip install ${{ env.PYTHON_DIST }}/*.whl
112148
# Run smoke-tests.
113149
- run: make -C examples/python smoke-test
114150

151+
# TODO: Should we move this to a separate workflow?
152+
release-pypi:
153+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
154+
needs:
155+
- build-pyproject
156+
runs-on: ubuntu-latest
157+
environment:
158+
name: release-pypi
159+
url: "https://pypi.org/p/pathrs"
160+
permissions:
161+
id-token: write
162+
steps:
163+
- name: download built python-pathrs
164+
uses: actions/download-artifact@v4
165+
with:
166+
name: python-3.x-pathrs-dist
167+
path: ${{ env.PYTHON_DIST }}
168+
# PyPI doesn't let us upload our native wheel because we aren't building
169+
# using the restrictive manylinux set of libraries (because we depend on
170+
# libpathrs.so).
171+
- name: remove wheel from python-pathrs
172+
run: rm -fv ${{ env.PYTHON_DIST }}/*.whl
173+
- name: upload python-pathrs to pypi
174+
uses: pypa/gh-action-pypi-publish@release/v1
175+
with:
176+
packages-dir: ${{ env.PYTHON_DIST }}
177+
115178
complete:
179+
if: ${{ ! failure() && ! cancelled() }}
116180
needs:
117181
- black
118182
- mypy
183+
- build-pyproject
119184
- smoke-test
185+
- release-pypi
120186
runs-on: ubuntu-latest
121187
steps:
122188
- run: echo "Python CI jobs completed successfully."

.github/workflows/rust.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
on:
1818
push:
1919
branches: [ main ]
20+
tags:
21+
- 'v*'
2022
pull_request:
2123
branches: [ main ]
2224
release:

0 commit comments

Comments
 (0)