-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (55 loc) · 1.76 KB
/
release_pypi.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 推送到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/*