Skip to content

Commit d4c4ee1

Browse files
committed
CI: add test pypi release
1 parent 644bf2c commit d4c4ee1

3 files changed

Lines changed: 173 additions & 0 deletions

File tree

.github/workflows/pypi-release.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Python Package
2+
3+
on:
4+
push:
5+
branches: ["*"]
6+
pull_request:
7+
branches: ["*"]
8+
release:
9+
types: [published]
10+
workflow_dispatch: # Allow manual triggering
11+
12+
jobs:
13+
build-wheels:
14+
name: Build wheels on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Set up Docker Buildx (Linux only)
31+
if: runner.os == 'Linux'
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
python -m pip install cibuildwheel
38+
39+
- name: Sync Python version
40+
run: python scripts/sync_python_version.py
41+
42+
- name: Build main libCacheSim library
43+
run: |
44+
sudo apt-get update && sudo apt-get install -y cmake ninja-build libglib2.0-dev || true
45+
brew install cmake ninja glib || true
46+
rm -rf ./build
47+
cmake -G Ninja -B build
48+
ninja -C build
49+
50+
- name: Verify Docker (Linux only)
51+
if: runner.os == 'Linux'
52+
run: |
53+
docker --version
54+
docker info
55+
echo "Docker is ready for cibuildwheel"
56+
57+
- name: Build wheels
58+
env:
59+
CIBW_SKIP: "*-musllinux* *-manylinux_i686"
60+
CIBW_ARCHS_LINUX: "x86_64"
61+
CIBW_BEFORE_ALL_LINUX: |
62+
yum install -y yum-utils && yum-config-manager --set-enabled crb && yum install -y ninja-build cmake libzstd-devel glib2-devel
63+
CIBW_TEST_COMMAND: "python -c 'import libcachesim; print(\"Import successful\")'"
64+
run: python -m cibuildwheel libCacheSim-python --output-dir wheelhouse
65+
66+
- name: Upload wheels as artifacts
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: wheels-${{ matrix.os }}
70+
path: wheelhouse/*.whl
71+
72+
build-sdist:
73+
name: Build source distribution
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
with:
78+
submodules: recursive
79+
80+
- name: Set up Python
81+
uses: actions/setup-python@v4
82+
with:
83+
python-version: '3.11'
84+
85+
- name: Install build dependencies
86+
run: |
87+
python -m pip install --upgrade pip
88+
python -m pip install build
89+
90+
- name: Sync Python version
91+
run: python scripts/sync_python_version.py
92+
93+
- name: Build source distribution
94+
run: python -m build --sdist libCacheSim-python --outdir dist/
95+
96+
- name: Upload sdist as artifact
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: sdist
100+
path: dist/*.tar.gz
101+
102+
publish-to-pypi:
103+
name: Publish to PyPI
104+
needs: [build-wheels, build-sdist]
105+
runs-on: ubuntu-latest
106+
# if: github.event_name == 'release' && github.event.action == 'published'
107+
environment:
108+
name: pypi
109+
url: https://pypi.org/p/libcachesim
110+
permissions:
111+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
112+
113+
steps:
114+
- name: Download all artifacts
115+
uses: actions/download-artifact@v4
116+
with:
117+
path: dist/
118+
119+
- name: Flatten artifacts directory
120+
run: |
121+
mkdir -p final-dist
122+
find dist/ -name "*.whl" -exec cp {} final-dist/ \;
123+
find dist/ -name "*.tar.gz" -exec cp {} final-dist/ \;
124+
ls -la final-dist/
125+
126+
- name: Publish to PyPI
127+
uses: pypa/gh-action-pypi-publish@release/v1
128+
with:
129+
packages-dir: final-dist/
130+
skip-existing: true
131+
132+
publish-to-test-pypi:
133+
name: Publish to TestPyPI
134+
needs: [build-wheels, build-sdist]
135+
runs-on: ubuntu-latest
136+
environment:
137+
name: testpypi
138+
url: https://test.pypi.org/p/libcachesim
139+
permissions:
140+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
141+
142+
steps:
143+
- name: Download all artifacts
144+
uses: actions/download-artifact@v4
145+
with:
146+
path: dist/
147+
148+
- name: Flatten artifacts directory
149+
run: |
150+
mkdir -p final-dist
151+
find dist/ -name "*.whl" -exec cp {} final-dist/ \;
152+
find dist/ -name "*.tar.gz" -exec cp {} final-dist/ \;
153+
ls -la final-dist/
154+
155+
- name: Publish to TestPyPI
156+
uses: pypa/gh-action-pypi-publish@release/v1
157+
with:
158+
repository-url: https://test.pypi.org/legacy/
159+
packages-dir: final-dist/
160+
skip-existing: true

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# libCacheSim - building and running cache simulations
22

33
[![build](https://github.com/1a1a11a/libCacheSim/actions/workflows/build.yml/badge.svg)](https://github.com/1a1a11a/libCacheSim/actions/workflows/build.yml)
4+
[![Python-package GitHub Actions Build Status](https://github.com/1a1a11a/libCacheSim/actions/workflows/pypi-release.yml/badge.svg)](https://github.com/1a1a11a/libCacheSim/actions/workflows/pypi-release.yml)
5+
[![Python Versions](https://img.shields.io/pypi/pyversions/libcachesim.svg?logo=python&logoColor=white)](https://pypi.org/project/libcachesim)
6+
[![PyPI Version](https://img.shields.io/pypi/v/libcachesim.svg?logo=pypi&logoColor=white)](https://pypi.org/project/libcachesim)
47
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/1a1a11a/libCacheSim/badge)](https://scorecard.dev/viewer/?uri=github.com/1a1a11a/libCacheSim)
58

9+
610
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
711
- [libCacheSim - building and running cache simulations](#libcachesim---building-and-running-cache-simulations)
812
- [News](#news)

libCacheSim-python/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ version = "0.3.1"
99
description="Python bindings for libCacheSim"
1010
readme = "README.md"
1111
requires-python = ">=3.9"
12+
keywords = ["performance", "cache", "simulator"]
13+
classifiers = [
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
]
1221

1322
[project.optional-dependencies]
1423
test = ["pytest"]

0 commit comments

Comments
 (0)