Skip to content

Commit 7d65915

Browse files
Add GitHub Actions workflow for PyPI publishing
Supports: - TestPyPI publishing via workflow_dispatch - PyPI publishing on release - OIDC trusted publisher (no tokens needed) Signed-off-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Deborah Jacob <deborah@botanu.ai>
1 parent 4704d3c commit 7d65915

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

.github/workflows/publish.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# SPDX-FileCopyrightText: 2026 The Botanu Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Publish to PyPI
5+
6+
on:
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
inputs:
11+
target:
12+
description: 'Target repository'
13+
required: true
14+
default: 'testpypi'
15+
type: choice
16+
options:
17+
- testpypi
18+
- pypi
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: "3.12"
34+
35+
- name: Install build dependencies
36+
run: pip install build
37+
38+
- name: Build package
39+
run: python -m build
40+
41+
- name: Upload artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: dist
45+
path: dist/
46+
47+
publish-testpypi:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi'
51+
environment: testpypi
52+
permissions:
53+
id-token: write
54+
steps:
55+
- name: Download artifacts
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: dist
59+
path: dist/
60+
61+
- name: Publish to TestPyPI
62+
uses: pypa/gh-action-pypi-publish@release/v1
63+
with:
64+
repository-url: https://test.pypi.org/legacy/
65+
66+
publish-pypi:
67+
needs: build
68+
runs-on: ubuntu-latest
69+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi')
70+
environment: pypi
71+
permissions:
72+
id-token: write
73+
steps:
74+
- name: Download artifacts
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: dist
78+
path: dist/
79+
80+
- name: Publish to PyPI
81+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)