|
1 | 1 | on:
|
2 | 2 | push:
|
3 | 3 | branches:
|
4 |
| - - main |
5 | 4 | - master
|
6 | 5 | - develop
|
7 | 6 | pull_request:
|
@@ -242,3 +241,98 @@ jobs:
|
242 | 241 | run: |
|
243 | 242 | export PATH=~/castxml/bin:$PATH
|
244 | 243 | pytest tests
|
| 244 | +
|
| 245 | + build: |
| 246 | + name: Build distribution 📦 |
| 247 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 248 | + needs: tests |
| 249 | + runs-on: ubuntu-latest |
| 250 | + |
| 251 | + steps: |
| 252 | + - uses: actions/checkout@v4 |
| 253 | + with: |
| 254 | + persist-credentials: false |
| 255 | + - name: Set up Python |
| 256 | + uses: actions/setup-python@v5 |
| 257 | + with: |
| 258 | + python-version: "3.x" |
| 259 | + |
| 260 | + - name: Install pypa/build |
| 261 | + run: >- |
| 262 | + python3 -m |
| 263 | + pip install |
| 264 | + build |
| 265 | + --user |
| 266 | + - name: Build a binary wheel and a source tarball |
| 267 | + run: python3 -m build |
| 268 | + - name: Store the distribution packages |
| 269 | + uses: actions/upload-artifact@v4 |
| 270 | + with: |
| 271 | + name: python-package-distributions |
| 272 | + path: dist/ |
| 273 | + |
| 274 | + publish-to-pypi: |
| 275 | + name: >- |
| 276 | + Publish Python 🐍 distribution 📦 to PyPI |
| 277 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 278 | + needs: |
| 279 | + - build |
| 280 | + runs-on: ubuntu-latest |
| 281 | + environment: |
| 282 | + name: pypi |
| 283 | + url: https://pypi.org/p/<package-name> # Replace <package-name> with your PyPI project name |
| 284 | + permissions: |
| 285 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 286 | + |
| 287 | + steps: |
| 288 | + - name: Download all the dists |
| 289 | + uses: actions/download-artifact@v4 |
| 290 | + with: |
| 291 | + name: python-package-distributions |
| 292 | + path: dist/ |
| 293 | + - name: Publish distribution 📦 to PyPI |
| 294 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 295 | + |
| 296 | + github-release: |
| 297 | + name: >- |
| 298 | + Sign the Python 🐍 distribution 📦 with Sigstore |
| 299 | + and upload them to GitHub Release |
| 300 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 301 | + needs: |
| 302 | + - publish-to-pypi |
| 303 | + runs-on: ubuntu-latest |
| 304 | + |
| 305 | + permissions: |
| 306 | + contents: write # IMPORTANT: mandatory for making GitHub Releases |
| 307 | + id-token: write # IMPORTANT: mandatory for sigstore |
| 308 | + |
| 309 | + steps: |
| 310 | + - name: Download all the dists |
| 311 | + uses: actions/download-artifact@v4 |
| 312 | + with: |
| 313 | + name: python-package-distributions |
| 314 | + path: dist/ |
| 315 | + - name: Sign the dists with Sigstore |
| 316 | + uses: sigstore/gh-action-sigstore-python@v3.0.0 |
| 317 | + with: |
| 318 | + inputs: >- |
| 319 | + ./dist/*.tar.gz |
| 320 | + ./dist/*.whl |
| 321 | + - name: Create GitHub Release |
| 322 | + env: |
| 323 | + GITHUB_TOKEN: ${{ github.token }} |
| 324 | + run: >- |
| 325 | + gh release create |
| 326 | + "$GITHUB_REF_NAME" |
| 327 | + --repo "$GITHUB_REPOSITORY" |
| 328 | + --notes "" |
| 329 | + - name: Upload artifact signatures to GitHub Release |
| 330 | + env: |
| 331 | + GITHUB_TOKEN: ${{ github.token }} |
| 332 | + # Upload to GitHub Release using the `gh` CLI. |
| 333 | + # `dist/` contains the built packages, and the |
| 334 | + # sigstore-produced signatures and certificates. |
| 335 | + run: >- |
| 336 | + gh release upload |
| 337 | + "$GITHUB_REF_NAME" dist/** |
| 338 | + --repo "$GITHUB_REPOSITORY" |
0 commit comments