Skip to content

Commit 717a319

Browse files
author
ericoder960803
committed
chore: replace complex workflow with simple sdist
1 parent f17a501 commit 717a319

1 file changed

Lines changed: 14 additions & 51 deletions

File tree

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,30 @@
1-
name: Build and Publish to PyPI
1+
name: Simple Publish to PyPI
22

33
on:
44
push:
55
tags:
6-
- 'v*' # 當你推送到 v0.1.1 這種 tag 時觸發
6+
- 'v*'
77

88
jobs:
9-
# 第一階段:編譯各種版本的 Wheel 檔案
10-
build_wheels:
11-
name: Build wheels on ${{ matrix.os }}
12-
runs-on: ${{ matrix.os }}
13-
strategy:
14-
matrix:
15-
os: [ubuntu-latest] # 如果要支援 Windows 可加 windows-latest
16-
17-
steps:
18-
- uses: actions/checkout@v4
19-
20-
- name: Build wheels
21-
uses: pypa/cibuildwheel@v2.16.2
22-
env:
23-
# 指定編譯的 Python 版本 (例如 3.10, 3.11)
24-
CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64"
25-
# 編譯前需要先安裝的依賴 (例如 torch)
26-
CIBW_BEFORE_BUILD: "pip install torch"
27-
28-
- name: temp
29-
uses: actions/upload-artifact@v4
30-
with:
31-
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
32-
path: ./wheelhouse/*.whl # cibw 的成品在這裡
33-
34-
# 第二階段:產生原始碼包 (sdist)
35-
build_sdist:
36-
name: Build source distribution
9+
build_and_publish:
3710
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
3813
steps:
3914
- uses: actions/checkout@v4
40-
- name: Build sdist
41-
run: pipx run build --sdist
42-
- uses: actions/upload-artifact@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
4318
with:
44-
name: cibw-sdist
45-
path: dist/*.tar.gz
19+
python-version: "3.10"
4620

47-
# 第三階段:正式發布到 PyPI
48-
upload_pypi:
49-
needs: [build_wheels, build_sdist]
50-
runs-on: ubuntu-latest
51-
environment: pypi
52-
permissions:
53-
id-token: write # 重要:PyPI Attestation 驗證身份必備
54-
steps:
55-
- name: 下載所有成品
56-
uses: actions/download-artifact@v4
57-
with:
58-
pattern: cibw-*
59-
path: dist
60-
merge-multiple: true
21+
- name: Build sdist (只打包原始碼,跳過編譯)
22+
run: |
23+
pip install build
24+
python -m build --sdist
6125
6226
- name: Publish to PyPI
6327
uses: pypa/gh-action-pypi-publish@release/v1
6428
with:
65-
# 解決你遇到的 400 錯誤:若檔案已存在則跳過,不報錯
66-
skip-existing: true
29+
skip-existing: true
6730
verbose: true

0 commit comments

Comments
 (0)