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
0 commit comments