Skip to content

✨ feat: 测试自动发版 #23

✨ feat: 测试自动发版

✨ feat: 测试自动发版 #23

Workflow file for this run

# 推送到pypi
name: release_to pypi
# 只在setup.py更新时触发
on:
push:
paths:
- 'setup.py'
jobs:
release_to:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
# 读取setup.py setup方法的版本号
- name: Get version
id: get_version
run: |
echo ::set-output name=version::$(python setup.py --version)
# 获取pypi的该项目的版本号
- name: Get pypi version
id: get_pypi_version
run: |
echo ::set-output name=version::$(curl -s https://pypi.org/pypi/music-tool-kit/json | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
# # 如果version和curr_version相同退出工作流
# - name: Check version
# if: ${{ steps.get_version.outputs.version }}==${{ steps.get_pypi_version.outputs.curr_version }}
# env:
# version: ${{ steps.get_version.outputs.version }}
# curr_version: ${{ steps.get_pypi_version.outputs.version }}
# run: |
# echo $version
# echo $curr_version
# echo "version is same, exit"
# exit 1
- name: Install dependencies
if: ${{ steps.get_version.outputs.version }}!=${{ steps.get_pypi_version.outputs.curr_version }}
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
if: ${{ steps.get_version.outputs.version }}!=${{ steps.get_pypi_version.outputs.curr_version }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
# # 根据setup的版本号创建Tag
# - name: Create Tag
# id: create_tag
# uses: actions/create-release@v1
# continue-on-error: true
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# with:
# tag_name: ${{ steps.get_version.outputs.version }}
# release_name: Release ${{ steps.get_version.outputs.version }}
# draft: false
# prerelease: false