Skip to content

Commit f6a3e3e

Browse files
authored
ci-cd: add workflow for publishing to PyPI
1 parent e8f549a commit f6a3e3e

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
release-build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.14.5"
20+
21+
- name: Build release distributions
22+
run: |
23+
python -m pip install build
24+
python -m build
25+
26+
- name: Upload distributions
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: release-dists
30+
path: dist/
31+
32+
pypi-publish:
33+
runs-on: ubuntu-latest
34+
needs:
35+
- release-build
36+
permissions:
37+
# IMPORTANT: this permission is mandatory for trusted publishing
38+
id-token: write
39+
40+
# Dedicated environments with protections for publishing are strongly recommended.
41+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
42+
environment:
43+
name: pypi
44+
url: https://pypi.org/project/chef-package-manager/${{ github.event.release.name }}
45+
46+
steps:
47+
- name: Retrieve release distributions
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: release-dists
51+
path: dist/
52+
53+
- name: Publish release distributions to PyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
with:
56+
packages-dir: dist/

0 commit comments

Comments
 (0)