Debian Codegraph @

.github/workflows/build-n-publish-to-pypi.yml

raw symbols SCIP
1 # link: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2 name: publish 📦 to PyPI
3
4 # Build on every branch push, tag push, and pull request change
5 on:
6 push:
7 branches:
8 - main
9 tags:
10 - v*
11 pull_request:
12
13 jobs:
14 build-sdist-n-wheel:
15 name: Build 🐍 distributions and wheels 📦
16 runs-on: ubuntu-latest
17 steps:
18
19 - uses: actions/checkout@v5
20 with:
21 fetch-depth: 0
22
23 - name: Set up Python 3.10
24 uses: actions/setup-python@v6
25 with:
26 python-version: "3.10"
27
28 - name: Install pypa/build
29 run: >-
30 python -m
31 pip install
32 build
33 --user
34
35 - name: Build a source tarball and a binary wheel
36 run: >-
37 python -m
38 build
39 --sdist
40 --wheel
41 --outdir dist/
42 .
43
44 - uses: actions/upload-artifact@v5
45 with:
46 path: |
47 dist/*.tar.gz
48 dist/*.whl
49
50 upload-to-pypi:
51 name: Upload 📦 to (Test) PyPI
52 needs: [build-sdist-n-wheel]
53 runs-on: ubuntu-latest
54 if: github.repository_owner == 'insarlab' && github.event_name == 'push'
55 steps:
56
57 - uses: actions/download-artifact@v6
58 with:
59 # unpacks default artifact into dist/
60 # if `name: artifact` is omitted, the action will create extra parent dir
61 name: artifact
62 path: dist
63
64 - name: Publish developed version 📦 to Test PyPI
65 if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
66 uses: pypa/gh-action-pypi-publish@release/v1
67 with:
68 password: ${{ secrets.TEST_PYPI_API_TOKEN }}
69 repository_url: https://test.pypi.org/legacy/
70 skip_existing: false
71 verbose: true
72
73 - name: Publish released version 📦 to PyPI
74 if: startsWith(github.ref, 'refs/tags/v')
75 uses: pypa/gh-action-pypi-publish@release/v1
76 with:
77 password: ${{ secrets.PYPI_API_TOKEN }}
78 verbose: true