Skip to content

Commit 42e8574

Browse files
authored
Prepare release v0.3.3 (#18)
* Clean up * Add publish workflow
1 parent fe29635 commit 42e8574

File tree

4 files changed

+155
-7
lines changed

4 files changed

+155
-7
lines changed

.github/workflows/pypi-release.yml

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

examples/plugin_cache/s3fifo.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,7 @@ def cache_remove_hook(cache, obj_id):
171171
cache.cache_remove(obj_id)
172172

173173
def cache_free_hook(cache):
174-
cache.small_fifo.clear()
175-
cache.small_freq.clear()
176-
cache.ghost_fifo.clear()
177-
cache.ghost_freq.clear()
178-
cache.main_fifo.clear()
179-
cache.main_freq.clear()
174+
pass
180175

181176
cache = PluginCache(
182177
cache_size=1024,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build-backend = "scikit_build_core.build"
99

1010
[project]
1111
name = "libcachesim"
12-
version = "0.3.2"
12+
version = "0.3.3"
1313
description="Python bindings for libCacheSim"
1414
readme = "README.md"
1515
requires-python = ">=3.9"

scripts/sync_version.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def update_pyproject_toml(version):
6060
if current_version == version:
6161
print(f"Python binding version already up to date: {version}")
6262
return False
63+
# If the pyproject version is newer than version.txt, it is allowed.
64+
if current_version > version:
65+
print(f"Warning: pyproject version {current_version} is newer than version.txt {version}, skipping update")
66+
return False
6367
# replace the version line with the new version
6468
pyproject_data = re.sub(r"version = \"(dev|[0-9]+\.[0-9]+\.[0-9]+)\"", f'version = "{version}"', pyproject_data)
6569

0 commit comments

Comments
 (0)