Skip to content

Commit 224cefd

Browse files
authored
Merge pull request #9 from grafana/publish-from-gha
2 parents a03bf12 + ea4a1f8 commit 224cefd

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

.github/workflows/release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
persist-credentials: false
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v5
17+
with:
18+
# Install a specific version of uv.
19+
version: "0.5.13"
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version-file: "pyproject.toml"
25+
26+
- name: Build distribution 📦
27+
run: uv build
28+
29+
- name: Store the distribution packages
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: python-package-distributions
33+
path: dist/
34+
35+
publish-to-pypi:
36+
name: >-
37+
Publish Python 🐍 distribution 📦 to PyPI
38+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
39+
needs:
40+
- build
41+
runs-on: ubuntu-latest
42+
environment:
43+
name: pypi
44+
url: https://pypi.org/p/mcp-grafana
45+
permissions:
46+
id-token: write # IMPORTANT: mandatory for trusted publishing
47+
steps:
48+
- name: Download all the dists
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: python-package-distributions
52+
path: dist/
53+
54+
- name: Install uv
55+
uses: astral-sh/setup-uv@v5
56+
with:
57+
# Install a specific version of uv.
58+
version: "0.5.13"
59+
- name: Publish distribution 📦 to PyPI
60+
run: uv publish
61+
62+
publish-to-testpypi:
63+
name: Publish Python 🐍 distribution 📦 to TestPyPI
64+
needs:
65+
- build
66+
runs-on: ubuntu-latest
67+
68+
environment:
69+
name: testpypi
70+
url: https://test.pypi.org/p/mcp-grafana
71+
72+
permissions:
73+
id-token: write # IMPORTANT: mandatory for trusted publishing
74+
75+
steps:
76+
# We need to checkout the repository so that we can use the
77+
# testpypi index in pyproject.toml.
78+
- uses: actions/checkout@v4
79+
with:
80+
persist-credentials: false
81+
- name: Download all the dists
82+
uses: actions/download-artifact@v4
83+
with:
84+
name: python-package-distributions
85+
path: dist/
86+
87+
- name: Install uv
88+
uses: astral-sh/setup-uv@v5
89+
with:
90+
# Install a specific version of uv.
91+
version: "0.5.13"
92+
- name: Publish distribution 📦 to TestPyPI
93+
run: uv publish --index testpypi

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ build-backend = "hatchling.build"
3434

3535
[tool.pytest.ini_options]
3636
asyncio_default_fixture_loop_scope = "session"
37+
38+
[[tool.uv.index]]
39+
name = "pypi"
40+
url = "https://pypi.org/simple/"
41+
publish-url = "https://pypi.org/legacy/"
42+
43+
[[tool.uv.index]]
44+
name = "testpypi"
45+
url = "https://test.pypi.org/simple/"
46+
publish-url = "https://test.pypi.org/legacy/"

0 commit comments

Comments
 (0)