Skip to content

Commit dd7940e

Browse files
authored
Add PyPI publication workflow. (#390)
1 parent 8cb688f commit dd7940e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/publish.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Upload package
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.13'
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -U build twine
22+
- name: Build package
23+
run: |
24+
python -m build
25+
- name: Publish package
26+
env:
27+
TWINE_USERNAME: "__token__"
28+
run: |
29+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
30+
export TWINE_REPOSITORY="testpypi"
31+
export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}"
32+
elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
33+
export TWINE_REPOSITORY="pypi"
34+
export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}"
35+
else
36+
echo "Unknown event name: ${GITHUB_EVENT_NAME}"
37+
exit 1
38+
fi
39+
python -m twine upload dist/*

0 commit comments

Comments
 (0)