Skip to content

Commit 03cf126

Browse files
committed
Added PyPi publishing step
1 parent 66b8b49 commit 03cf126

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution 📦
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Python
12+
uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.x"
15+
- name: Install pypa/build
16+
run: >-
17+
python3 -m
18+
pip install
19+
build
20+
--user
21+
- name: Build a binary wheel and a source tarball
22+
run: python3 -m build
23+
- name: Store the distribution packages
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: python-package-distributions
27+
path: dist/
28+
29+
publish-to-pypi:
30+
name: Publish Python 🐍 distribution 📦 to PyPI
31+
if: startsWith(github.ref, 'refs/tags/')
32+
needs:
33+
- build
34+
runs-on: ubuntu-latest
35+
environment:
36+
name: pypi
37+
url: https://pypi.org/p/libloader
38+
permissions:
39+
id-token: write
40+
41+
steps:
42+
- name: Download all the dists
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: python-package-distributions
46+
path: dist/
47+
- name: Publish distribution 📦 to PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
50+
github-release:
51+
name: Sign the Python 🐍 distribution 📦 with Sigstore and upload to GitHub Release
52+
if: startsWith(github.ref, 'refs/tags/') # Only run for tagged releases
53+
needs:
54+
- publish-to-pypi
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: write
58+
id-token: write
59+
60+
steps:
61+
- name: Download all the dists
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: python-package-distributions
65+
path: dist/
66+
- name: Sign the dists with Sigstore
67+
uses: sigstore/gh-action-sigstore-python@v3.0.0
68+
with:
69+
inputs: >-
70+
./dist/*.tar.gz
71+
./dist/*.whl
72+
- name: Create GitHub Release
73+
env:
74+
GITHUB_TOKEN: ${{ github.token }}
75+
run: >-
76+
gh release create
77+
'${{ github.ref_name }}'
78+
--repo '${{ github.repository }}'
79+
--notes ""
80+
- name: Upload artifact signatures to GitHub Release
81+
env:
82+
GITHUB_TOKEN: ${{ github.token }}
83+
run: >-
84+
gh release upload
85+
'${{ github.ref_name }}' dist/**
86+
--repo '${{ github.repository }}'

0 commit comments

Comments
 (0)