-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (35 loc) · 1.02 KB
/
python-publish.yml
File metadata and controls
43 lines (35 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Build and Publish to PyPI
on:
release:
types: [created]
workflow_dispatch: # Allow manual triggering
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for setuptools_scm to read version from git history
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
# Build the package
python -m build
# Check the dist directory
ls -la dist/
# Upload to PyPI if credentials are provided
if [ -n "$TWINE_USERNAME" ] && [ -n "$TWINE_PASSWORD" ]; then
twine upload dist/*
else
echo "PyPI credentials not provided. Skipping upload."
fi