Skip to content

Update python-publish.yml #5

Update python-publish.yml

Update python-publish.yml #5

Workflow file for this run

name: Upload Python Package
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: Find and upload the latest distribution files
- 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: |
# Define the base name of your package
PACKAGE_NAME="numan_plus"
# Find the latest distribution files
LATEST_FILES=$(ls -t dist | grep -E "^${PACKAGE_NAME}-[0-9]+.[0-9]+.[0-9]+.*\.(tar\.gz|whl)$")
# Upload the latest files individually
for FILE in $LATEST_FILES; do
echo "Uploading $FILE"
twine upload "dist/$FILE"
done