Skip to content

Merge pull request #66 from nichuanfang/dependabot/pip/yt-dlp-2024.8.6 #286

Merge pull request #66 from nichuanfang/dependabot/pip/yt-dlp-2024.8.6

Merge pull request #66 from nichuanfang/dependabot/pip/yt-dlp-2024.8.6 #286

Workflow file for this run

# 推送到pypi
name: release_to pypi
on:
push:
tags:
- 'v*'
jobs:
release_to:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11.0
cache: pip
# 读取最新版本号
- name: Get version
id: get_version
run: |
TAG_VERSION=$(basename "${{ github.ref }}")
echo "version=${TAG_VERSION}" >> "$GITHUB_OUTPUT"
# 获取pypi的该项目的版本号
- name: Get pypi version
id: get_pypi_version
run: |
echo "version=$(curl -s https://pypi.org/pypi/music-tool-kit/json | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")" >> "$GITHUB_OUTPUT"
# 如果version和curr_version相同退出工作流
- name: Check version
env:
version: ${{ steps.get_version.outputs.version }}
curr_version: ${{ steps.get_pypi_version.outputs.version }}
run: |
if [ $version == $curr_version ]; then
echo "version is same, exit"
exit 1
fi
- name: Replace version in setup.py
run: |
sed -i "s/#version/${{ steps.get_version.outputs.version }}/g" setup.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
continue-on-error: true
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*