Debian Codegraph @

.github/workflows/ci-cd.yml

raw symbols SCIP
1 # Used guide from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2 name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
3 on: push
4 jobs:
5
6
7 build:
8 name: Build distribution 📦
9 runs-on: ubuntu-latest
10 steps:
11 - uses: actions/checkout@v4
12 - name: Set up Python
13 uses: actions/setup-python@v5
14 with:
15 python-version: "3.x"
16 - name: Install pypa/build
17 run: >-
18 python3 -m
19 pip install
20 build
21 --user
22 - name: Build a binary wheel and a source tarball
23 run: python3 -m build
24 - name: Store the distribution packages
25 uses: actions/upload-artifact@v4
26 with:
27 name: python-package-distributions
28 path: dist/
29
30
31 publish-to-pypi:
32 name: >-
33 Publish Python 🐍 distribution 📦 to PyPI
34 if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
35 needs:
36 - build
37 runs-on: ubuntu-latest
38 environment:
39 name: pypi
40 url: https://pypi.org/p/igloohome-api # Replace <package-name> with your PyPI project name
41 permissions:
42 id-token: write # IMPORTANT: mandatory for trusted publishing
43 steps:
44 - name: Download all the dists
45 uses: actions/download-artifact@v4
46 with:
47 name: python-package-distributions
48 path: dist/
49 - name: Publish distribution 📦 to PyPI
50 uses: pypa/gh-action-pypi-publish@release/v1
51
52
53 github-release:
54 name: >-
55 Sign the Python 🐍 distribution 📦 with Sigstore
56 and upload them to GitHub Release
57 needs:
58 - publish-to-pypi
59 runs-on: ubuntu-latest
60 permissions:
61 contents: write # IMPORTANT: mandatory for making GitHub Releases
62 id-token: write # IMPORTANT: mandatory for sigstore
63 steps:
64 - name: Download all the dists
65 uses: actions/download-artifact@v4
66 with:
67 name: python-package-distributions
68 path: dist/
69 - name: Sign the dists with Sigstore
70 uses: sigstore/[email protected]
71 with:
72 inputs: >-
73 ./dist/*.tar.gz
74 ./dist/*.whl
75 - name: Create GitHub Release
76 env:
77 GITHUB_TOKEN: ${{ github.token }}
78 run: >-
79 gh release create
80 '${{ github.ref_name }}'
81 --repo '${{ github.repository }}'
82 --notes ""
83 - name: Upload artifact signatures to GitHub Release
84 env:
85 GITHUB_TOKEN: ${{ github.token }}
86 # Upload to GitHub Release using the `gh` CLI.
87 # `dist/` contains the built packages, and the
88 # sigstore-produced signatures and certificates.
89 run: >-
90 gh release upload
91 '${{ github.ref_name }}' dist/**
92 --repo '${{ github.repository }}'
93
94
95 publish-to-testpypi:
96 name: Publish Python 🐍 distribution 📦 to TestPyPI
97 if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
98 needs:
99 - build
100 runs-on: ubuntu-latest
101 environment:
102 name: testpypi
103 url: https://test.pypi.org/p/igloohome-api
104 permissions:
105 id-token: write # IMPORTANT: mandatory for trusted publishing
106 steps:
107 - name: Download all the dists
108 uses: actions/download-artifact@v4
109 with:
110 name: python-package-distributions
111 path: dist/
112 - name: Publish distribution 📦 to TestPyPI
113 uses: pypa/gh-action-pypi-publish@release/v1
114 with:
115 repository-url: https://test.pypi.org/legacy/