Skip to content

Commit 240980a

Browse files
committed
Add GitHub Actions workflow to publish to PyPI
Add .github/workflows/publish.yml to automatically build and publish the package when a release is published. The workflow runs on ubuntu-latest, sets up Python 3.12, installs build tools, creates distributions into dist/, uploads the built artifacts, and then downloads and publishes them to PyPI using pypa/gh-action-pypi-publish. The publish job is configured with an environment for PyPI and uses id-token: write for OIDC-based trusted publishing.
1 parent 6235a38 commit 240980a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/publish.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
17+
- name: Install build tools
18+
run: pip install build
19+
20+
- name: Build package
21+
run: python -m build
22+
23+
- name: Upload distributions
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: dist
27+
path: dist/
28+
29+
publish:
30+
needs: build
31+
runs-on: ubuntu-latest
32+
environment:
33+
name: pypi
34+
url: https://pypi.org/p/brainstem_python_api_tools
35+
permissions:
36+
id-token: write # required for trusted publishing (OIDC)
37+
38+
steps:
39+
- name: Download distributions
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: dist
43+
path: dist/
44+
45+
- name: Publish to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)