-
Notifications
You must be signed in to change notification settings - Fork 1
43 lines (35 loc) · 1.38 KB
/
python-publish.yml
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: Upload Python Package
# Trigger the workflow on push to any tag that starts with "v"
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest # Use the latest Ubuntu environment
steps:
# Step 1: Check out the repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x' # Specify the Python version
# Step 3: Install dependencies for building and uploading the package
- name: Install build dependencies
run: |
python -m pip install --upgrade pip # Upgrade pip
pip install build twine # Install build and twine
# Step 4: Build the package
- name: Build the package
run: python -m build # Build source and wheel distributions
# Step 5: List files in the dist directory for debugging
- name: List files for debugging
run: ls -l dist # List the contents of the dist directory
# Step 6: Publish the package to PyPI
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__ # Use __token__ for authentication
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} # Use the PyPI API token stored as a secret
run: twine upload dist/* # Upload the built distributions to PyPI