Skip to content

feat: Add file copying for 'latest' directory in package workflow #29

feat: Add file copying for 'latest' directory in package workflow

feat: Add file copying for 'latest' directory in package workflow #29

Workflow file for this run

name: Publish to PyPI
on:
push:
tags:
- 'v*' # 当推送版本标签时触发
workflow_dispatch: # 允许手动触发
jobs:
# PyPI 发布任务
deploy-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Extract version from tag
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
else
echo "VERSION=latest" >> $GITHUB_ENV
fi
- name: Update version in setup.py
run: |
sed -i "s/version='.*'/version='$VERSION'/g" setup.py
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*