Skip to content

fix and test

fix and test #7

name: Publish to PyPI
on:
push:
branches:
- main
jobs:
build-n-publish:
name: Build and publish (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
# 設定矩陣策略
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
# 如果其中一個版本失敗,其他版本繼續執行
fail-fast: false
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install torch setuptools wheel build
- name: Build binary wheel and source tarball
run: python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# 關鍵:允許上傳重複的版本檔案(因為多個 Job 會推同一個版號)
# 這樣 3.9 傳完後,3.10 傳的時候才不會因為版號相同而被 PyPI 擋掉
skip-existing: true