Skip to content

Commit 935b6cf

Browse files
committed
ci: setup PyPI publishing workflow
1 parent f774b6f commit 935b6cf

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

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

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
build:
10+
name: Build distribution 📦
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
persist-credentials: false
17+
- uses: astral-sh/setup-uv@v5
18+
with:
19+
python-version: 3.11
20+
- name: Build a binary wheel and a source tarball
21+
run: uv build
22+
- name: Store the distribution packages
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: python-package-distributions
26+
path: dist/
27+
28+
publish-to-pypi:
29+
name: >-
30+
Publish Python 🐍 distribution 📦 to PyPI
31+
needs:
32+
- build
33+
runs-on: ubuntu-latest
34+
environment:
35+
name: pypi
36+
url: https://pypi.org/p/mcp-search-linkup
37+
permissions:
38+
id-token: write # IMPORTANT: mandatory for trusted publishing
39+
40+
steps:
41+
- name: Download all the dists
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
- name: Publish distribution 📦 to PyPI
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
49+
github-release:
50+
name: >-
51+
Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release
52+
needs:
53+
- publish-to-pypi
54+
runs-on: ubuntu-latest
55+
56+
permissions:
57+
contents: write # IMPORTANT: mandatory for making GitHub Releases
58+
id-token: write # IMPORTANT: mandatory for sigstore
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/[email protected]
68+
with:
69+
inputs: >-
70+
./dist/*.tar.gz ./dist/*.whl
71+
- name: Create GitHub Release
72+
env:
73+
GITHUB_TOKEN: ${{ github.token }}
74+
run: >-
75+
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --notes ""
76+
- name: Upload artifact signatures to GitHub Release
77+
env:
78+
GITHUB_TOKEN: ${{ github.token }}
79+
# Upload to GitHub Release using the `gh` CLI.
80+
# `dist/` contains the built packages, and the
81+
# sigstore-produced signatures and certificates.
82+
run: >-
83+
gh release upload "$GITHUB_REF_NAME" dist/** --repo "$GITHUB_REPOSITORY"

0 commit comments

Comments
 (0)